Testing: dump in different modes

This commit is contained in:
Shahram Najm 2023-08-13 13:52:07 +01:00
parent 3a122d8fc2
commit 0f220e44fe
3 changed files with 61 additions and 0 deletions

View File

@ -47,6 +47,7 @@ list(APPEND test_c_bins
codes_dump_action_tree
codes_set_samples_path
codes_compare_keys
codes_dump_content
grib_sh_ieee64
grib_ieee
grib_set_bytes
@ -290,6 +291,7 @@ if( HAVE_BUILD_TOOLS )
codes_dump_action_tree
codes_set_samples_path
codes_compare_keys
codes_dump_content
grib_dump
grib_dump_debug
grib_dump_json

View File

@ -0,0 +1,35 @@
/*
* (C) Copyright 2005- ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#include <stdio.h>
#undef NDEBUG
#include <assert.h>
#include "eccodes.h"
int main(int argc, char* argv[])
{
int err = 0;
assert (argc == 3);
char* mode = argv[1];
char* filename = argv[2];
FILE* in = fopen(filename, "rb");
assert(in);
codes_handle* h = codes_handle_new_from_file(0, in, PRODUCT_ANY, &err);
assert(h);
grib_dump_content(h, stdout, mode, 0, NULL);
codes_handle_delete(h);
fclose(in);
return 0;
}

24
tests/codes_dump_content.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
label="codes_dump_content_test"
temp=temp.$label.grib
infile=$data_dir/sample.grib2
modes="default wmo json serialize debug grib_encode_C"
for mode in $modes; do
$EXEC ${test_dir}/codes_dump_content $mode $infile
done
# Clean up
rm -f $temp