From 574bdc080ad82236325b3432392008702a09c3b2 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 7 Jan 2024 17:28:36 +0000 Subject: [PATCH] Testing: bufr_filter unreadable message --- tests/bufr_filter_fail.sh | 16 ++++++++++++++++ tests/grib_repair.sh | 21 ++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/tests/bufr_filter_fail.sh b/tests/bufr_filter_fail.sh index ed38ba64c..2ab8b3ef0 100755 --- a/tests/bufr_filter_fail.sh +++ b/tests/bufr_filter_fail.sh @@ -105,6 +105,22 @@ cat $tempErr grep -q "Input output problem" $tempErr +# ------------------------ +# Unreadable message +# ------------------------ +cat > $fRules < $outfile +set +e +${tools_dir}/bufr_filter $fRules $outfile > $tempErr 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "unreadable message" $tempErr +rm -f $outfile + # Clean up rm -f $fLog $fRules $tempErr diff --git a/tests/grib_repair.sh b/tests/grib_repair.sh index 430fa89cb..876ebdff0 100755 --- a/tests/grib_repair.sh +++ b/tests/grib_repair.sh @@ -3,7 +3,7 @@ # # This software is licensed under the terms of the Apache Licence Version 2.0 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# +# # In applying this licence, ECMWF does not waive the privileges and immunities granted to it by # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # @@ -12,16 +12,23 @@ label="grib_repair_test" tempText=temp.$label.txt -tempGrib=temp.$label.grib +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 $tempGrib > $tempText 2>&1 - cat $tempText - ${tools_dir}/grib_ls $tempGrib - + ${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 fi # Clean up -rm -f $tempText $tempGrib +rm -f $tempText $tempGoodGribs $tempBadGribs