From 611dffe81628683ebd2b48ae6f02f9bff6081ee9 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Tue, 13 Jun 2023 10:59:50 +0000 Subject: [PATCH] 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. --- ChangeLog | 4 ++++ regress/Makefile | 5 +---- regress/sha | 16 ---------------- regress/tests.sh | 16 +++++++++++++--- 4 files changed, 18 insertions(+), 23 deletions(-) delete mode 100755 regress/sha diff --git a/ChangeLog b/ChangeLog index 3d6c516..78270ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2023-06-13 Omar Polo + + * regress/sha: remove regress/sha; sha256/sha256sum is no more required for the regress suite. + 2022-09-10 Omar Polo * parse.y (string): retire the deprecated `mime' and `map' config options 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() {