diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8671f37eb..21e4eb5dc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -277,6 +277,7 @@ if( HAVE_BUILD_TOOLS ) grib_copy_message grib_decimalPrecision grib_bitsPerValue + grib_accessors grib_get_fail grib_missing grib_local diff --git a/tests/grib_accessors.sh b/tests/grib_accessors.sh new file mode 100755 index 000000000..0d10c7442 --- /dev/null +++ b/tests/grib_accessors.sh @@ -0,0 +1,57 @@ +#!/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 + +label="grib_accessors_test" +tempText=temp.$label.txt + +if [ $ECCODES_ON_WINDOWS -eq 1 ]; then + echo "$0: This test is currently disabled on Windows" + exit 0 +fi + +# Accessors like uint16, uint32 etc +# ---------------------------------- +tempDir=${label}.temp.dir +rm -rf $tempDir +mkdir -p $tempDir/definitions/grib2 +bootfile=$tempDir/definitions/grib2/boot.def +cat $def_dir/grib2/boot.def > $bootfile +echo "uint16 key_uint16: transient;" >> $bootfile +echo "uint32 key_uint32: transient;" >> $bootfile +echo "uint64 key_uint64: transient;" >> $bootfile +echo "uint32_little_endian key_uint32_le: transient;" >> $bootfile +echo "uint64_little_endian key_uint64_le: transient;" >> $bootfile +echo "key_tos1 = to_string(kindOfProduct,0,1);" >> $bootfile +echo "key_tos2 = to_string(dataDate,0,3);" >> $bootfile +echo >> $bootfile + +curr_defs=$ECCODES_DEFINITION_PATH +export ECCODES_DEFINITION_PATH=$PWD/$tempDir/definitions:$curr_defs + +input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl +set +e +# Not yet fully implemented +${tools_dir}/grib_get -p key_uint16 $input > $tempText 2>&1 +${tools_dir}/grib_get -p key_uint32 $input >> $tempText 2>&1 +${tools_dir}/grib_get -p key_uint32_le $input >> $tempText 2>&1 +set -e + +# kindOfProduct = GRIB, dataDate = 20070323 +grib_check_key_equals $input 'key_uint64,key_uint64_le' '0 0' +grib_check_key_equals $input 'key_tos1,key_tos2' 'G 200' +grib_check_key_equals $input 'key_tos2:d,key_tos2:i' '200 200' + +rm -rf $tempDir + + +# Clean up +rm -f $tempText diff --git a/tests/grib_get_fail.sh b/tests/grib_get_fail.sh index cb23f7468..a94ad80f6 100755 --- a/tests/grib_get_fail.sh +++ b/tests/grib_get_fail.sh @@ -32,36 +32,5 @@ set -e [ $status -ne 0 ] grep -q "Nh (Key/value not found)" $tempText -# Types like uint16, uint32 etc -# ------------------------------- -if [ $ECCODES_ON_WINDOWS -eq 0 ]; then - tempDir=${label}.temp.dir - rm -rf $tempDir - mkdir -p $tempDir/definitions/grib2 - bootfile=$tempDir/definitions/grib2/boot.def - cat $def_dir/grib2/boot.def > $bootfile - echo "uint16 key_uint16: transient;" >> $bootfile - echo "uint32 key_uint32: transient;" >> $bootfile - echo "uint64 key_uint64: transient;" >> $bootfile - echo "uint32_little_endian key_uint32_le: transient;" >> $bootfile - echo "uint64_little_endian key_uint64_le: transient;" >> $bootfile - curr_defs=$ECCODES_DEFINITION_PATH - export ECCODES_DEFINITION_PATH=$PWD/$tempDir/definitions:$curr_defs - - input=$ECCODES_SAMPLES_PATH/GRIB2.tmpl - set +e - # Not yet fully implemented - ${tools_dir}/grib_get -p key_uint16 $input > $tempText 2>&1 - ${tools_dir}/grib_get -p key_uint32 $input >> $tempText 2>&1 - ${tools_dir}/grib_get -p key_uint32_le $input >> $tempText 2>&1 - set -e - cat $tempText - - ${tools_dir}/grib_get -p key_uint64 $input - ${tools_dir}/grib_get -p key_uint64_le $input - - rm -rf $tempDir -fi - # Clean up rm -f $tempText