#!/bin/sh

set -eux

debian/rules clean > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_clean.log"
dh_update_autotools_config > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_autotools_config.log"
dh_autoreconf > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_autoreconf.log"
debian/rules override_dh_auto_configure > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_configure.log"
debian/rules override_dh_auto_build > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_build.log"

# Some tests need the test helper binaries.
make -C "debian/build-${FLAVOR}/tests/libtest" check > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_libtests_build.log"

# Every test session starts the dnsd test server (tests/server/servers) since
# 8.23.0, so the test servers need to be built as well.
make -C "debian/build-${FLAVOR}/tests/server" check > "${AUTOPKGTEST_ARTIFACTS}/${SUFFIX}_servers_build.log"

# Test harness expects to find config.ini, curl and curlinfo relative to the
# current working directory.
cd "debian/build-${FLAVOR}"

# test_19_01_check_tcp_rst expects tcpdump to capture TCP RSTs, which it doesn't
# in the autopkgtest containers. Upstream skips it in CI for the same reason.
python3 -m pytest tests/http/ -v \
    --deselect tests/http/test_19_shutdown.py::TestShutdown::test_19_01_check_tcp_rst
