2021-08-18 12:45:02 +02:00
|
|
|
top_srcdir=@abs_top_srcdir@
|
|
|
|
top_builddir=@abs_top_builddir@
|
2016-05-10 15:48:03 +02:00
|
|
|
PYTHON=@PYTHON@
|
2014-12-20 23:25:19 +01:00
|
|
|
# we need a different tmp for each script since make can run tests in parallel
|
2022-10-26 16:25:19 +02:00
|
|
|
tmp=$top_builddir/test/tmp-$$
|
2018-07-06 17:11:02 +02:00
|
|
|
test_images=$top_srcdir/test/test-suite/images
|
2019-11-27 09:58:30 +01:00
|
|
|
image=$test_images/sample.jpg
|
2014-11-19 18:32:29 +01:00
|
|
|
mkdir -p $tmp
|
2021-08-18 12:45:02 +02:00
|
|
|
vips=$top_builddir/tools/vips
|
|
|
|
vipsthumbnail=$top_builddir/tools/vipsthumbnail
|
|
|
|
vipsheader=$top_builddir/tools/vipsheader
|
2016-01-17 10:29:25 +01:00
|
|
|
|
|
|
|
# we need bc to use '.' for a decimal separator
|
|
|
|
export LC_NUMERIC=C
|
2019-10-06 11:55:19 +02:00
|
|
|
|
2021-05-09 16:49:44 +02:00
|
|
|
# raspbian sets this too, annoyingly
|
|
|
|
unset LC_ALL
|
|
|
|
|
2019-10-06 11:55:19 +02:00
|
|
|
# test for file format supported
|
|
|
|
test_supported() {
|
|
|
|
format=$1
|
|
|
|
|
|
|
|
if $vips $format > /dev/null 2>&1; then
|
|
|
|
result=0
|
|
|
|
else
|
|
|
|
echo "support for $format not configured, skipping test"
|
|
|
|
result=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
return $result
|
|
|
|
}
|
2019-11-24 19:22:43 +01:00
|
|
|
|
|
|
|
# is a difference beyond a threshold? return 0 (meaning all ok) or 1 (meaning
|
|
|
|
# error, or outside threshold)
|
skip some skippable tests (#3102)
* tests: consolidate redundant, duplicated helper code
These functions currently exist in a sourced shell library, but there is
an identical copy of them in a single test file. Get rid of this
duplicate definition.
* tests: mark some tests as skipped if bc is not installed
`exit 77` is the GNU exitcode protocol for tests that cannot be run
because their prerequisites are not available. If `bc` is not installed,
and it often isn't, the test can be short-circuited instead of failing;
meson will report them in "warning yellow".
* tests: mark some tests as skipped if support is not compiled
Not all test cases can be cleanly marked as skipped -- sometimes,
multiple things are checked, and having one be unavailable should not
mean skipping all tests.
But in a couple cases, a test file only tests one thing, and that may be
skipped. In such cases, it can be semantically indicated in the test
harness report collection, that a skip occurred.
2022-10-19 19:13:48 +02:00
|
|
|
#
|
|
|
|
# use bc since bash does not support fp math
|
2019-11-24 19:22:43 +01:00
|
|
|
break_threshold() {
|
|
|
|
diff=$1
|
|
|
|
threshold=$2
|
skip some skippable tests (#3102)
* tests: consolidate redundant, duplicated helper code
These functions currently exist in a sourced shell library, but there is
an identical copy of them in a single test file. Get rid of this
duplicate definition.
* tests: mark some tests as skipped if bc is not installed
`exit 77` is the GNU exitcode protocol for tests that cannot be run
because their prerequisites are not available. If `bc` is not installed,
and it often isn't, the test can be short-circuited instead of failing;
meson will report them in "warning yellow".
* tests: mark some tests as skipped if support is not compiled
Not all test cases can be cleanly marked as skipped -- sometimes,
multiple things are checked, and having one be unavailable should not
mean skipping all tests.
But in a couple cases, a test file only tests one thing, and that may be
skipped. In such cases, it can be semantically indicated in the test
harness report collection, that a skip occurred.
2022-10-19 19:13:48 +02:00
|
|
|
if ! command -v bc >/dev/null; then
|
|
|
|
exit 77
|
|
|
|
fi
|
2019-11-24 19:22:43 +01:00
|
|
|
return $(echo "$diff <= $threshold" | bc -l)
|
|
|
|
}
|
|
|
|
|
|
|
|
# subtract, look for max difference less than a threshold
|
|
|
|
test_difference() {
|
|
|
|
before=$1
|
|
|
|
after=$2
|
|
|
|
threshold=$3
|
|
|
|
|
|
|
|
$vips subtract $before $after $tmp/difference.v
|
|
|
|
$vips abs $tmp/difference.v $tmp/abs.v
|
|
|
|
dif=$($vips max $tmp/abs.v)
|
|
|
|
|
|
|
|
if break_threshold $dif $threshold; then
|
|
|
|
echo "save / load difference is $dif"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|