mirror of https://github.com/omar-polo/gmid.git
re-add sha script; it's used in the Makefile
While there, use it in the tests too
This commit is contained in:
parent
2072343d6b
commit
6e0f14d51e
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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)"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue