Skip to content

Commit

Permalink
Fix tests when HAVE_GEOGRAPHY=0
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Dec 26, 2024
1 parent 7776c36 commit 35274a1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/accessor/grib_accessor_class_message_is_valid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/geo/iterator/grib_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 8 additions & 6 deletions tests/grib_check_message_validity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ------------------------------
Expand Down
4 changes: 3 additions & 1 deletion tests/grib_spectral.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ cat > $tempFilt <<EOF
write;
EOF
${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample2
${tools_dir}/grib_get_data $tempGrib
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
${tools_dir}/grib_get_data $tempGrib
fi
${tools_dir}/grib_dump $tempGrib
grib_check_key_equals $tempGrib packingType spectral_complex
grib_check_key_equals $tempGrib gridType sh
Expand Down

0 comments on commit 35274a1

Please sign in to comment.