diff --git a/src/Makefile.am b/src/Makefile.am index f2c7cb3d1..648e71d27 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -287,6 +287,7 @@ libeccodes_la_prototypes= \ grib_dumper_class_debug.c \ grib_dumper_class_default.c \ grib_dumper_class_keys.c \ + grib_dumper_class_filter.c \ grib_dumper_class_json.c \ grib_dumper_class_xml.c \ grib_dumper_class_c_code.c \ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 527941f75..f00f142b4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -57,6 +57,7 @@ list( APPEND tests2 bufr_change_edition ecc-197 ecc-286 + ecc-288 gts_get gts_ls gts_compare diff --git a/tests/Makefile.am b/tests/Makefile.am index 58f0cf501..76b0d169d 100755 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -58,7 +58,10 @@ TESTS = definitions.sh \ ccsds.sh \ md5.sh \ grib_util_set_spec.sh \ - neg_fctime.sh + neg_fctime.sh \ + ecc-197.sh \ + ecc-286.sh \ + ecc-288.sh # First download all the necessary data for testing # Note: if download fails, no tests will be done diff --git a/tests/bufr_compare.sh b/tests/bufr_compare.sh index 62e2224aa..2413ca549 100755 --- a/tests/bufr_compare.sh +++ b/tests/bufr_compare.sh @@ -104,7 +104,7 @@ ${tools_dir}/bufr_compare -r ${fBufrInput1} ${fBufrInput2}>> $fLog #---------------------------------------------------- ${tools_dir}bufr_set -s subCentre=12 aaen_55.bufr $fBufrTmp set +e -${tools_dir}bufr_compare aaen_55.bufr $fBufrTmp +${tools_dir}bufr_compare aaen_55.bufr $fBufrTmp >/dev/null status=$? set -e [ $status -eq 1 ] @@ -116,7 +116,7 @@ temp_dir=tempdir.bufr_compare mkdir -p $temp_dir infile=aaen_55.bufr cp $infile $temp_dir -${tools_dir}bufr_compare $infile $temp_dir +${tools_dir}bufr_compare $infile $temp_dir >/dev/null #Clean up diff --git a/tests/bufr_dump.sh b/tests/bufr_dump.sh index b0425bb31..8c8c89b7c 100755 --- a/tests/bufr_dump.sh +++ b/tests/bufr_dump.sh @@ -15,7 +15,7 @@ label="bufr_dump_test" #Create log file fLog=${label}".log" -rm -f $fLog | true +rm -f $fLog touch $fLog #Define tmp bufr files @@ -70,3 +70,4 @@ done #rm -f $fLog #rm -f $fJsonTmp | true +rm -f $fLog diff --git a/tests/bufr_filter.sh b/tests/bufr_filter.sh index a2add0e2e..26fbc0b0f 100755 --- a/tests/bufr_filter.sh +++ b/tests/bufr_filter.sh @@ -1425,3 +1425,4 @@ do done +rm -f $fLog diff --git a/tests/bufr_get.sh b/tests/bufr_get.sh index 02982d36a..5376c4d5a 100755 --- a/tests/bufr_get.sh +++ b/tests/bufr_get.sh @@ -41,14 +41,11 @@ ref_get=$f".ls.ref" echo "Test: -p switch" >> $fLog echo "file: $f" >> $fLog -${tools_dir}/bufr_get -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f > $fTmp +${tools_dir}/bufr_get -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,localNumberOfObservations $f > $fTmp #Write the values into a file and compare with ref cat $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_get diff $ref_get $res_get #Clean up -rm -f $fLog -rm -f $fTmp | true -rm -f $res_get | true - +rm -f $fLog $fTmp $res_get diff --git a/tests/bufr_ls.sh b/tests/bufr_ls.sh index 6cf1c18c3..60d4fa4ec 100755 --- a/tests/bufr_ls.sh +++ b/tests/bufr_ls.sh @@ -42,7 +42,7 @@ ref_ls=$f".ls.ref" res_ls=$f".ls.test" REDIRECT=/dev/null -${tools_dir}/bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,numberOfObservations $f 2> $REDIRECT > $fTmp +${tools_dir}/bufr_ls -p totalLength,bufrHeaderCentre,bufrHeaderSubCentre,masterTableNumber,masterTablesVersionNumber,localTablesVersionNumber,numberOfSubsets,localNumberOfObservations $f 2> $REDIRECT > $fTmp #Write the values into a file and compare with ref awk NR==3 $fTmp | awk '{split($0,a," "); for (i=1; i<=8; i++) print a[i]}' > $res_ls diff --git a/tests/ecc-197.sh b/tests/ecc-197.sh index 286ca217e..f4393052f 100755 --- a/tests/ecc-197.sh +++ b/tests/ecc-197.sh @@ -15,9 +15,17 @@ # It tests decoding a BUFR file which cannot be done unless # we extend the definitions to include extra files # --------------------------------------------------------- +label="ecc-197-test" + +input=${data_dir}/bufr/vos308014_v3_26.bufr +if [ ! -f $input ]; then + echo "Data file $input not available" + exit 0 +fi +TEMP=${label}.temp # Create a temporary directory which holds the tables etc -TEMP_DIR=ecc-197-temp-dir.$$ +TEMP_DIR=${label}.temp-dir.$$ rm -rf $TEMP_DIR mkdir -p $TEMP_DIR/definitions/bufr/tables/0/wmo/26 @@ -32,7 +40,11 @@ MY_DEFS=`pwd`/$TEMP_DIR/definitions export ECCODES_DEFINITION_PATH=$MY_DEFS:$ECCODES_DEFINITION_PATH # Now decode -${tools_dir}bufr_dump ${data_dir}/bufr/vos308014_v3_26.bufr >/dev/null +${tools_dir}bufr_dump $input > $TEMP +# Ensure output JSON has all the expected contents +# After calling 'wc' and 'set', $1 will be the line count +set `wc -l $TEMP` +[ "$1" = "35725" ] rm -rf $TEMP_DIR - +rm -f $TEMP diff --git a/tests/ecc-288.sh b/tests/ecc-288.sh new file mode 100755 index 000000000..226273da0 --- /dev/null +++ b/tests/ecc-288.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright 2005-2016 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.sh + +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-288 +# It tests bufr_compare with a relative tolerance +# --------------------------------------------------------- +cd ${data_dir}/bufr +label="ecc_288_test" + +tempRules=temp.${label}.filter +tempOut=temp.${label}.out +BufrFile=syno_1.bufr + +cat > $tempRules <tolerance_count=MAX_KEYS; + ret=parse_keyval_string(grib_tool_name, sarg,1,GRIB_TYPE_DOUBLE,options->tolerance,&(options->tolerance_count)); + if (ret == GRIB_INVALID_ARGUMENT) { + usage(); + exit(1); + } + } + { /* Check for 2nd file being a directory. If so, we assume user is comparing to a file */ /* with the same name as first file in that directory */ diff --git a/windows/msvc/grib_api_lib/grib_api_lib.vcproj b/windows/msvc/grib_api_lib/grib_api_lib.vcproj index 008a97b7f..88eec9fca 100644 --- a/windows/msvc/grib_api_lib/grib_api_lib.vcproj +++ b/windows/msvc/grib_api_lib/grib_api_lib.vcproj @@ -420,6 +420,10 @@ RelativePath="..\..\..\src\action_class_write.c" > + + @@ -1388,6 +1392,10 @@ RelativePath="..\..\..\src\grib_dumper_class_default.c" > + +