#!/usr/bin/env -S bats --report-formatter junit --formatter tap -j 2
# -*-sh-*-

load ./common/test_helper_functions || exit 1
source ./common/functions || exit 1

if [ -s ./common/TEST_ENV ]; then
	source ./common/TEST_ENV
fi

setup() {
	if [ "${LMOD_FAMILY_COMPILER}" == "acfl" ] || [ "${LMOD_FAMILY_COMPILER}" == "intel" ]; then
		skip "Test segfaults with ${LMOD_FAMILY_COMPILER} compiler"
	fi
}

check_rms
export RM=$RESOURCE_MANAGER

export TESTNAME="libs/PLASMA"

ARGS=0

@test "[$TESTNAME/C_test] C_test under resource manager ($RM/$LMOD_FAMILY_COMPILER)" {
	if [ ! -s C_test ]; then
		flunk "C_test binary does not exist"
	fi

	run_serial_binary ./C_test $ARGS
	assert_success
}

@test "[$TESTNAME/F90_test] F90_test under resource manager ($RM/$LMOD_FAMILY_COMPILER)" {
	if [ ! -s F90_test ]; then
		flunk "F90_test binary does not exist"
	fi

	run_serial_binary ./F90_test "< gebrd_example.d"
	assert_success
}
