diff options
author | Omar Polo <op@omarpolo.com> | 2023-06-13 10:59:50 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-06-13 10:59:50 +0000 |
commit | 611dffe81628683ebd2b48ae6f02f9bff6081ee9 (patch) | |
tree | 057f6e8b1949e85efc89d4bafde38ed44f004ca0 /regress | |
parent | 1b9031f1fccde6f61363328c6efebf045dd97dec (diff) |
remove regress/sha
we can use cmp to tell if two files are different, which also has
the benefit of being available everywhere and reporting the byte
offset of the first difference. Reduces the test dependencies on
some systems.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/Makefile | 5 | ||||
-rwxr-xr-x | regress/sha | 16 | ||||
-rw-r--r-- | regress/tests.sh | 16 |
3 files changed, 14 insertions, 23 deletions
diff --git a/regress/Makefile b/regress/Makefile index a40d9c2..2e09681 100644 --- a/regress/Makefile +++ b/regress/Makefile @@ -16,7 +16,6 @@ DISTFILES = Makefile \ puny-test.c \ regress \ serve-bigfile \ - sha \ slow \ tests.sh \ valid.ext @@ -96,9 +95,7 @@ clean: testdata: fill-file mkdir testdata ./fill-file testdata/bigfile - ./sha testdata/bigfile testdata/bigfile.sha printf "# hello world\n" > testdata/index.gmi - ./sha testdata/index.gmi testdata/index.gmi.sha cp hello slow err invalid serve-bigfile env testdata/ cp max-length-reply testdata mkdir testdata/dir @@ -111,4 +108,4 @@ dist: ${DISTFILES} mkdir -p ${DESTDIR}/ ${INSTALL} -m 0644 ${DISTFILES} ${DESTDIR}/ cd ${DESTDIR}/ && chmod +x env err hello invalid \ - max-length-reply regress sha slow + max-length-reply regress slow diff --git a/regress/sha b/regress/sha deleted file mode 100755 index 6fc6273..0000000 --- a/regress/sha +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# USAGE: ./sha in out -# writes the sha256 of in to file out - -if command -v sha256 >/dev/null; then - exec sha256 < "$1" > "$2" -fi - -if command -v sha256sum >/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 eb9b54f..5ebc33b 100644 --- a/regress/tests.sh +++ b/regress/tests.sh @@ -48,10 +48,20 @@ test_serve_big_files() { hdr="$(head /bigfile)" get /bigfile > bigfile - ./sha bigfile bigfile.sha - body="$(cat bigfile.sha)" - check_reply "20 application/octet-stream" "$(cat testdata/bigfile.sha)" + want="20 application/octet-stream" + if [ "$hdr" != "$want" ]; then + echo "Header mismatch" >&2 + echo "wants : $want" >&2 + echo "got : $hdr" >&2 + return 1 + fi + + if ! cmp -s bigfile testdata/bigfile; then + echo "received bigfile is not as expected" + cmp bigfile testdata/bigfile + return 1 + fi } test_dont_execute_scripts() { |