Files
IFEM/Apps/Common/scripts/iotest.sh.in
Arne Morten Kvarving 4dc1171c18 changed: make failed.log updates atomic in regression tests
this to obtain a proper failed.log even if running multiple tests
in parallel
2021-09-10 11:30:06 +02:00

68 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# This script performs a single IO regression test.
# It is used by the 'make test' target in the buildsystems
# Usually you should use 'make test' rather than calling this script directly
#
# Parameters: $1 = Application binary
# $2 = Regression test file
# $3 = File type to generate/test
# A IO regression test file is of the format:
# parameters to application
# blank line
# output from listing application
function atomic_log_file {
(
flock -x 200
cat $1 >> @CMAKE_BINARY_DIR@/failed.log
) 200>/var/lock/ifemloglock
}
mysim=$1
test -f $2 || exit 1
cd `dirname $2`
MAPFILE=`head -n1 $2`
tmplog=`mktemp -t ifemlogXXXXXX`
tmpnew=`mktemp -t ifemlogXXXXXX`
tmpold=`mktemp -t ifemlogXXXXXX`
output=`mktemp -t ifemXXXXXX.$3`
if [ "$3" == "hdf5" ]
then
test -n "$4" && mysim="mpirun -n $4 $mysim"
$mysim $MAPFILE -hdf5 $output 2>&1 | tee $tmplog
else
$mysim $MAPFILE -vtf 0 -vtffile $output 2>&1 | tee $tmplog
fi
if test $? -ne 0
then
atomic_log_file $tmplog
exit 1
fi
tail -n +3 $2 > $tmpold
if [ "$3" == "hdf5" ]
then
@H5LS_COMMAND@ -r $output > $tmpnew
else
@VTFLS_COMMAND@ $output > $tmpnew
fi
diff -u $tmpold $tmpnew > $tmplog
res=$?
if test $res -ne 0
then
faillog=`mktemp -t ifemfailXXXXXX`
echo "Failure for $2" > $faillog
echo "======================" >> $faillog
cat $tmplog >> $faillog
atomic_log_file $faillog
cat $faillog
rm -f $faillog
fi
rm $tmpnew $tmpold $tmplog $output
exit $res