#!/bin/bash
set -evux

check_command()
{
	# Set LD_LIBRARY_PATH so tests can find the installed libs;
	# libanastasis* land in the multiarch libdir, the Taler libraries
	# come from the Debian packages.
	export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/taler:/usr/lib/x86_64-linux-gnu/taler-merchant:/usr/lib
	# taler-unified-setup.sh (used by the reducer and IBAN tests) wants this
	export USER=root
	PGPORT=5432 make check
}

print_logs()
{
	set +e
	echo "Printing meson log"
	cat build/meson-logs/testlog.txt
}

if ! check_command ; then
	print_logs
	exit 1
fi
