#!/bin/bash
set -e
set -x

pkg="libzeep-dev"

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi

cp -r /usr/share/doc/${pkg}/examples/* $AUTOPKGTEST_TMP

cd $AUTOPKGTEST_TMP

cmake -S . -B build
cmake --build build --target daemon-sample

# The tests below fail, presumably since asio insists on
# having a resolver available? Will have to find out.
# For now, we know at least that the applications build.
#
# build/daemon-sample start
# build/daemon-sample status
# msg=$(curl http://127.0.0.1:10330/restcall)
# build/daemon-sample stop
# 
# if [ "$msg" = "Hello, world!" ] ; then
# 	echo "Test passed"
# else
# 	echo "Test failed"
# 	exit 1
# fi
