1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# 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.
#
. ./include.ctest.sh
if [ $HAVE_GEOGRAPHY -eq 0 ]; then
exit 0
fi
label="grib_iterator_fail_test"
tempText=temp.$label.txt
tempGrib=temp.$label.grib
# Badly encoded Gaussian sub area
# --------------------------------
tempFilt=temp.${label}.filt
cat > $tempFilt <<EOF
meta pl1 element(pl, 1);
set pl1 = 0;
write;
EOF
input=$data_dir/reduced_gaussian_sub_area.grib2
${tools_dir}/grib_filter -o $tempGrib $tempFilt $input
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid pl array" $tempText
rm -f $tempFilt
# ECC-1642: badly encoded regular grids
# -------------------------------------
${tools_dir}/grib_set -s Ni=33 $samp_dir/GRIB2.tmpl $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Grid description is wrong or inconsistent" $tempText
# Bad Ni
${tools_dir}/grib_set -s Ni=MISSING $samp_dir/GRIB2.tmpl $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Grid description is wrong or inconsistent" $tempText
set +e
${tools_dir}/grib_ls -s Ni=missing -j -p latLonValues $data_dir/sample.grib2 > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
cat $tempText
grep -q "Key Ni cannot be 'missing' for a regular grid" $tempText
grep -q "latlonvalues: Unable to create iterator" $tempText
# ------------------------
# non-existing key
# ------------------------
input=$data_dir/sample.grib2
${tools_dir}/grib_get_data -f -p nonexistingkey $input > $tempText
grep -q "not found" $tempText
# ------------------------
# Bad options
# ------------------------
input=$data_dir/sample.grib2
set +e
${tools_dir}/grib_get_data -Lxxx $input > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid lats/lons format option" $tempText
# ------------------------
# Unreadable message
# ------------------------
echo GRIB > $tempGrib
set +e
${tools_dir}/grib_get_data $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
cat $tempText
grep -q "unreadable message" $tempText
# Bad -s
set +e
${tools_dir}/grib_get_data -s blah=999 $data_dir/sample.grib2 > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Key/value not found" $tempText
# Bad -p
set +e
${tools_dir}/grib_get_data -f -p values $data_dir/sample.grib2 > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Passed array is too small" $tempText
# Clean up
rm -f $tempText $tempGrib
|