diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7b919ccbb..51078d24f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -95,6 +95,7 @@ list( APPEND tests_data_reqd bufr_ecc-750 grib_ecc-490 grib_ecc-756 + grib_ecc-873 bufr_ecc-556 gts_get gts_ls diff --git a/tests/grib_ecc-873.sh b/tests/grib_ecc-873.sh new file mode 100755 index 000000000..4cb832953 --- /dev/null +++ b/tests/grib_ecc-873.sh @@ -0,0 +1,117 @@ +#!/bin/sh +# Copyright 2005-2018 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 +set -u +# --------------------------------------------------------- +# This is the test for the JIRA issue ECC-873. +# It tests grib_ls with the ordering option '-B' +# --------------------------------------------------------- +label="grib_ecc-873-test" +tempRef=temp.${label}.ref +tempOut=temp.${label}.out + +# Test 1 +# ------ +input=${data_dir}/tigge_pf_ecmwf.grib2 +${tools_dir}/grib_ls -p count,level -B'level:i' $input > $tempOut + +cat > $tempRef < $tempOut +cat > $tempRef <handle_count=0; + grib_context_set_handle_file_count(c, 0); /* ECC-873 */ + grib_context_set_handle_total_count(c, 0); /* ECC-873 */ while(!options->skip_all && ((h = grib_fieldset_next_handle(set,&err)) != NULL || err != GRIB_SUCCESS )) { options->handle_count++; + grib_context_set_handle_file_count(c, options->handle_count);/* ECC-873 */ + grib_context_set_handle_total_count(c, options->handle_count);/* ECC-873 */ options->error=err; if (!h) {