From 281612a23ad79365fb1c1823853c114601e5727f Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 16 Jan 2024 17:01:45 +0000 Subject: [PATCH] Testing: Dump modes --- tests/bufr_dump_samples.sh | 37 +++++++++++++++++++++++++++++++++++++ tools/bufr_dump.cc | 7 ------- tools/grib_dump.cc | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/tests/bufr_dump_samples.sh b/tests/bufr_dump_samples.sh index 105c9f9b3..9b3aaa531 100755 --- a/tests/bufr_dump_samples.sh +++ b/tests/bufr_dump_samples.sh @@ -34,4 +34,41 @@ for lang in C python fortran filter; do ${tools_dir}/bufr_dump -E $lang $input >/dev/null done +# Extra options +input=$ECCODES_SAMPLES_PATH/BUFR4.tmpl +${tools_dir}/bufr_dump -OHat $input >/dev/null + + +# Error cases +input=$ECCODES_SAMPLES_PATH/BUFR4.tmpl +set +e +${tools_dir}/bufr_dump -EXX $input > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid language specified" $temp + +set +e +${tools_dir}/bufr_dump -DXX $input > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid language specified" $temp + +set +e +${tools_dir}/bufr_dump -jX $input > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Invalid JSON option" $temp + +export ECCODES_BUFR_MULTI_ELEMENT_CONSTANT_ARRAYS=1 +set +e +${tools_dir}/bufr_dump -EC $input > $temp 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "not implemented" $temp + +# Clean up rm -f $temp diff --git a/tools/bufr_dump.cc b/tools/bufr_dump.cc index ed5fe88b8..840478728 100644 --- a/tools/bufr_dump.cc +++ b/tools/bufr_dump.cc @@ -99,16 +99,9 @@ static void check_code_gen_dump_mode(const char* language) int grib_tool_init(grib_runtime_options* options) { - int opt = grib_options_on("C") + grib_options_on("O"); - options->dump_mode = (char*)"default"; options->strict = 1; /* Must set here as bufr_dump has its own -S option */ - if (opt > 1) { - printf("%s: simultaneous j/C/O options not allowed\n", tool_name); - exit(1); - } - if (grib_options_on("j:")) { options->dump_mode = (char*)"json"; json_option = grib_options_get_option("j:"); diff --git a/tools/grib_dump.cc b/tools/grib_dump.cc index c7e0c02d9..f0db16c25 100644 --- a/tools/grib_dump.cc +++ b/tools/grib_dump.cc @@ -61,7 +61,7 @@ int grib_tool_before_getopt(grib_runtime_options* options) int grib_tool_init(grib_runtime_options* options) { - int opt = grib_options_on("C") + grib_options_on("O") + grib_options_on("D") + grib_options_on("j"); + const int opt = grib_options_on("C") + grib_options_on("O") + grib_options_on("D") + grib_options_on("j"); options->dump_mode = (char*)"default";