Testing: GTS header

This commit is contained in:
Shahram Najm 2020-02-10 17:48:41 +00:00
parent 1f23533b68
commit 86549f88e4
2 changed files with 26 additions and 8 deletions

View File

@ -779,7 +779,8 @@ static grib_handle* grib_handle_new_from_file_multi(grib_context* c, FILE* f, in
if (c->gts_header_on && gtslen >= 8) {
gl->gts_header = (char*)grib_context_malloc_clear(c, sizeof(unsigned char) * gtslen);
memcpy(gl->gts_header, gts_header, gtslen);
DebugAssert(gts_header);
if (gts_header) memcpy(gl->gts_header, gts_header, gtslen);
gl->gts_header_len = gtslen;
grib_context_free(c, save_gts_header);
gtslen = 0;
@ -1012,7 +1013,8 @@ grib_handle* bufr_new_from_file(grib_context* c, FILE* f, int* error)
if (c->gts_header_on && gtslen >= 8) {
gl->gts_header = (char*)grib_context_malloc(c, sizeof(unsigned char) * gtslen);
memcpy(gl->gts_header, gts_header, gtslen);
DebugAssert(gts_header);
if (gts_header) memcpy(gl->gts_header, gts_header, gtslen);
gl->gts_header_len = gtslen;
grib_context_free(c, save_gts_header);
gtslen = 0;
@ -1135,7 +1137,8 @@ static grib_handle* grib_handle_new_from_file_no_multi(grib_context* c, FILE* f,
if (c->gts_header_on && gtslen >= 8) {
gl->gts_header = (char*)grib_context_malloc(c, sizeof(unsigned char) * gtslen);
memcpy(gl->gts_header, gts_header, gtslen);
DebugAssert(gts_header);
if (gts_header) memcpy(gl->gts_header, gts_header, gtslen);
gl->gts_header_len = gtslen;
grib_context_free(c, save_gts_header);
gtslen = 0;

View File

@ -10,8 +10,6 @@
. ./include.sh
#set -x
#Enter data dir
cd ${data_dir}
@ -19,9 +17,26 @@ cd ${data_dir}
label="grib_copy_test"
temp=${label}".grib.tmp"
#-------------------------------------------------------------------
# Test: The -X option
#-------------------------------------------------------------------
echo "Test: The -g option..."
# -----------------------------------
input=gts.grib
${tools_dir}/grib_copy -w count=1 -g $input $temp
val1=`${tools_dir}/gts_get -wcount=1 -p AA $input`
val2=`${tools_dir}/gts_get -p AA $temp`
[ "$val1" = "$val2" ]
[ "$val1" = "XK" ]
${tools_dir}/grib_copy -w count=1 $input $temp
set +e
${tools_dir}/gts_get -p AA $temp
status=$?
set -e
[ $status -ne 0 ]
echo "Test: The -X option..."
# -------------------------------
echo "Test: use of -X option"
input=tigge_pf_ecmwf.grib2
${tools_dir}/grib_copy -w count=1 -X 0 $input $temp #First msg