13 config_common="prefork 1
19 dont_check_server_alive=no
21 ran_no=$((ran_no + 1))
29 failed_no=$((failed_no + 1))
35 if [ "$dont_check_server_alive" != 'no' ]; then
42 failed_no=$((failed_no + 1))
47 ok=$((ran_no - failed_no))
49 echo "tests: $ran_no / passed: $ok / failed: $failed_no"
50 if [ "$failed" != "" ]; then
52 echo "failed tests:$failed"
58 # usage: gen_config <global config> <server config>
59 # generates a configuration file reg.conf
72 echo "failed to parse the config" >&2
79 server "localhost.local" {
83 relay-to "localhost:$port"
90 echo "failed to parse the config" >&2
96 if ! $gmid -n -f reg.conf >/dev/null 2>&1; then
101 # usage: setup_simple_test <global config> <server config>
102 # generates a configuration file with `gen_config', validates it and
103 # launches the daemon
104 setup_simple_test() {
110 # return the body of the request on stdout
112 $gg -T10 $ggflags "gemini://localhost:10965/$1" || true
116 # return the meta response line on stdout
118 $gg -T10 -d header $ggflags "gemini://localhost:10965/$1" || true
121 # usage: fetch <path>
122 # fetches the header and the body. They're returned in $hdr and
125 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
130 # usage: fetch_hdr <path>
131 # fetches the header into $hdr
137 # usage: check_reply header body
138 # checks that $hdr and $body are equal to the given strings
140 if [ "$hdr" != "$1" ]; then
141 echo "Header mismatch" >&2
142 echo "wants : $1" >&2
143 echo "got : $hdr" >&2
147 if [ "$body" != "$2" ]; then
148 echo "Body mismatch" >&2
149 echo "wants : $2" >&2
150 echo "got : $body" >&2
157 kill -HUP "$(cat gmid.pid)"
162 $gmid -P gmid.pid -f reg.conf
164 # give gmid time to bind the port, otherwise we end up
165 # executing gg when gmid isn't ready yet.
170 if [ ! -f gmid.pid ]; then
174 pid="$(cat gmid.pid || true)"
175 if [ "$pid" = "" ]; then
179 # remember: we're running under ``set -e''
180 if ps $pid >/dev/null; then
192 pid="$(cat gmid.pid || true)"
193 if [ "$pid" != "" ]; then
200 rm -f bigfile bigfile.sha