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
67 if ! $gmid -n -c reg.conf >/dev/null 2>&1; then
72 # usage: setup_simple_test <global config> <server config>
73 # generates a configuration file with `gen_config', validates it and
81 # return the body of the request on stdout
83 $gg -T10 $ggflags "gemini://localhost:10965/$1" || true
87 # return the meta response line on stdout
89 $gg -T10 -d header $ggflags "gemini://localhost:10965/$1" || true
93 # return both header and body
95 $gg -T10 -dwhole $ggflags "gemini://localhost:10965/$1" || true
99 # fetches the header and the body. They're returned in $hdr and
102 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
107 # usage: fetch_hdr <path>
108 # fetches the header into $hdr
114 # usage: check_reply header body
115 # checks that $hdr and $body are equal to the given strings
117 if [ "$hdr" != "$1" ]; then
118 echo "Header mismatch" >&2
119 echo "wants : $1" >&2
120 echo "got : $hdr" >&2
124 if [ "$body" != "$2" ]; then
125 echo "Body mismatch" >&2
126 echo "wants : $2" >&2
127 echo "got : $body" >&2
134 kill -HUP "$(cat gmid.pid)"
139 $gmid -P gmid.pid -c reg.conf
141 # give gmid time to bind the port, otherwise we end up
142 # executing gg when gmid isn't ready yet.
147 if [ ! -f gmid.pid ]; then
151 pid="$(cat gmid.pid || true)"
152 if [ "$pid" == "" ]; then
156 # remember: we're running under ``set -e''
157 if ps $pid >/dev/null; then
169 pid="$(cat gmid.pid || true)"
170 if [ "$pid" != "" ]; then
177 rm -f bigfile bigfile.sha