Blob


1 #!/bin/sh
3 # sha256 of "20 text/gemini\r\n# hello world\n"
4 ok_res=6989d9b0e082c79edb8f625ebb77ddcb07764d3dd0c7c5ae60a27a50a33f6a15
6 # sha256 of docs/script
7 script_res=00bf8349336a4a1896f9e98dda67c8264f70b767343351247db96b4546f8d872
9 get() {
10 ./gg.py "$1" 10965
11 }
13 # check "path" "expected-sha256"
14 check() {
15 got=`get "$1" | $sha | awk '{print \$1}'`
16 if [ "$got" '!=' "$2" ]; then
17 echo "FAIL $1 (with_cgi: $with_cgi)"
18 quit
19 else
20 echo "PASS $1"
21 fi
22 }
24 quit() {
25 pkill gmid
26 exit ${1:-1}
27 }
29 # check for sha256sum (linux) or sha256 (OpenBSD)
30 if which sha256sum >/dev/null; then
31 sha=sha256sum
32 elif which sha256 >/dev/null; then
33 sha=sha256
34 else
35 echo "No sha256/sha256sum binary available"
36 exit 1
37 fi
39 with_cgi="no"
40 ./../gmid -c no-cgi.conf 2>/dev/null &
42 check "/" $ok_res
43 check "/index.gmi" $ok_res
44 check "/script" $script_res
46 if ! pkill gmid; then
47 echo "Is gmid still running?"
48 exit 1
49 fi
51 wait
53 with_cgi="yes"
54 ./../gmid -c cgi.conf 2>/dev/null &
56 check "/" $ok_res
57 check "/index.gmi" $ok_res
58 check "/script" $ok_res
60 quit 0