#! /bin/sh
# $NetBSD: test-simple,v 1.2.4.4 2018/11/24 17:22:58 martin Exp $

test="$1"; shift
bozohttpd="$1"; shift
datadir="$1"; shift
curdir="$1"; shift
verbose="$1"; shift
host="$1"; shift

in="$curdir/$test.in"
out="$curdir/$test.out"
tmpout="tmp.$test.out"
tmperr="tmp.$test.err"

if [ "yes" = "$verbose" ]; then
	echo "Running test $test"
else
	exec 2>"$tmperr"
fi

bozotestport=11111

${bozohttpd} "$@" "${datadir}" "${host}" < "$in" > "$tmpout"
if "$curdir/html_cmp" cmp "$out" "$tmpout"; then
	exit 0
else
	if [ "yes" = "$verbose" ]; then
		echo "Failed test $test:"
		cat "$tmperr"
		$curdir/html_cmp diff "$out" "$tmpout"
	fi
	exit 1
fi
