#!/bin/sh # Starts the server on a spare port, asks it for a page, and checks the # answer. Run from the repository root after a build. set -u port=$((20000 + $$ % 20000)) ./build/tiny-http "$port" & pid=$! trap 'kill "$pid" 2>/dev/null' EXIT INT TERM url="http://127.0.0.1:$port" for i in 1 2 3 4 5 6 7 8 9 10; do curl -s -o /dev/null "$url/" && break sleep 0.1 done fail() { echo "FAIL: $*"; exit 1; } curl -s -i "$url/" | head -n 1 | grep -q '200 OK' || fail "GET / did not answer 200" echo "GET / 200" echo "smoke: 1 request answered"