From 264edafab902fc353983edb0ebb753a68156fc37 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 24 Aug 2024 16:17:15 +0100 Subject: [PATCH] Testing: grib_compare & bufr_compare options --- tests/grib_compare.sh | 19 +++++++++++++++++-- tools/bufr_compare.cc | 13 +------------ tools/grib_compare.cc | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/tests/grib_compare.sh b/tests/grib_compare.sh index 1ac1f1462..4c1f457ff 100755 --- a/tests/grib_compare.sh +++ b/tests/grib_compare.sh @@ -306,20 +306,35 @@ status=$? set -e [ $status -ne 0 ] +# Key unpackedValues +#------------------- +${tools_dir}/grib_set -s scaleValuesBy=1.01 $ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl $temp1 +${tools_dir}/grib_compare -c unpackedValues -A 1.86 $ECCODES_SAMPLES_PATH/sh_ml_grib2.tmpl $temp1 + +# ----------------- # Failing cases # ----------------- set +e -${tools_dir}/grib_compare -H -c data:n $temp1 $temp2 +${tools_dir}/grib_compare -Rxxxx $temp1 $temp2 > $outfile 2>&1 status=$? set -e [ $status -eq 1 ] +grep "Invalid argument" $outfile set +e -${tools_dir}/grib_compare -a $temp1 $temp2 +${tools_dir}/grib_compare -H -c data:n $temp1 $temp2 > $outfile 2>&1 status=$? set -e [ $status -eq 1 ] +grep -q "options are incompatible" $outfile + +set +e +${tools_dir}/grib_compare -a $temp1 $temp2 > $outfile 2>&1 +status=$? +set -e +[ $status -eq 1 ] +grep -q "a option requires -c option" $outfile echo GRIB > $temp1 diff --git a/tools/bufr_compare.cc b/tools/bufr_compare.cc index 325c67cd3..327020a9d 100644 --- a/tools/bufr_compare.cc +++ b/tools/bufr_compare.cc @@ -49,17 +49,6 @@ const char* tool_name = "bufr_compare"; const char* tool_online_doc = "https://confluence.ecmwf.int/display/ECC/bufr_compare"; const char* tool_usage = "[options] bufr_file1 bufr_file2"; -GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b) -{ - if (*a != *b) - return 1; - while ((*a != 0 && *b != 0) && *(a) == *(b)) { - a++; - b++; - } - return (*a == 0 && *b == 0) ? 0 : 1; -} - typedef double (*compare_double_proc)(const double*, const double*, const double*); typedef struct grib_error grib_error; @@ -657,7 +646,7 @@ static int strings_are_different(grib_handle* h1, grib_handle* h2, const char* k const char* s1, const char* s2, size_t slen1, size_t slen2) { - if (grib_inline_strcmp(s1, s2) == 0) { + if (strcmp(s1, s2) == 0) { return 0; } /* Strings are different. Now check if strings are 'missing'. diff --git a/tools/grib_compare.cc b/tools/grib_compare.cc index 330f218e0..911b1b0a5 100644 --- a/tools/grib_compare.cc +++ b/tools/grib_compare.cc @@ -367,8 +367,8 @@ int grib_tool_init(grib_runtime_options* options) options->tolerance_count = MAX_KEYS; ret = parse_keyval_string(tool_name, sarg, 1, GRIB_TYPE_DOUBLE, options->tolerance, &(options->tolerance_count)); if (ret == GRIB_INVALID_ARGUMENT) { + fprintf(stderr, "%s: Invalid argument for -R\n",tool_name); usage(); - exit(1); } }