2017-01-16 01:06:26 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-04-09 03:40:34 -05:00
|
|
|
OPM_TESTS_ROOT=$1
|
2021-08-18 06:46:17 -05:00
|
|
|
BUILD_DIR=$2
|
|
|
|
CONVERT_ECL=$3
|
|
|
|
|
2019-11-27 02:00:22 -06:00
|
|
|
TMPDIR=`mktemp -d`
|
|
|
|
mkdir $TMPDIR/orig
|
|
|
|
mkdir $TMPDIR/new
|
2017-01-16 01:06:26 -06:00
|
|
|
|
2017-01-16 04:46:32 -06:00
|
|
|
# Copy results from a test run to refence dir
|
|
|
|
# $1 = source directory to copy data from
|
|
|
|
# $2 = destination directory to copy data to
|
|
|
|
# $3 = base file name for files to copy
|
|
|
|
# $4...$@ = file types to copy
|
2017-01-16 01:06:26 -06:00
|
|
|
copyToReferenceDir () {
|
|
|
|
SRC_DIR=$1
|
2018-07-03 06:03:13 -05:00
|
|
|
DST_DIR=$2
|
|
|
|
STEM=$3
|
|
|
|
FILETYPES=${@:4}
|
2017-11-10 08:06:47 -06:00
|
|
|
mkdir -p $DST_DIR
|
2017-01-16 01:06:26 -06:00
|
|
|
|
2018-07-03 06:03:13 -05:00
|
|
|
DIFF=1
|
|
|
|
for filetype in $FILETYPES
|
|
|
|
do
|
2019-09-06 08:32:15 -05:00
|
|
|
# Don't flag as changed if both reference and result dir lack a file type
|
|
|
|
# In particular to handle the optional RFT's
|
2021-08-18 06:46:17 -05:00
|
|
|
if [ ! -f $SRC_DIR/$STEM.$filetype ] && [ ! -f $DST_DIR/$STEM.$filetype ]
|
2019-09-06 08:32:15 -05:00
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
2021-08-18 06:46:17 -05:00
|
|
|
diff -q "$SRC_DIR/$STEM.$filetype" "$DST_DIR/$STEM.$filetype"
|
2021-11-12 04:25:07 -06:00
|
|
|
res=$?
|
|
|
|
if test $res -ne 0 && test -n "$CONVERT_ECL"
|
2018-07-03 06:03:13 -05:00
|
|
|
then
|
2021-08-18 06:46:17 -05:00
|
|
|
cp $SRC_DIR/$STEM.$filetype $TMPDIR/new
|
|
|
|
$CONVERT_ECL $TMPDIR/new/$STEM.$filetype
|
2019-11-27 02:00:22 -06:00
|
|
|
cp $DST_DIR/$STEM.$filetype $TMPDIR/orig
|
2021-08-18 06:46:17 -05:00
|
|
|
$CONVERT_ECL $TMPDIR/orig/$STEM.$filetype
|
2019-11-27 02:00:22 -06:00
|
|
|
diff -u $TMPDIR/orig/$STEM.F$filetype $TMPDIR/new/$STEM.F$filetype >> $WORKSPACE/data_diff
|
2018-07-03 06:03:13 -05:00
|
|
|
fi
|
2021-11-12 04:25:07 -06:00
|
|
|
if test $res -ne 0
|
|
|
|
then
|
|
|
|
cp "$SRC_DIR/$STEM.$filetype" $DST_DIR
|
|
|
|
DIFF=0
|
|
|
|
fi
|
2017-01-16 01:06:26 -06:00
|
|
|
done
|
2017-05-04 12:03:25 -05:00
|
|
|
|
2018-07-03 06:03:13 -05:00
|
|
|
return $DIFF
|
|
|
|
}
|
2017-01-16 01:06:26 -06:00
|
|
|
|
2024-07-03 05:22:25 -05:00
|
|
|
# Copy damaris results from a test run to refence dir
|
|
|
|
# $1 = source directory to copy data from
|
|
|
|
# $2 = destination directory to copy data to
|
|
|
|
# $3 = base file name for files to copy
|
|
|
|
copyDamarisToReferenceDir () {
|
|
|
|
SRC_DIR=$1
|
|
|
|
DST_DIR=$2
|
|
|
|
STEM=$3
|
|
|
|
mkdir -p $DST_DIR
|
|
|
|
|
|
|
|
FIRST_FILE=`ls -v1 $SRC_DIR/$STEM*.h5 | head -n1`
|
|
|
|
LAST_FILE=`ls -v1 $SRC_DIR/$STEM*.h5 | tail -n1`
|
|
|
|
|
|
|
|
for file in $FIRST_FILE $LAST_FILE
|
|
|
|
do
|
|
|
|
h5diff -v "$file" "$DST_DIR/`basename $file`" >> $WORKSPACE/data_diff
|
|
|
|
cp "$file" $DST_DIR
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-07-03 06:03:13 -05:00
|
|
|
changed_tests=""
|
2019-11-28 03:20:40 -06:00
|
|
|
|
|
|
|
# Read failed tests
|
2021-08-18 06:46:17 -05:00
|
|
|
FAILED_TESTS=`cat $BUILD_DIR/Testing/Temporary/LastTestsFailed*.log`
|
2019-11-28 03:20:40 -06:00
|
|
|
|
2019-12-20 05:32:26 -06:00
|
|
|
test -z "$FAILED_TESTS" && exit 5
|
|
|
|
|
2019-11-28 03:20:40 -06:00
|
|
|
for failed_test in $FAILED_TESTS
|
2018-07-03 06:03:13 -05:00
|
|
|
do
|
2024-07-03 05:22:25 -05:00
|
|
|
grep -q -E "compareECLFiles|compareDamarisFiles" <<< $failed_test
|
2023-05-31 05:06:37 -05:00
|
|
|
test $? -ne 0 && continue
|
|
|
|
failed_test=`echo $failed_test | sed -e 's/.*://g' -e 's/\+/./g'`
|
|
|
|
# Extract test properties
|
|
|
|
dir=`dirname "$0"`
|
2023-11-03 04:47:55 -05:00
|
|
|
binary=$(awk -v search="set_tests_properties\\\($failed_test\$" -v prop="SIMULATOR" -f $dir/getprop.awk $BUILD_DIR/CTestTestfile.cmake)
|
|
|
|
dir_name=$(awk -v search="set_tests_properties\\\($failed_test\$" -v prop="DIRNAME" -f $dir/getprop.awk $BUILD_DIR/CTestTestfile.cmake)
|
|
|
|
file_name=$(awk -v search="set_tests_properties\\\($failed_test\$" -v prop="FILENAME" -f $dir/getprop.awk $BUILD_DIR/CTestTestfile.cmake)
|
|
|
|
test_name=$(awk -v search="set_tests_properties\\\($failed_test\$" -v prop="TESTNAME" -f $dir/getprop.awk $BUILD_DIR/CTestTestfile.cmake)
|
|
|
|
echo "$failed_test ${binary} ${dirname} ${file_name} ${test_name}"
|
2024-07-03 05:22:25 -05:00
|
|
|
if grep -q compareECLFiles <<< $failed_test
|
2023-05-31 05:06:37 -05:00
|
|
|
then
|
2024-07-03 05:22:25 -05:00
|
|
|
copyToReferenceDir \
|
|
|
|
$BUILD_DIR/tests/results/$binary+$test_name \
|
|
|
|
$OPM_TESTS_ROOT/$dir_name/opm-simulation-reference/$binary \
|
|
|
|
$file_name \
|
|
|
|
EGRID INIT RFT SMSPEC UNRST UNSMRY
|
|
|
|
test $? -eq 0 && changed_tests="$changed_tests $test_name"
|
|
|
|
|
|
|
|
if [ -d $configuration/build-opm-simulators/tests/results/$binary+$test_name/restart ]
|
|
|
|
then
|
2021-12-05 05:09:19 -06:00
|
|
|
|
2024-07-03 05:22:25 -05:00
|
|
|
RSTEPS=`ls -1 $BUILD_DIR/tests/results/$binary+$test_name/restart/*.UNRST | sed -e 's/.*RESTART_*//' | sed 's/[.].*//' `
|
|
|
|
result=0
|
|
|
|
for RSTEP in $RSTEPS
|
|
|
|
do
|
|
|
|
copyToReferenceDir \
|
|
|
|
$BUILD_DIR/tests/results/$binary+$test_name/restart/ \
|
|
|
|
$OPM_TESTS_ROOT/$dir_name/opm-simulation-reference/$binary/restart \
|
|
|
|
${file_name}_RESTART_${RSTEP} \
|
|
|
|
EGRID INIT RFT SMSPEC UNRST UNSMRY
|
|
|
|
res=$?
|
|
|
|
test $result -eq 0 || result=$res
|
|
|
|
done
|
|
|
|
test $result -eq 0 && changed_tests="$changed_tests $test_name(restart)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
copyDamarisToReferenceDir \
|
|
|
|
$BUILD_DIR/tests/results/$binary+$test_name \
|
|
|
|
$OPM_TESTS_ROOT/$dir_name/opm-simulation-reference/$binary \
|
|
|
|
$file_name
|
|
|
|
changed_tests="$changed_tests $test_name"
|
2023-05-31 05:06:37 -05:00
|
|
|
fi
|
2018-07-03 06:03:13 -05:00
|
|
|
done
|
2017-01-16 01:06:26 -06:00
|
|
|
|
2018-07-03 06:03:13 -05:00
|
|
|
# special tests
|
|
|
|
copyToReferenceDir \
|
2021-08-18 06:46:17 -05:00
|
|
|
$BUILD_DIR/tests/results/init/flow+norne \
|
2018-04-09 03:40:34 -05:00
|
|
|
$OPM_TESTS_ROOT/norne/opm-simulation-reference/flow \
|
2017-04-10 15:31:46 -05:00
|
|
|
NORNE_ATW2013 \
|
|
|
|
EGRID INIT
|
2018-07-03 06:03:13 -05:00
|
|
|
test $? -eq 0 && changed_tests="$changed_tests norne_init"
|
2017-04-10 15:31:46 -05:00
|
|
|
|
2018-07-03 06:03:13 -05:00
|
|
|
changed_tests=`echo $changed_tests | xargs`
|
2021-08-18 06:46:17 -05:00
|
|
|
echo -e "Automatic Reference Data Update for ${REASON:-(Unknown)}\n" > /tmp/cmsg
|
2017-01-26 03:52:49 -06:00
|
|
|
if [ -z "$REASON" ]
|
|
|
|
then
|
|
|
|
echo -e "Reason: fill in this\n" >> /tmp/cmsg
|
|
|
|
else
|
|
|
|
echo -e "Reason: $REASON\n" >> /tmp/cmsg
|
|
|
|
fi
|
2021-08-18 06:46:17 -05:00
|
|
|
if [ -n "$CONVERT_ECL" ]
|
|
|
|
then
|
2024-10-02 03:47:54 -05:00
|
|
|
for dep in opm-common opm-grid
|
2021-08-18 06:46:17 -05:00
|
|
|
do
|
|
|
|
pushd $WORKSPACE/deps/$dep > /dev/null
|
|
|
|
name=`printf "%-14s" $dep`
|
|
|
|
rev=`git rev-parse HEAD`
|
|
|
|
echo -e "$name = $rev" >> /tmp/cmsg
|
|
|
|
popd > /dev/null
|
|
|
|
done
|
|
|
|
echo -e "opm-simulators = `git rev-parse HEAD`" >> /tmp/cmsg
|
|
|
|
fi
|
2017-01-16 01:06:26 -06:00
|
|
|
|
2020-06-13 05:14:36 -05:00
|
|
|
echo -e "\n### Changed Tests ###\n" >> /tmp/cmsg
|
|
|
|
for t in ${changed_tests}
|
|
|
|
do
|
|
|
|
echo " * ${t}" >> /tmp/cmsg
|
|
|
|
done
|
|
|
|
|
2018-04-09 03:40:34 -05:00
|
|
|
cd $OPM_TESTS_ROOT
|
2017-01-26 03:52:49 -06:00
|
|
|
if [ -n "$BRANCH_NAME" ]
|
|
|
|
then
|
2021-11-12 04:41:47 -06:00
|
|
|
git checkout -b $BRANCH_NAME $BRANCH_BASE
|
2017-01-26 03:52:49 -06:00
|
|
|
fi
|
|
|
|
|
2017-11-10 08:06:47 -06:00
|
|
|
# Add potential new files
|
2022-02-02 07:54:51 -06:00
|
|
|
untracked=`git status --porcelain | awk '$1~/\?/{print $2}'`
|
2017-11-10 08:06:47 -06:00
|
|
|
if [ -n "$untracked" ]
|
|
|
|
then
|
|
|
|
git add $untracked
|
|
|
|
fi
|
|
|
|
|
2017-01-26 03:52:49 -06:00
|
|
|
if [ -z "$REASON" ]
|
|
|
|
then
|
|
|
|
git commit -a -t /tmp/cmsg
|
|
|
|
else
|
|
|
|
git commit -a -F /tmp/cmsg
|
|
|
|
fi
|
2019-11-27 02:00:22 -06:00
|
|
|
|
|
|
|
rm -rf $TMPDIR
|