From 35274a1c4ea8013ba2cf3cba2e6a66d6ef385e35 Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 26 Dec 2024 17:27:06 +0000 Subject: [PATCH] Fix tests when HAVE_GEOGRAPHY=0 --- .../grib_accessor_class_message_is_valid.cc | 4 ++++ src/geo/iterator/grib_iterator.cc | 3 ++- tests/grib_check_message_validity.sh | 14 ++++++++------ tests/grib_spectral.sh | 4 +++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/accessor/grib_accessor_class_message_is_valid.cc b/src/accessor/grib_accessor_class_message_is_valid.cc index 558b7d0d1..856fec982 100644 --- a/src/accessor/grib_accessor_class_message_is_valid.cc +++ b/src/accessor/grib_accessor_class_message_is_valid.cc @@ -93,6 +93,8 @@ static int check_geoiterator(grib_handle* h) { //printf("DEBUG %s \n", __func__); int err = 0; + +#if defined(HAVE_GEOGRAPHY) grib_iterator* iter = grib_iterator_new(h, 0, &err); if (err == GRIB_NOT_IMPLEMENTED || err == GRIB_SUCCESS) { grib_iterator_delete(iter); @@ -101,6 +103,8 @@ static int check_geoiterator(grib_handle* h) grib_context_log(h->context, GRIB_LOG_ERROR, "%s", grib_get_error_message(err)); grib_iterator_delete(iter); +#endif + return err; } diff --git a/src/geo/iterator/grib_iterator.cc b/src/geo/iterator/grib_iterator.cc index 5c41b9be2..b215036f4 100644 --- a/src/geo/iterator/grib_iterator.cc +++ b/src/geo/iterator/grib_iterator.cc @@ -166,7 +166,8 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int int grib_iterator_delete(grib_iterator* i) { - grib_context_log(ch->context, GRIB_LOG_ERROR, + grib_context* c = grib_context_get_default(); + grib_context_log(c, GRIB_LOG_ERROR, "Geoiterator functionality not enabled. Please rebuild with -DENABLE_GEOGRAPHY=ON"); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/tests/grib_check_message_validity.sh b/tests/grib_check_message_validity.sh index d23df8d6c..293bf73ad 100755 --- a/tests/grib_check_message_validity.sh +++ b/tests/grib_check_message_validity.sh @@ -24,15 +24,17 @@ grib_check_key_equals $ECCODES_SAMPLES_PATH/GRIB2.tmpl isMessageValid 1 ${tools_dir}/grib_set -s PVPresent=1,NV=6 $ECCODES_SAMPLES_PATH/reduced_gg_pl_128_grib2.tmpl $tempGrib grib_check_key_equals $tempGrib isMessageValid 0 2>$tempText grep -q "Section 5 is missing" $tempText -grep -q "Error instantiating iterator gaussian_reduced" $tempText - +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + grep -q "Error instantiating iterator gaussian_reduced" $tempText +fi # Check regular lat/lon # ------------------------------ -${tools_dir}/grib_set -s Nj=0 $data_dir/sample.grib2 $tempGrib -grib_check_key_equals $tempGrib isMessageValid 0 2>$tempText -grep -q "Regular grid Geoiterator" $tempText - +if [ $HAVE_GEOGRAPHY -eq 1 ]; then + ${tools_dir}/grib_set -s Nj=0 $data_dir/sample.grib2 $tempGrib + grib_check_key_equals $tempGrib isMessageValid 0 2>$tempText + grep -q "Regular grid Geoiterator" $tempText +fi # Check reduced Gaussian grid Ni # ------------------------------ diff --git a/tests/grib_spectral.sh b/tests/grib_spectral.sh index df3bf43f0..7a32647fc 100755 --- a/tests/grib_spectral.sh +++ b/tests/grib_spectral.sh @@ -52,7 +52,9 @@ cat > $tempFilt <