From 5cbc79fd3649e9d2f3584e872f25f29d4c3d0a75 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 26 Dec 2023 17:54:09 +0000 Subject: [PATCH] Testing: Increase coverage: JPEG decoding --- src/grib_jasper_encoding.cc | 8 +++----- src/grib_openjpeg_encoding.cc | 4 ++-- tests/grib_jpeg.sh | 12 +++++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/grib_jasper_encoding.cc b/src/grib_jasper_encoding.cc index 815fe376b..ac545555a 100644 --- a/src/grib_jasper_encoding.cc +++ b/src/grib_jasper_encoding.cc @@ -273,19 +273,17 @@ cleanup: return code; } -#else +#else // HAVE_LIBJASPER int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled."); + grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_decode: JasPer JPEG support not enabled."); return GRIB_FUNCTIONALITY_NOT_ENABLED; } int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) { - grib_context_log(c, GRIB_LOG_ERROR, - "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled."); + grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_encode: JasPer JPEG support not enabled."); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/src/grib_openjpeg_encoding.cc b/src/grib_openjpeg_encoding.cc index 1c08de603..6b726a97a 100644 --- a/src/grib_openjpeg_encoding.cc +++ b/src/grib_openjpeg_encoding.cc @@ -546,13 +546,13 @@ cleanup: int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals) { - grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_encoding.c: OpenJPEG JPEG support not enabled."); + grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_decode: OpenJPEG JPEG support not enabled."); return GRIB_FUNCTIONALITY_NOT_ENABLED; } int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper) { - grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_encoding.c: OpenJPEG JPEG support not enabled."); + grib_context_log(c, GRIB_LOG_ERROR, "grib_openjpeg_encode: OpenJPEG JPEG support not enabled."); return GRIB_FUNCTIONALITY_NOT_ENABLED; } diff --git a/tests/grib_jpeg.sh b/tests/grib_jpeg.sh index dfe8a8f61..69210430e 100755 --- a/tests/grib_jpeg.sh +++ b/tests/grib_jpeg.sh @@ -156,5 +156,15 @@ ECCODES_GRIB_DUMP_JPG_FILE=$tempDump ${tools_dir}/grib_copy -r $data_dir/jpeg.g [ -f $tempDump ] rm -f $tempDump +# Check Jasper decoding when it is disabled +if [ $HAVE_LIBJASPER -eq 0 ]; then + set +e + ECCODES_GRIB_JPEG=jasper ${tools_dir}/grib_get -n statistics $data_dir/jpeg.grib2 > $tempDump 2>&1 + status=$? + set -e + [ $status -ne 0 ] + grep -q "JasPer JPEG support not enabled" $tempDump +fi + # Clean up -rm -f $tempFilt $tempGrib +rm -f $tempFilt $tempGrib $tempDump