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.
This commit is contained in:
Omar Polo 2023-06-13 10:59:50 +00:00
parent 1b9031f1fc
commit 611dffe816
4 changed files with 18 additions and 23 deletions

View File

@ -1,3 +1,7 @@
2023-06-13 Omar Polo <op@omarpolo.com>
* regress/sha: remove regress/sha; sha256/sha256sum is no more required for the regress suite.
2022-09-10 Omar Polo <op@omarpolo.com> 2022-09-10 Omar Polo <op@omarpolo.com>
* parse.y (string): retire the deprecated `mime' and `map' config options * parse.y (string): retire the deprecated `mime' and `map' config options

View File

@ -16,7 +16,6 @@ DISTFILES = Makefile \
puny-test.c \ puny-test.c \
regress \ regress \
serve-bigfile \ serve-bigfile \
sha \
slow \ slow \
tests.sh \ tests.sh \
valid.ext valid.ext
@ -96,9 +95,7 @@ clean:
testdata: fill-file testdata: fill-file
mkdir testdata mkdir testdata
./fill-file testdata/bigfile ./fill-file testdata/bigfile
./sha testdata/bigfile testdata/bigfile.sha
printf "# hello world\n" > testdata/index.gmi 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 hello slow err invalid serve-bigfile env testdata/
cp max-length-reply testdata cp max-length-reply testdata
mkdir testdata/dir mkdir testdata/dir
@ -111,4 +108,4 @@ dist: ${DISTFILES}
mkdir -p ${DESTDIR}/ mkdir -p ${DESTDIR}/
${INSTALL} -m 0644 ${DISTFILES} ${DESTDIR}/ ${INSTALL} -m 0644 ${DISTFILES} ${DESTDIR}/
cd ${DESTDIR}/ && chmod +x env err hello invalid \ cd ${DESTDIR}/ && chmod +x env err hello invalid \
max-length-reply regress sha slow max-length-reply regress slow

View File

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

View File

@ -48,10 +48,20 @@ test_serve_big_files() {
hdr="$(head /bigfile)" hdr="$(head /bigfile)"
get /bigfile > 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() { test_dont_execute_scripts() {