From 5b06296dcebd4fc705abe739f1e600cb18b7164c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 24 Aug 2023 17:59:02 +0100 Subject: [PATCH] Testing: Increase coverage --- tests/grib_ls.sh | 12 ++++++++++++ tests/grib_set.sh | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/tests/grib_ls.sh b/tests/grib_ls.sh index 7d884608c..3329ae48c 100755 --- a/tests/grib_ls.sh +++ b/tests/grib_ls.sh @@ -40,6 +40,7 @@ ${tools_dir}/grib_ls -l 0,0,1 $infile >> $tempLog ${tools_dir}/grib_get -l 0,0,1 $infile >> $tempLog ${tools_dir}/grib_get -p count,step $infile >> $tempLog ${tools_dir}/grib_get -P count $infile >> $tempLog +${tools_dir}/grib_get -i 0 $infile files=" reduced_gaussian_lsm.grib1 reduced_gaussian_model_level.grib1 @@ -207,5 +208,16 @@ grib_check_key_equals $file 'expver:d' 1 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 + +set +e +${tools_dir}/grib_ls -l0,0,666 $data_dir/sample.grib2 > $tempText 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Wrong mode given" $tempText + + # Clean up rm -f $temp1 $temp2 $tempText $tempLog diff --git a/tests/grib_set.sh b/tests/grib_set.sh index 45ddc4fb0..8e448c8d9 100755 --- a/tests/grib_set.sh +++ b/tests/grib_set.sh @@ -18,6 +18,8 @@ temp=temp.grib_set.out rm -f $outfile +${tools_dir}/grib_set -V + ${tools_dir}/grib_set -v -p levtype,centre,levtype,centre:l -s levtype=pl,centre=80 $infile $outfile >$REDIRECT levtype=`${tools_dir}/grib_get -p levtype $outfile` @@ -85,6 +87,17 @@ set -e [ $status -ne 0 ] grep -q "Trying to encode a negative value of -1 for key of type unsigned" $temp +# Bad value for -d +# ---------------- +input=${data_dir}/reduced_gaussian_sub_area.grib2 +set +e +${tools_dir}/grib_set -d hello $input $outfile 2>$temp +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid number" $temp + + # ECC-1605: Out-of-bounds value for signed keys # ---------------------------------------------------- if [ $ECCODES_ON_WINDOWS -eq 0 ]; then @@ -196,5 +209,17 @@ count=`${tools_dir}/grib_count $outfile` grib_check_key_equals $outfile shortName '2t' +# ------------------------ +# Unreadable message +# ------------------------ +echo GRIB > $outfile +set +e +${tools_dir}/grib_set -s edition=2 $outfile /dev/null > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "unreadable message" $temp + + # Clean up rm -f $outfile $temp