#!/bin/sh

set -e

# Allow outside-of-autopkgtest runs
if [ -z "$AUTOPKGTEST_TMP" ]; then
    AUTOPKGTEST_TMP=$(mktemp -d)
fi

cp -r ./ $AUTOPKGTEST_TMP/source
cd $AUTOPKGTEST_TMP/source

echo "Run standard ./configure"
./configure

cd testsuite
make testpappl.o pwg-driver.o

LIBS="$(pkg-config --libs pappl) -lpthread"

echo "Build testpappl tests against dynamic libpappl"
cc -o ./testpappl ./testpappl.o ./pwg-driver.o ${LIBS}

# Prepare the tests' playground
mkdir testpappl.output

# This needs to _also_ be tested in autopkgtest, for avahi-daemon tests
./testpappl -c -l testpappl.log -L debug -o testpappl.output -t all

cd -
cd -
