From 4ac57746267aa27aaa9efd52c8274c7eb61f7f6d Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 3 Jan 2024 16:31:07 +0000 Subject: [PATCH] Testing: Error conditions --- tests/grib_get_fail.sh | 30 ++++++++++++++++++++++++++++++ tests/grib_ls.sh | 10 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/tests/grib_get_fail.sh b/tests/grib_get_fail.sh index f4a6102e3..d7d0d5b1b 100755 --- a/tests/grib_get_fail.sh +++ b/tests/grib_get_fail.sh @@ -50,6 +50,36 @@ set -e grep -q "Key Nj cannot be 0" $tempText +set +e +${tools_dir}/grib_get -l 0,0,5 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong mode given" $tempText + + +set +e +${tools_dir}/grib_get -l 0,0,1,nonexistingmask $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +cat $tempText +grep -q "unable to open mask file" $tempText + + +# ------------------------ +# Unreadable message +# ------------------------ +outfile=temp.$label.out +echo GRIB > $outfile +set +e +${tools_dir}/grib_get -p edition $outfile /dev/null > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "unreadable message" $tempText +rm -f $outfile + # Clean up rm -f $tempText diff --git a/tests/grib_ls.sh b/tests/grib_ls.sh index 2a6f6c5ab..1101d4d52 100755 --- a/tests/grib_ls.sh +++ b/tests/grib_ls.sh @@ -225,6 +225,8 @@ grib_check_key_equals $file 'expver:s' '0001' ${tools_dir}/grib_ls -j -l0,0 -p referenceValue:d $data_dir/sample.grib2 ${tools_dir}/grib_ls -j -l0,0 -p referenceValue:i $data_dir/sample.grib2 +${tools_dir}/grib_get -l0,0,4 $data_dir/sample.grib2 + set +e ${tools_dir}/grib_ls -l0,0,666 $data_dir/sample.grib2 > $tempText 2>&1 status=$? @@ -233,5 +235,13 @@ set -e grep -q "Wrong mode given" $tempText +set +e +${tools_dir}/grib_ls -l0,0,1,nonexistingmask $data_dir/sample.grib2 > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "unable to open mask file" $tempText + + # Clean up rm -f $temp1 $temp2 $tempText $tempLog