#!/bin/bash
set -evux

check_command()
{
    # /usr/local is where the install step has put the libararies
    export TALER_EXCHANGE_PREFIX=/usr/local
    export TALER_AUDITOR_PREFIX=/usr/local

    # bank and merchant are from the debian package, having /usr as
    # their installation path's
    export TALER_BANK_PREFIX=/usr
    export TALER_MERCHANT_PREFIX=/usr
    export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu/taler-merchant

    # Some tests appear to require this
    export USER=root

    make check installcheck integrationtests
}

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

if ! check_command ; then
	print_logs
	exit 1
fi
