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

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

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

check_rms
rm=$RESOURCE_MANAGER

NODES=2
TASKS=`tasks_count 8`
ARGS=8

module load $python_module_prefix-mpi4py

@test "[dev-tools/$python_module_prefix-mpi4py] python hello world ($rm/$LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    if [ -z ${_python} ];then
	flunk "\${_python} not set"
    fi

    if [ ! -s helloworld.py ];then
	flunk "helloworld.py does not exist"
    fi

    if [ "$LMOD_FAMILY_MPI" == "mvapich2" ];then
        export MV2_SUPPORT_DPM=1
	export MV2_ENABLE_AFFINITY=0
    fi


    run_mpi_binary "${_python} helloworld.py" $ARGS $NODES $TASKS
    assert_success
}
