#!/bin/sh

exec 2>&1
set -e

cd regressiontests

# Mask flaky tests on amd64 only.
# ref. https://gitlab.com/gromacs/gromacs/-/issues/5226#note_2342932082
if dpkg-architecture -e amd64
then
    mkdir -p disabled_tests
    mv complex/swap_[xyz] disabled_tests
fi

echo "========================================================"
echo "Starting regression tests: basic build, single precision"
echo "========================================================"
perl gmxtest.pl all

echo "========================================================"
echo "Starting regression tests: basic build, double precision"
echo "========================================================"
perl gmxtest.pl all -double

echo "============================================================="
echo "Starting regression tests: MPI build, single precision (only)"
echo "============================================================="
export OMPI_MCA_rmaps_base_oversubscribe=1
export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe
perl gmxtest.pl all -np 4 || dpkg-architecture -e s390x

perl gmxtest.pl clean

if dpkg-architecture -e amd64
then
    mv disabled_tests/swap_[xyz] complex/
    rmdir disabled_tests
fi
