From 11e66959476175a329e24a83490a6f807221c8ea Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 22 Jan 2024 18:12:07 -0500 Subject: [PATCH] Added a macro that will elide the CRC value for tests (#237) Added a macro that will elide the CRC value for tests This will enable 'universal' tests in more cases, freeing us from maintaining two sets of baselines (one each for big- and little-endian machines). --- tests/DMRTest.at | 57 ++++++++++++++++++- ... => test_simple_8.xml.1.trans_base-unused} | 0 ... => test_simple_8.xml.2.trans_base-unused} | 0 ... => test_simple_8.xml.1.trans_base-unused} | 0 ... => test_simple_8.xml.2.trans_base-unused} | 0 .../universal/test_simple_8.xml.1.trans_base | 26 +++++++++ .../universal/test_simple_8.xml.2.trans_base | 25 ++++++++ 7 files changed, 105 insertions(+), 3 deletions(-) rename tests/dmr-testsuite/big-endian/{test_simple_8.xml.1.trans_base => test_simple_8.xml.1.trans_base-unused} (100%) rename tests/dmr-testsuite/big-endian/{test_simple_8.xml.2.trans_base => test_simple_8.xml.2.trans_base-unused} (100%) rename tests/dmr-testsuite/little-endian/{test_simple_8.xml.1.trans_base => test_simple_8.xml.1.trans_base-unused} (100%) rename tests/dmr-testsuite/little-endian/{test_simple_8.xml.2.trans_base => test_simple_8.xml.2.trans_base-unused} (100%) create mode 100644 tests/dmr-testsuite/universal/test_simple_8.xml.1.trans_base create mode 100644 tests/dmr-testsuite/universal/test_simple_8.xml.2.trans_base diff --git a/tests/DMRTest.at b/tests/DMRTest.at index 3046e9f21..180043768 100644 --- a/tests/DMRTest.at +++ b/tests/DMRTest.at @@ -162,6 +162,54 @@ m4_define([DMR_TRANS_CE], [ AT_CLEANUP ]) +dnl Given a filename, remove the element of a DAP4 data response as +dnl printed by getdap4 so that we dont have issues with comparing data values +dnl on big- and little-endian machines. The value of the checksum is a function +dnl of the bytes, so different word orders produce different checksums. jhrg 4/25/18 +dnl +dnl Ripped from the BES modules/common/handler_tests_macros.m4 file. jhrg 1/22/24 + +m4_define([REMOVE_DAP4_CHECKSUM], [dnl + sed 's@[[0-9a-f]]\{8\}@removed checksum@g' < $1 > $1.sed + dnl ' + mv $1.sed $1 +]) + + +# Usage DMR_TRANS_C_NO_CRC +# This code tests the values printed when the received document is decoded. +# It is different from DMR_TRANS_CE in that it does not include the CRC32 +# checksum so that the test will work for both little- and big-endian machines. +# jhrg 1/22/24 +m4_define([DMR_TRANS_CE_NO_CRC], [ + # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it) + # after applying a constraint expression to the source DMR. + AT_SETUP([trans ce no CRC $1 $2 $3]) + AT_KEYWORDS([trans_ce]) + + input=$abs_srcdir/dmr-testsuite/$1 + baseline=$abs_srcdir/dmr-testsuite/universal/$3 + + AS_IF([test -n "$baselines" -a x$baselines = xyes], + [ + # // old version - sbl 9.4.19 + # AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2"], [], [stdout], []) old version + + AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2"], [ignore], [stdout], [stderr]) + REMOVE_DAP4_CHECKSUM([stdout]) + AT_CHECK([cat stdout stderr > $baseline.tmp]) + ], + [ + AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2" || true], [], [stdout], [stderr]) + REMOVE_DAP4_CHECKSUM([stdout]) + AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[]) + AT_XFAIL_IF([test "X$4" = "Xxfail"]) + ]) + + AT_CLEANUP +]) + + # Usage DMR_TRANS_FUNC_CE # This code tests the values printed when the received document is decoded. m4_define([DMR_TRANS_FUNC_CE], [ @@ -462,9 +510,12 @@ DMR_TRANS_CE([test_simple_7.xml], [s{i1;s}], [test_simple_7.xml.1.trans_base], [ DMR_TRANS_CE([test_simple_7.xml], [s.i1], [test_simple_7.xml.2.trans_base], [pass]) DMR_TRANS_CE([test_simple_7.xml], [s{i1}], [test_simple_7.xml.2.trans_base], [pass]) -DMR_TRANS_CE([test_simple_8.xml], [outer], [test_simple_8.xml.1.trans_base], [pass]) -DMR_TRANS_CE([test_simple_8.xml], [outer.s.s], [test_simple_8.xml.2.trans_base], [pass]) -DMR_TRANS_CE([test_simple_8.xml], [outer{s{s}}], [test_simple_8.xml.2.trans_base], [pass]) +# Modified to use elided CRC - we have tested the CRC elsewhere and in the BES +# we remove the CRC from both the output and the baselines to avoid making baselines +# for both big- and little-endian machines. jhrg 1/22/24 +DMR_TRANS_CE_NO_CRC([test_simple_8.xml], [outer], [test_simple_8.xml.1.trans_base], [pass]) +DMR_TRANS_CE_NO_CRC([test_simple_8.xml], [outer.s.s], [test_simple_8.xml.2.trans_base], [pass]) +DMR_TRANS_CE_NO_CRC([test_simple_8.xml], [outer{s{s}}], [test_simple_8.xml.2.trans_base], [pass]) DMR_TRANS_CE([test_array_7.xml], [s], [test_array_7.xml.1.trans_base], [pass]) DMR_TRANS_CE([test_array_7.xml], [s{i1;s}], [test_array_7.xml.1.trans_base], [pass]) diff --git a/tests/dmr-testsuite/big-endian/test_simple_8.xml.1.trans_base b/tests/dmr-testsuite/big-endian/test_simple_8.xml.1.trans_base-unused similarity index 100% rename from tests/dmr-testsuite/big-endian/test_simple_8.xml.1.trans_base rename to tests/dmr-testsuite/big-endian/test_simple_8.xml.1.trans_base-unused diff --git a/tests/dmr-testsuite/big-endian/test_simple_8.xml.2.trans_base b/tests/dmr-testsuite/big-endian/test_simple_8.xml.2.trans_base-unused similarity index 100% rename from tests/dmr-testsuite/big-endian/test_simple_8.xml.2.trans_base rename to tests/dmr-testsuite/big-endian/test_simple_8.xml.2.trans_base-unused diff --git a/tests/dmr-testsuite/little-endian/test_simple_8.xml.1.trans_base b/tests/dmr-testsuite/little-endian/test_simple_8.xml.1.trans_base-unused similarity index 100% rename from tests/dmr-testsuite/little-endian/test_simple_8.xml.1.trans_base rename to tests/dmr-testsuite/little-endian/test_simple_8.xml.1.trans_base-unused diff --git a/tests/dmr-testsuite/little-endian/test_simple_8.xml.2.trans_base b/tests/dmr-testsuite/little-endian/test_simple_8.xml.2.trans_base-unused similarity index 100% rename from tests/dmr-testsuite/little-endian/test_simple_8.xml.2.trans_base rename to tests/dmr-testsuite/little-endian/test_simple_8.xml.2.trans_base-unused diff --git a/tests/dmr-testsuite/universal/test_simple_8.xml.1.trans_base b/tests/dmr-testsuite/universal/test_simple_8.xml.1.trans_base new file mode 100644 index 000000000..d93629778 --- /dev/null +++ b/tests/dmr-testsuite/universal/test_simple_8.xml.1.trans_base @@ -0,0 +1,26 @@ +Parse successful + + + + + + + + + + + + + + + + + + + removed checksum + + + + +The data: +{ { { { 123456789, "Silly test string: 1" }, { 123456789, "Silly test string: 1" }, { 123456789, "Silly test string: 1" }, { 123456789, "Silly test string: 1" } } } } diff --git a/tests/dmr-testsuite/universal/test_simple_8.xml.2.trans_base b/tests/dmr-testsuite/universal/test_simple_8.xml.2.trans_base new file mode 100644 index 000000000..48c7934c5 --- /dev/null +++ b/tests/dmr-testsuite/universal/test_simple_8.xml.2.trans_base @@ -0,0 +1,25 @@ +Parse successful + + + + + + + + + + + + + + + + + + removed checksum + + + + +The data: +{ { { { "Silly test string: 1" }, { "Silly test string: 1" }, { "Silly test string: 1" }, { "Silly test string: 1" } } } }