From 6e0f14d51ef1971893bb094c873ddde86d0cae61 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Mon, 4 Oct 2021 09:40:05 +0000 Subject: [PATCH] re-add sha script; it's used in the Makefile While there, use it in the tests too --- regress/lib.sh | 17 ----------------- regress/sha | 16 ++++++++++++++++ regress/tests.sh | 4 ++-- 3 files changed, 18 insertions(+), 19 deletions(-) create mode 100755 regress/sha diff --git a/regress/lib.sh b/regress/lib.sh index b38a729..6c741ce 100644 --- a/regress/lib.sh +++ b/regress/lib.sh @@ -159,23 +159,6 @@ check() { return 1 } -# usage: sha in out -# writes the sha256 of `in' to `out' -sha() { - if which sha256 >/dev/null 2>&1; then - sha256 < "$1" > "$2" - return $? - fi - - if which sha256sum >/dev/null 2>&1; then - sha256sum "$1" | awk '{print $1}' > "$2" - return $? - fi - - echo "No sha binary found" >&2 - exit 1 -} - count() { wc -l | xargs } diff --git a/regress/sha b/regress/sha new file mode 100755 index 0000000..02b8eb2 --- /dev/null +++ b/regress/sha @@ -0,0 +1,16 @@ +#!/bin/sh + +# USAGE: ./sha in out +# writes the sha256 of in to file out + +if which sha256 2>/dev/null >/dev/null; then + exec sha256 < "$1" > "$2" +fi + +if which sha256sum 2>/dev/null >/dev/null; then + sha256sum "$1" | awk '{print $1}' > "$2" + exit $? +fi + +echo "No sha binary found" +exit 1 diff --git a/regress/tests.sh b/regress/tests.sh index c01013e..ccb7ea7 100644 --- a/regress/tests.sh +++ b/regress/tests.sh @@ -38,7 +38,7 @@ test_serve_big_files() { hdr="$(head /bigfile)" get /bigfile > bigfile - sha bigfile bigfile.sha + ./sha bigfile bigfile.sha body="$(cat bigfile.sha)" check_reply "20 application/octet-stream" "$(cat testdata/bigfile.sha)" @@ -99,7 +99,7 @@ test_cgi_big_replies() { hdr="$(head /serve-bigfile)" get /bigfile > bigfile - sha bigfile bigfile.sha + ./sha bigfile bigfile.sha body="$(cat bigfile.sha)" check_reply "20 application/octet-stream" "$(cat testdata/bigfile.sha)" }