Testing: Dump modes

This commit is contained in:
Shahram Najm 2024-01-16 17:01:45 +00:00
parent e785c67ce4
commit 281612a23a
3 changed files with 38 additions and 8 deletions

View File

@ -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

View File

@ -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:");

View File

@ -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";