2012-01-10 04:34:04 -06:00
|
|
|
#! /bin/bash
|
|
|
|
#
|
|
|
|
# Runs a test from the test directory and compare the resulting VTU files.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# runTest.sh REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY TEST_ARGS
|
|
|
|
#
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo "Usage:"
|
|
|
|
echo
|
2012-10-19 07:42:37 -05:00
|
|
|
echo "runTest.sh TEST_TYPE TEST_BINARY [TEST_ARGS]"
|
|
|
|
echo "where TEST_TYPE can either be --plain or --simulation"
|
2012-01-10 04:34:04 -06:00
|
|
|
};
|
|
|
|
|
2012-10-19 07:42:37 -05:00
|
|
|
TEST_TYPE="$1"
|
|
|
|
TEST_NAME="$2"
|
|
|
|
TEST_ARGS="${@:3:100}"
|
2012-01-10 04:34:04 -06:00
|
|
|
|
2012-10-19 07:42:37 -05:00
|
|
|
# make sure we have at least 2 parameters
|
|
|
|
if test "$#" -lt 2; then
|
2012-01-10 04:34:04 -06:00
|
|
|
echo "Wrong number of parameters"
|
|
|
|
echo
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-10-19 07:42:37 -05:00
|
|
|
# find the binary in the its folder
|
|
|
|
TEST_BINARY=$(find -type f -executable -name "$TEST_NAME")
|
2012-01-10 04:34:04 -06:00
|
|
|
|
|
|
|
# make sure the binary is of the test is present
|
|
|
|
if ! test -x "$TEST_BINARY"; then
|
2012-10-19 07:42:37 -05:00
|
|
|
echo "$TEST_NAME does not exist or is not executable"
|
2012-01-10 04:34:04 -06:00
|
|
|
echo
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#run the test
|
|
|
|
echo "######################"
|
2012-10-19 07:42:37 -05:00
|
|
|
echo "# Running test '$TEST_NAME'"
|
2012-01-10 04:34:04 -06:00
|
|
|
echo "######################"
|
2012-10-19 07:42:37 -05:00
|
|
|
|
2012-10-22 15:44:42 -05:00
|
|
|
RND="$RANDOM"
|
|
|
|
"$TEST_BINARY" $TEST_ARGS | tee "test-$RND.log"
|
|
|
|
RET="${PIPESTATUS[0]}"
|
|
|
|
if test "$RET" != "0"; then
|
2012-01-10 04:34:04 -06:00
|
|
|
echo "Executing the binary failed!"
|
2012-10-22 15:44:42 -05:00
|
|
|
rm "test-$RND.log"
|
2012-01-10 04:34:04 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-10-19 07:42:37 -05:00
|
|
|
case "$TEST_TYPE" in
|
|
|
|
"--simulation")
|
|
|
|
# compare the results
|
|
|
|
echo "######################"
|
|
|
|
echo "# Comparing results"
|
|
|
|
echo "######################"
|
2012-10-22 15:44:42 -05:00
|
|
|
SIM_NAME=$(grep "Writing result file for" test-$RND.log | sed "s/.*\"\(.*\)\".*/\1/" | head -n1)
|
|
|
|
TEST_RESULT=$(ls $SIM_NAME*.vtu $SIM_NAME*.vtp 2> /dev/null | sort | tail -n 1)
|
2012-10-19 07:42:37 -05:00
|
|
|
if ! test -r "$TEST_RESULT"; then
|
|
|
|
echo "File $TEST_RESULT does not exist or is not readable"
|
2012-10-22 15:44:42 -05:00
|
|
|
rm "test-$RND.log"
|
2012-10-19 07:42:37 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
REFERENCE_RESULT="referencesolutions/$TEST_RESULT"
|
|
|
|
if ! test -r "$REFERENCE_RESULT"; then
|
|
|
|
echo "File $REFERENCE_RESULT does not exist or is not readable"
|
2012-10-22 15:44:42 -05:00
|
|
|
rm "test-$RND.log"
|
2012-10-19 07:42:37 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! python bin/fuzzycomparevtu.py "$REFERENCE_RESULT" "$TEST_RESULT"; then
|
|
|
|
echo "The files \"$TEST_RESULT\" and \"$REFERENCE_RESULT\" are different."
|
|
|
|
echo "Make sure the contents of \"$TEST_RESULT\" are still valid and "
|
|
|
|
echo "make it the reference result if necessary."
|
2012-10-22 15:44:42 -05:00
|
|
|
rm "test-$RND.log"
|
2012-10-19 07:42:37 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# SUCCESS!!!!!!
|
|
|
|
echo "Result and reference result are identical"
|
2012-10-22 15:44:42 -05:00
|
|
|
rm "test-$RND.log"
|
2012-10-19 07:42:37 -05:00
|
|
|
exit 0
|
2012-01-10 04:34:04 -06:00
|
|
|
|
2012-10-19 07:42:37 -05:00
|
|
|
;;
|
|
|
|
*)
|
2012-10-22 15:44:42 -05:00
|
|
|
rm "test-$RND.log"
|
2012-10-19 07:42:37 -05:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|