Testing: Increase coverage

This commit is contained in:
Shahram Najm 2023-08-23 14:17:27 +01:00
parent aca7a5ddb1
commit 2cfe640f1c
5 changed files with 57 additions and 19 deletions

View File

@ -10,37 +10,33 @@
. ./include.ctest.sh . ./include.ctest.sh
# Define a common label for all the tmp files
#Define a common label for all the tmp files
label="bufr_set_keys_test_c" label="bufr_set_keys_test_c"
REDIRECT=/dev/null
#Define tmp file
fBufrTmp=${label}.tmp.bufr fBufrTmp=${label}.tmp.bufr
rm -f $fBufrTmp rm -f $fBufrTmp
#We check "syno_multi.bufr". The path is # We check "syno_multi.bufr". The path is hard coded in the example
#hardcoded in the example
f=${data_dir}/bufr/syno_multi.bufr f=${data_dir}/bufr/syno_multi.bufr
REDIRECT=/dev/null set +e
${examples_dir}/c_bufr_set_keys
status=$?
set -e
[ $status -ne 0 ]
# # Run
${examples_dir}/c_bufr_set_keys $fBufrTmp 2> $REDIRECT > $REDIRECT ${examples_dir}/c_bufr_set_keys $fBufrTmp 2> $REDIRECT > $REDIRECT
#Compare modified to the original # Compare modified to the original
set +e set +e
${tools_dir}/bufr_compare $f $fBufrTmp >$REDIRECT 2> $REDIRECT ${tools_dir}/bufr_compare $f $fBufrTmp >$REDIRECT 2> $REDIRECT
status=$?
#Check if modified is different
if [ $? -eq 0 ]; then
echo "setting keys produced identical files " >&2
exit 1
fi
set -e set -e
[ $status -ne 0 ]
#Check if modified has the same number of messages # Check if modified has the same number of messages
[ `${tools_dir}/bufr_count $f` -eq `${tools_dir}/bufr_count ${fBufrTmp}` ] [ `${tools_dir}/bufr_count $f` -eq `${tools_dir}/bufr_count ${fBufrTmp}` ]
#Clean up # Clean up
rm -f $fBufrTmp rm -f $fBufrTmp

View File

@ -15,6 +15,12 @@ fTmp=${label}.tmp
fOut=${label}.tmp.out fOut=${label}.tmp.out
fRef=${label}.tmp.ref fRef=${label}.tmp.ref
set +e
${examples_dir}/c_get_product_kind
status=$?
set -e
[ $status -eq 1 ]
# Create a file containing one GRIB and three BUFR messages # Create a file containing one GRIB and three BUFR messages
cat ${data_dir}/sample.grib2 ${data_dir}/bufr/syno_multi.bufr >$fTmp cat ${data_dir}/sample.grib2 ${data_dir}/bufr/syno_multi.bufr >$fTmp

View File

@ -15,6 +15,12 @@ temp1=$label.temp1.$$
temp2=$label.temp2.$$ temp2=$label.temp2.$$
tempRef=$label.ref.$$ tempRef=$label.ref.$$
set +e
${examples_dir}/c_grib_nearest_multiple 2>/dev/null
status=$?
set -e
[ $status -eq 1 ]
cat > $temp1 <<EOF cat > $temp1 <<EOF
1 30 -20 1 30 -20
2 13 234 2 13 234

View File

@ -308,6 +308,29 @@ ${tools_dir}/grib_filter $tempFilt $input
cd .. cd ..
rm -rf $tempDir rm -rf $tempDir
# Use of 'defined' functor
cat >$tempFilt <<EOF
if (defined(Ni)) { print "Ni defined: true"; }
else { print "Ni defined: false"; }
EOF
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut
grep -q "Ni defined: true" $tempOut
cat >$tempFilt <<EOF
if (defined(N)) { print "N defined: true"; }
else { print "N defined: false"; }
EOF
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut
grep -q "N defined: false" $tempOut
cat >$tempFilt <<EOF
if (defined()) { print "No args: true"; }
else { print "No args: false"; }
EOF
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempOut
grep -q "No args: false" $tempOut
# Clean up # Clean up
rm -f $tempGrib $tempFilt $tempOut $tempRef rm -f $tempGrib $tempFilt $tempOut $tempRef

View File

@ -155,7 +155,14 @@ ${tools_dir}/grib_set -s julianDay=2454504 $input $temp
grib_check_key_equals $input day 6 grib_check_key_equals $input day 6
grib_check_key_equals $temp day 7 grib_check_key_equals $temp day 7
# Seconds (ignored)
# -----------------------------------------------
grib2_sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_ls -s second=9 -n time $grib2_sample 2>$templog
# Something should have been written to stderr
[ -s $templog ]
grep -q "Truncating time: non-zero seconds.* ignored" $templog
# Clean up # Clean up
rm -f $temp rm -f $temp $templog
rm -f $grib2File.p8tmp ${grib2File}.tmp x.grib rm -f $grib2File.p8tmp ${grib2File}.tmp x.grib