12 config_common="prefork 1
18 dont_check_server_alive=no
20 ran_no=$((ran_no + 1))
28 failed_no=$((failed_no + 1))
34 if [ "$dont_check_server_alive" != 'no' ]; then
41 failed_no=$((failed_no + 1))
46 ok=$((ran_no - failed_no))
48 echo "tests: $ran_no / passed: $ok / failed: $failed_no"
49 if [ "$failed" != "" ]; then
51 echo "failed tests:$failed"
57 # usage: gen_config <global config> <server config>
58 # generates a configuration file reg.conf
71 echo "failed to parse the config" >&2
78 server "localhost.local" {
82 relay-to "localhost:$port"
89 echo "failed to parse the config" >&2
95 if ! $gmid -n -c reg.conf >/dev/null 2>&1; then
100 # usage: setup_simple_test <global config> <server config>
101 # generates a configuration file with `gen_config', validates it and
102 # launches the daemon
103 setup_simple_test() {
109 # return the body of the request on stdout
111 $gg -T10 $ggflags "gemini://localhost:10965/$1" || true
115 # return the meta response line on stdout
117 $gg -T10 -d header $ggflags "gemini://localhost:10965/$1" || true
120 # usage: fetch <path>
121 # fetches the header and the body. They're returned in $hdr and
124 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
129 # usage: fetch_hdr <path>
130 # fetches the header into $hdr
136 # usage: check_reply header body
137 # checks that $hdr and $body are equal to the given strings
139 if [ "$hdr" != "$1" ]; then
140 echo "Header mismatch" >&2
141 echo "wants : $1" >&2
142 echo "got : $hdr" >&2
146 if [ "$body" != "$2" ]; then
147 echo "Body mismatch" >&2
148 echo "wants : $2" >&2
149 echo "got : $body" >&2
156 kill -HUP "$(cat gmid.pid)"
161 $gmid -P gmid.pid -c reg.conf
163 # give gmid time to bind the port, otherwise we end up
164 # executing gg when gmid isn't ready yet.
169 if [ ! -f gmid.pid ]; then
173 pid="$(cat gmid.pid || true)"
174 if [ "$pid" = "" ]; then
178 # remember: we're running under ``set -e''
179 if ps $pid >/dev/null; then
191 pid="$(cat gmid.pid || true)"
192 if [ "$pid" != "" ]; then
199 rm -f bigfile bigfile.sha