12 config_common="prefork 1
18 dont_check_server_alive=no
20 ran_no=$((ran_no + 1))
28 failed_no=$((failed_no + 1))
33 if [ "$dont_check_server_alive" != 'no' ]; then
40 failed_no=$((failed_no + 1))
45 ok=$((ran_no - failed_no))
47 echo "tests: $ran_no / passed: $ok / failed: $failed_no"
48 if [ "$failed" != "" ]; then
50 echo "failed tests:$failed"
56 # usage: gen_config <global config> <server config>
57 # generates a configuration file reg.conf
70 echo "failed to parse the config" >&2
77 server "localhost.local" {
81 relay-to "localhost:$port"
88 echo "failed to parse the config" >&2
94 if ! $gmid -n -c reg.conf >/dev/null 2>&1; then
99 # usage: setup_simple_test <global config> <server config>
100 # generates a configuration file with `gen_config', validates it and
101 # launches the daemon
102 setup_simple_test() {
108 # return the body of the request on stdout
110 $gg -T10 $ggflags "gemini://localhost:10965/$1" || true
114 # return the meta response line on stdout
116 $gg -T10 -d header $ggflags "gemini://localhost:10965/$1" || true
119 # usage: fetch <path>
120 # fetches the header and the body. They're returned in $hdr and
123 if ! hdr="$(head $1)" || ! body="$(get $1)"; then
128 # usage: fetch_hdr <path>
129 # fetches the header into $hdr
135 # usage: check_reply header body
136 # checks that $hdr and $body are equal to the given strings
138 if [ "$hdr" != "$1" ]; then
139 echo "Header mismatch" >&2
140 echo "wants : $1" >&2
141 echo "got : $hdr" >&2
145 if [ "$body" != "$2" ]; then
146 echo "Body mismatch" >&2
147 echo "wants : $2" >&2
148 echo "got : $body" >&2
155 kill -HUP "$(cat gmid.pid)"
160 $gmid -P gmid.pid -c reg.conf
162 # give gmid time to bind the port, otherwise we end up
163 # executing gg when gmid isn't ready yet.
168 if [ ! -f gmid.pid ]; then
172 pid="$(cat gmid.pid || true)"
173 if [ "$pid" = "" ]; then
177 # remember: we're running under ``set -e''
178 if ps $pid >/dev/null; then
190 pid="$(cat gmid.pid || true)"
191 if [ "$pid" != "" ]; then
198 rm -f bigfile bigfile.sha