mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
runtest.sh: fix shellcheck warninings
at least the ones which were no false positives
This commit is contained in:
parent
71ebee78e7
commit
79bfc102cc
@ -6,22 +6,22 @@
|
|||||||
#
|
#
|
||||||
# runTest.sh REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY TEST_ARGS
|
# runTest.sh REFERENCE_RESULT_FILE TEST_RESULT_FILE TEST_BINARY TEST_ARGS
|
||||||
#
|
#
|
||||||
MY_DIR="$(dirname $0)"
|
MY_DIR="$(dirname "$0")"
|
||||||
|
|
||||||
function usage() {
|
usage() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo
|
echo
|
||||||
echo "runTest.sh TEST_TYPE TEST_BINARY [TEST_ARGS]"
|
echo "runTest.sh TEST_TYPE TEST_BINARY [TEST_ARGS]"
|
||||||
echo "where TEST_TYPE can either be --plain or --simulation (is '$TEST_TYPE')."
|
echo "where TEST_TYPE can either be --plain or --simulation (is '$TEST_TYPE')."
|
||||||
};
|
};
|
||||||
|
|
||||||
function validateResults() {
|
validateResults() {
|
||||||
OUTPUT_FILE="$1"
|
OUTPUT_FILE="$1"
|
||||||
SIM_NAME="$2"
|
SIM_NAME="$2"
|
||||||
|
|
||||||
for REFERENCE_RESULT in ${MY_DIR}/../tests/referencesolutions/$SIM_NAME*; do
|
for REFERENCE_RESULT in ${MY_DIR}/../tests/referencesolutions/$SIM_NAME*; do
|
||||||
echo "Comparing with \"$REFERENCE_RESULT\"... "
|
echo "Comparing with \"$REFERENCE_RESULT\"... "
|
||||||
if python ${MY_DIR}/fuzzycomparevtu.py "$REFERENCE_RESULT" "$OUTPUT_FILE"; then
|
if python "${MY_DIR}/fuzzycomparevtu.py" "$REFERENCE_RESULT" "$OUTPUT_FILE"; then
|
||||||
# SUCCESS!!!!!!
|
# SUCCESS!!!!!!
|
||||||
echo "Result file '$OUTPUT_FILE' and reference '$REFERENCE_RESULT' are identical"
|
echo "Result file '$OUTPUT_FILE' and reference '$REFERENCE_RESULT' are identical"
|
||||||
return 0
|
return 0
|
||||||
@ -93,7 +93,7 @@ case "$TEST_TYPE" in
|
|||||||
SIM_NAME=$(grep "Initializing problem" "test-$RND.log" | sed "s/.*\"\(.*\)\".*/\1/" | head -n1)
|
SIM_NAME=$(grep "Initializing problem" "test-$RND.log" | sed "s/.*\"\(.*\)\".*/\1/" | head -n1)
|
||||||
NUM_TIMESTEPS=$(grep "Writing result" "test-$RND.log" | wc -l)
|
NUM_TIMESTEPS=$(grep "Writing result" "test-$RND.log" | wc -l)
|
||||||
TEST_RESULT=$(printf "%s-%05i" "$SIM_NAME" "$NUM_TIMESTEPS")
|
TEST_RESULT=$(printf "%s-%05i" "$SIM_NAME" "$NUM_TIMESTEPS")
|
||||||
TEST_RESULT=$(ls $TEST_RESULT.*)
|
TEST_RESULT=$(ls "$TEST_RESULT".*)
|
||||||
rm "test-$RND.log"
|
rm "test-$RND.log"
|
||||||
if ! test -r "$TEST_RESULT"; then
|
if ! test -r "$TEST_RESULT"; then
|
||||||
echo "File $TEST_RESULT does not exist or is not readable"
|
echo "File $TEST_RESULT does not exist or is not readable"
|
||||||
@ -179,7 +179,7 @@ case "$TEST_TYPE" in
|
|||||||
|
|
||||||
"--parameters")
|
"--parameters")
|
||||||
HELP_MSG="$($TEST_BINARY --help)"
|
HELP_MSG="$($TEST_BINARY --help)"
|
||||||
if test "$(echo $HELP_MSG | grep -i usage)" == ''; then
|
if test "$(echo "$HELP_MSG" | grep -i usage)" == ''; then
|
||||||
echo "$TEST_BINARY did not accept '--help' parameter"
|
echo "$TEST_BINARY did not accept '--help' parameter"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -194,20 +194,20 @@ EndTime=100
|
|||||||
InitialTimeStepSize=100
|
InitialTimeStepSize=100
|
||||||
UndefinedParam="blubb"
|
UndefinedParam="blubb"
|
||||||
EOF
|
EOF
|
||||||
if ! $TEST_BINARY --parameter-file="paramfile-$RND.ini" 2>&1 > /dev/null; then
|
if ! $TEST_BINARY --parameter-file="paramfile-$RND.ini" > 2>&1 /dev/null; then
|
||||||
echo "$TEST_BINARY does not correctly read a parameter file"
|
echo "$TEST_BINARY does not correctly read a parameter file"
|
||||||
exit 1
|
exit 1
|
||||||
elif $TEST_BINARY --parameter-file="foobar.ini" 2>&1 > /dev/null; then
|
elif $TEST_BINARY --parameter-file="foobar.ini" > 2>&1 /dev/null; then
|
||||||
echo "$TEST_BINARY does not abort even though the specified parameter file does not exist"
|
echo "$TEST_BINARY does not abort even though the specified parameter file does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
elif ! $TEST_BINARY --foo --end-time=1 2>&1 > /dev/null; then
|
elif ! $TEST_BINARY --foo --end-time=1 > 2>&1 /dev/null; then
|
||||||
echo "$TEST_BINARY does not accept a flag parameters"
|
echo "$TEST_BINARY does not accept a flag parameters"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# test some invalid parameter names
|
# test some invalid parameter names
|
||||||
for PARAM in foo -- -0foo --0foo --foo--bar --foo- -foo --foo-bar§=abc ; do
|
for PARAM in foo -- -0foo --0foo --foo--bar --foo- -foo --foo-bar§=abc ; do
|
||||||
if $TEST_BINARY "$PARAM" --end-time=100 2>&1 > /dev/null; then
|
if $TEST_BINARY "$PARAM" --end-time=100 > 2>&1 /dev/null; then
|
||||||
echo "$TEST_BINARY accepted invalid command line option '$PARAM'"
|
echo "$TEST_BINARY accepted invalid command line option '$PARAM'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user