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
111 # return both header and body
113 $gg -T10 -dwhole $ggflags "gemini://localhost:10965/$1" || true
116 # usage: fetch <path>
117 # fetches the header and the body. They're returned in $hdr and
120 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
125 # usage: fetch_hdr <path>
126 # fetches the header into $hdr
132 # usage: check_reply header body
133 # checks that $hdr and $body are equal to the given strings
135 if [ "$hdr" != "$1" ]; then
136 echo "Header mismatch" >&2
137 echo "wants : $1" >&2
138 echo "got : $hdr" >&2
142 if [ "$body" != "$2" ]; then
143 echo "Body mismatch" >&2
144 echo "wants : $2" >&2
145 echo "got : $body" >&2
152 kill -HUP "$(cat gmid.pid)"
157 $gmid -P gmid.pid -c reg.conf
159 # give gmid time to bind the port, otherwise we end up
160 # executing gg when gmid isn't ready yet.
165 if [ ! -f gmid.pid ]; then
169 pid="$(cat gmid.pid || true)"
170 if [ "$pid" == "" ]; then
174 # remember: we're running under ``set -e''
175 if ps $pid >/dev/null; then
187 pid="$(cat gmid.pid || true)"
188 if [ "$pid" != "" ]; then
195 rm -f bigfile bigfile.sha