#!./common/bats/bin/bats
# -*-sh-*-

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

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

check_rms

NODES=2
TASKS=$(tasks_count 8)
ARGS=8

@test "[libs/PETSc] C binary runs under resource manager (${RESOURCE_MANAGER}/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
	if [ ! -x C_test ]; then
		flunk "C_test binary does not exist"
	fi

	run_mpi_binary ./C_test "${ARGS}" "${NODES}" "${TASKS}"
	assert_success
}

@test "[libs/PETSc] MPI C binary runs under resource manager (${RESOURCE_MANAGER}/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
	if [ ! -x C_mpi_test ]; then
		flunk "C_mpi_test binary does not exist"
	fi

	run_mpi_binary ./C_mpi_test "${ARGS}" "${NODES}" "${TASKS}"
	assert_success
}

@test "[libs/PETSc] MPI F90 binary runs under resource manager (${RESOURCE_MANAGER}/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
	if [ ! -x F90_test ]; then
		flunk "F90_test binary does not exist"
	fi

	run_mpi_binary ./F90_test "" "${NODES}" "${TASKS}"
	assert_success
}
