10 config_common="prefork 1
16 dont_check_server_alive=no
28 if [ "$dont_check_server_alive" != 'no' ]; then
39 if [ "$failed" != "" ]; then
41 echo "failed tests:$failed"
47 # usage: gen_config <global config> <server config>
48 # generates a configuration file reg.conf
61 echo "failed to parse the config" >&2
68 server "localhost.local" {
72 relay-to "localhost:$port"
79 echo "failed to parse the config" >&2
85 if ! $gmid -n -c reg.conf >/dev/null 2>&1; then
90 # usage: setup_simple_test <global config> <server config>
91 # generates a configuration file with `gen_config', validates it and
99 # return the body of the request on stdout
101 $gg -T10 $ggflags "gemini://localhost:10965/$1" || true
105 # return the meta response line on stdout
107 $gg -T10 -d header $ggflags "gemini://localhost:10965/$1" || true
110 # usage: fetch <path>
111 # fetches the header and the body. They're returned in $hdr and
114 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
119 # usage: fetch_hdr <path>
120 # fetches the header into $hdr
126 # usage: check_reply header body
127 # checks that $hdr and $body are equal to the given strings
129 if [ "$hdr" != "$1" ]; then
130 echo "Header mismatch" >&2
131 echo "wants : $1" >&2
132 echo "got : $hdr" >&2
136 if [ "$body" != "$2" ]; then
137 echo "Body mismatch" >&2
138 echo "wants : $2" >&2
139 echo "got : $body" >&2
146 kill -HUP "$(cat gmid.pid)"
151 $gmid -P gmid.pid -c reg.conf
153 # give gmid time to bind the port, otherwise we end up
154 # executing gg when gmid isn't ready yet.
159 if [ ! -f gmid.pid ]; then
163 pid="$(cat gmid.pid || true)"
164 if [ "$pid" = "" ]; then
168 # remember: we're running under ``set -e''
169 if ps $pid >/dev/null; then
181 pid="$(cat gmid.pid || true)"
182 if [ "$pid" != "" ]; then
189 rm -f bigfile bigfile.sha