28 if [ "$dont_check" != '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 $gmid -n -c reg.conf >/dev/null
70 # usage: setup_simple_test <global config> <server config>
71 # generates a configuration file with `gen_config', validates it and
79 # return the body of the request on stdout
81 $gg -T10 -b $ggflags "gemini://localhost:10965/$1"
85 # return the meta response line on stdout
87 $gg -T10 -h $ggflags "gemini://localhost:10965/$1"
91 # return both header and body
93 $gg -T10 $ggflags "gemini://localhost:10965/$1"
97 # fetches the header and the body. They're returned in $hdr and
100 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
105 # usage: fetch_hdr <path>
106 # fetches the header into $hdr
112 # usage: check_reply header body
113 # checks that $hdr and $body are equal to the given strings
115 if [ "$hdr" != "$1" ]; then
116 echo "Header mismatch" >&2
117 echo "wants : $1" >&2
118 echo "got : $hdr" >&2
122 if [ "$body" != "$2" ]; then
123 echo "Body mismatch" >&2
124 echo "wants : $1" >&2
125 echo "got : $body" >&2
132 kill -HUP "$(cat gmid.pid)"
137 $gmid -P gmid.pid -c reg.conf
139 # give gmid time to bind the port, otherwise we end up
140 # executing gg when gmid isn't ready yet.
145 if [ ! -f gmid.pid ]; then
149 pid="$(cat gmid.pid || true)"
150 if [ "$pid" == "" ]; then
154 # remember: we're running under ``set -e''
155 if ps $pid >/dev/null; then
167 pid="$(cat gmid.pid || true)"
168 if [ "$pid" != "" ]; then
175 rm -f bigfile bigfile.sha