#!/bin/sh

# Run the upstream test suite without the upstream Makefile, because:
# - we want to test the installed version of foomuuri
# - autopkgtests should not change the source tree, and might not have
#   write access to it
# - Linters should not be run from autopkgtests

set -ex

out=$(mktemp -d)
if [ ! -d "$out" ]; then
    echo "Unable to create temporary directory"
    exit 1
fi

for t in test/??-*; do
    /sbin/foomuuri --set=etc_dir="$t"		\
		   --set=share_dir=etc		\
		   --set=state_dir="$out"	\
		   --set=run_dir="$out"		\
		   check
    diff -u "$t"/golden.txt "$out"/next.fw
done

rm -rf "$out"
