From 92df819d3e18569f10d4637e179cce7a8205aeac Mon Sep 17 00:00:00 2001 From: Sandor Kertesz Date: Wed, 4 Feb 2015 13:52:37 +0000 Subject: [PATCH] Add bufr_compare test ECC-24 --- tests/bufr_compare.sh | 42 ++++++++++++++++------------------------ tests/bufr_get.sh | 1 + tests/bufr_set.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/tests/bufr_compare.sh b/tests/bufr_compare.sh index 3a0671669..d8700bc1a 100755 --- a/tests/bufr_compare.sh +++ b/tests/bufr_compare.sh @@ -41,20 +41,18 @@ ${tools_dir}/bufr_compare $f $f >> $fLog # Test: comparing two completely different files #---------------------------------------------------- -#TODO: enable this test when ECC-42 is fixed - set +e f1="syno_1.bufr" f2="aaen_55.bufr" echo "Test: comparing two completely different files" >> $fLog echo "file: $f" >> $fLog -#${tools_dir}/bufr_compare $f1 $f2 >> $fLog +${tools_dir}/bufr_compare $f1 $f2 >> $fLog -#if [ $? -eq 0 ]; then -# echo "bufr_compare should have failed if files are completely different" >&2 -# exit 1 -#fi +if [ $? -eq 0 ]; then + echo "bufr_compare should have failed if files are completely different" >&2 + exit 1 +fi set -e @@ -62,47 +60,41 @@ set -e # Test: comparing with and witout the -b switch #---------------------------------------------------- -#TODO: enable this test when ECC-42 is fixed - f="syno_1.bufr" echo "Test: comparing with and witout the -b switch" >> $fLog echo "file: $f" >> $fLog #Alter a key in the file -${tools_dir}/bufr_set -s centre=222 $f ${fBufrTmp} >> $fLog - -#TODO: enable this test when ECC-42 is fixed +${tools_dir}/bufr_set -s dataCategory=2 $f ${fBufrTmp} >> $fLog set +e -#${tools_dir}/bufr_compare $f ${fBufrTmp}>> $fLog +${tools_dir}/bufr_compare $f ${fBufrTmp}>> $fLog -#if [ $? -eq 0 ]; then -# echo "bufr_compare should have failed if files are different" >&2 -# exit 1 -#fi +if [ $? -eq 0 ]; then + echo "bufr_compare should have failed if files are different" >&2 + exit 1 +fi set -e #Now compare with -b switch. No difference should be found. -${tools_dir}/bufr_compare -b centre $f ${fBufrTmp}>> $fLog +${tools_dir}/bufr_compare -b dataCategory $f ${fBufrTmp}>> $fLog #---------------------------------------------------- # Test: comparing with the -r switch #---------------------------------------------------- -#TODO: enable this test when ECC-42 is fixed - #Create a bufr file with various message types cat syno_multi.bufr temp_101.bufr > $fBufrInput1 cat temp_101.bufr syno_multi.bufr > $fBufrInput2 set +e -#${tools_dir}/bufr_compare {fBufrInput1} ${fBufrInput2} >> $fLog +${tools_dir}/bufr_compare ${fBufrInput1} ${fBufrInput2} >> $fLog -#if [ $? -eq 0 ]; then -# echo "bufr_compare should have failed if the message order in the files is different" >&2 -# exit 1 -#fi +if [ $? -eq 0 ]; then + echo "bufr_compare should have failed if the message order in the files is different" >&2 + exit 1 +fi ${tools_dir}/bufr_compare -r ${fBufrInput1} ${fBufrInput2}>> $fLog diff --git a/tests/bufr_get.sh b/tests/bufr_get.sh index 1926ca9f8..67aeeb873 100755 --- a/tests/bufr_get.sh +++ b/tests/bufr_get.sh @@ -48,6 +48,7 @@ ${tools_dir}/bufr_get -p totalLength,centre,subCentre,masterTableNumber,masterTa cat $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_get diff $ref_get $res_get >$REDIRECT 2> $REDIRECT +#Clean up rm -f $fLog rm -f $fTmp | true rm -f $res_get | true diff --git a/tests/bufr_set.sh b/tests/bufr_set.sh index 7898fd629..e5ce66a6f 100755 --- a/tests/bufr_set.sh +++ b/tests/bufr_set.sh @@ -92,6 +92,51 @@ echo "file: $f" >> $fLog # [ $centre = "234.5" ] #done +#----------------------------------------------------------- +# Test: with nonexistent keys. +#----------------------------------------------------------- + +#Key "center" does not exist!! + +# Invoke without -f i.e. should fail if error encountered +set +e + +f="syno_1.bufr" +echo "Test: nonexistent keys" >> $fLog +echo "file: $f" >> $fLog +${tools_dir}/bufr_set -s center=98 $f $fBufrTmp 2>> $fLog 1>> $fLog +if [ $? -eq 0 ]; then + echo "bufr_set should have failed if key not found" >&2 + exit 1 +fi +set -e + +# Now repeat with -f option (do not exit on error) +${tools_dir}/bufr_set -f -s center=98 $f $fBufrTmp 2>>$fLog 1>>$fLog + + +#----------------------------------------------------------- +# Test: with not allowed key values +#----------------------------------------------------------- + +#Here 1024 is out of range for centre (it is 8-bit only for edition=4 files) + +# Invoke without -f i.e. should fail if error encountered +set +e + +f="syno_1.bufr" +echo "Test: nonexistent keys" >> $fLog +echo "file: $f" >> $fLog +${tools_dir}/bufr_set -s centre=1024 $f $fBufrTmp 2>> $fLog 1>> $fLog +if [ $? -eq 0 ]; then + echo "bufr_set should have failed if key not found" >&2 + exit 1 +fi +set -e + +# Now repeat with -f option (do not exit on error) +${tools_dir}/bufr_set -f -s centre=1024 -f $f $fBufrTmp 2>>$fLog 1>>$fLog + #Clean up rm -f $fLog