Commit bc6e999b authored by Matthias Rüster's avatar Matthias Rüster
Browse files

Tests: Use GDAL for comparing the results

parent c5532a76
Pipeline #20783 passed with stages
in 3 minutes and 43 seconds
......@@ -18,8 +18,8 @@ verify_build_cpu:
stage: build
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y build-essential autoconf
- DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential autoconf
script:
- *compile_easywave
......@@ -28,8 +28,8 @@ verify_build_gpu:
stage: build
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y build-essential autoconf
- DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential autoconf
script:
- *compile_easywave
......@@ -38,8 +38,8 @@ run_tests:
stage: test
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y python3 build-essential autoconf
- DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y python3 build-essential autoconf gdal-bin
script:
- *compile_easywave
- cd "${TESTS_DIR}"
......
#!/bin/bash
set -e
if [ "$#" -ne "2" ]; then
echo "Need two files as argument to compare them"
exit 1
fi
EXPECTED="$1"
COMPUTED="$2"
CONV_EXPECTED="$(mktemp /tmp/converted_XXXXXXXXXX.tif)"
CONV_COMPUTED="$(mktemp /tmp/converted_XXXXXXXXXX.tif)"
CUT_COMPUTED="$(mktemp /tmp/cut_XXXXXXXXXX.tif)"
DIFF="/tmp/diff-${RANDOM}.tif"
trap "rm -f ${CONV_EXPECTED} ${CONV_COMPUTED} ${CUT_COMPUTED} ${DIFF}" EXIT
gdal_translate -of gtiff "${EXPECTED}" "${CONV_EXPECTED}"
gdal_translate -of gtiff "${COMPUTED}" "${CONV_COMPUTED}"
UPPERLEFT="$(gdalinfo ${CONV_EXPECTED} | grep -F 'Upper Left' | sed -e 's@.*(@@' -e 's@)@@' -e 's@,@ @')"
LOWERRIGHT="$(gdalinfo ${CONV_EXPECTED} | grep -F 'Lower Right' | sed -e 's@.*(@@' -e 's@)@@' -e 's@,@ @')"
# resize computed output to fit with expected raster file
gdal_translate -projwin $UPPERLEFT $LOWERRIGHT -of gtiff "${CONV_COMPUTED}" "${CUT_COMPUTED}"
# calculate difference between rasters
gdal_calc.py -A "${CONV_EXPECTED}" -B "${CUT_COMPUTED}" --calc="abs(A-B)" --format=gtiff --outfile="${DIFF}"
MAX_DIFF="$(gdalinfo -stats ${DIFF} | grep STATISTICS_MAXIMUM | sed -e 's@.*STATISTICS_MAXIMUM=@@')"
echo "Max difference: ${MAX_DIFF}"
......@@ -61,7 +61,7 @@ def compareResults(expected, computed):
for i in range(0, 2):
files.append(glob.glob(path[i] + '/*.ssh'))
files[i] += glob.glob(path[i] + '/*.sshmax')
files[i] += glob.glob(path[i] + '/*.time')
# files[i] += glob.glob(path[i] + '/*.time')
for f in files[0]:
# go through expected files
......@@ -72,10 +72,10 @@ def compareResults(expected, computed):
# we found the expected file in the computed results
files[1].remove(fnext)
print('Comparing ' + '%s with %s' % (f, fnext))
print('Comparing %s with %s' % (f, fnext))
compare = subprocess.Popen(
sdir + '/compare.py %s %s' % (f, fnext),
sdir + '/compare_gdal.sh %s %s' % (f, fnext),
shell=True,
stdout=subprocess.PIPE
)
......@@ -90,7 +90,7 @@ def compareResults(expected, computed):
)
if match is None:
print('Output of compare.py was not as expected.')
print('Output of compare_gdal.sh was not as expected.')
success = False
continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment