From ecf1f5ec8626a6d83675cf8a7ce7d3e62d2ac0a6 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sat, 20 Jan 2024 14:09:25 +0000 Subject: [PATCH] Tools: Increase coverage --- tests/grib_repair.sh | 36 +++++++++++++++++++++++------------- tests/gts_compare.sh | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/tests/grib_repair.sh b/tests/grib_repair.sh index 876ebdff0..3212861e4 100755 --- a/tests/grib_repair.sh +++ b/tests/grib_repair.sh @@ -15,20 +15,30 @@ tempText=temp.$label.txt tempGoodGribs=temp.$label.good.grib tempBadGribs=temp.$label.bad.grib -if [ -e "${tools_dir}/grib_repair" ]; then - export ECCODES_GRIB_REPAIR_MAX_NUM_MESSAGES=3 - ${tools_dir}/grib_repair $data_dir/bad.grib $tempGoodGribs $tempBadGribs > $tempText 2>&1 - grep -q "Wrong message length" $tempText - - count=$( ${tools_dir}/grib_count $tempGoodGribs ) - [ $count -eq 1 ] - - count=$( ${tools_dir}/grib_count $tempBadGribs ) - [ $count -eq 3 ] - - ${tools_dir}/grib_ls $tempGoodGribs - ${tools_dir}/grib_ls $tempBadGribs +if [ ! -e "${tools_dir}/grib_repair" ]; then + exit 0 fi +set +e +${tools_dir}/grib_repair +status=$? +set -e +[ $status -ne 0 ] + + +export ECCODES_GRIB_REPAIR_MAX_NUM_MESSAGES=3 +${tools_dir}/grib_repair $data_dir/bad.grib $tempGoodGribs $tempBadGribs > $tempText 2>&1 +grep -q "Wrong message length" $tempText + +count=$( ${tools_dir}/grib_count $tempGoodGribs ) +[ $count -eq 1 ] + +count=$( ${tools_dir}/grib_count $tempBadGribs ) +[ $count -eq 3 ] + +${tools_dir}/grib_ls $tempGoodGribs +${tools_dir}/grib_ls $tempBadGribs + + # Clean up rm -f $tempText $tempGoodGribs $tempBadGribs diff --git a/tests/gts_compare.sh b/tests/gts_compare.sh index 196fa2756..678d8b571 100755 --- a/tests/gts_compare.sh +++ b/tests/gts_compare.sh @@ -31,6 +31,12 @@ echo "Test: comparing the same files" >> $fLog echo "file: $gts_file" >> $fLog ${tools_dir}/gts_compare $gts_file $gts_file +#---------------------------------------------------- +# Test: comparing with skip +#---------------------------------------------------- +gts_file="EGRR20150317121020_00493212.DAT" +${tools_dir}/gts_compare -w TT=SA $gts_file $gts_file + #---------------------------------------------------- # Test: comparing two different files #---------------------------------------------------- @@ -99,6 +105,15 @@ cp $gts_file $tempDir ${tools_dir}/gts_compare $gts_file $tempDir rm -r $tempDir +# Options +set +e +${tools_dir}/gts_compare -a $gts_file $gts_file > $fLog 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "option requires" $fLog + + # Non-existence set +e ${tools_dir}/gts_compare non-exist1 non-exist2 > $fLog 2>&1