re-add sha script; it's used in the Makefile

While there, use it in the tests too
This commit is contained in:
Omar Polo 2021-10-04 09:40:05 +00:00
parent 2072343d6b
commit 6e0f14d51e
3 changed files with 18 additions and 19 deletions

View File

@ -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
}

16
regress/sha Executable file
View File

@ -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

View File

@ -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)"
}