mirror of https://github.com/ecmwf/eccodes.git
Testing: codes_get_string for different products
This commit is contained in:
parent
a0e3cc1a8f
commit
7b36814d11
|
@ -142,7 +142,7 @@ static int value_count(grib_accessor* a, long* count)
|
||||||
static int unpack_string(grib_accessor* a, char* val, size_t* len)
|
static int unpack_string(grib_accessor* a, char* val, size_t* len)
|
||||||
{
|
{
|
||||||
long i = 0;
|
long i = 0;
|
||||||
size_t l = a->length + 1;
|
size_t l = string_length(a) + 1;
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
grib_handle* h = grib_handle_of_accessor(a);
|
||||||
|
|
||||||
if (*len < l) {
|
if (*len < l) {
|
||||||
|
|
|
@ -18,15 +18,20 @@ int main(int argc, char* argv[])
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
assert(argc == 3);
|
assert(argc == 4);
|
||||||
|
|
||||||
const char* infile = argv[1];
|
const char* prod = argv[1];
|
||||||
|
const char* infile = argv[2];
|
||||||
FILE* in = fopen(infile, "rb");
|
FILE* in = fopen(infile, "rb");
|
||||||
assert(in);
|
assert(in);
|
||||||
char* key = argv[2];
|
char* key = argv[3];
|
||||||
char kvalue[2] = {0,}; // deliberately short
|
char kvalue[2] = {0,}; // deliberately short
|
||||||
|
ProductKind productKind = PRODUCT_GRIB;
|
||||||
|
if (strcmp(prod, "BUFR")==0) productKind = PRODUCT_BUFR;
|
||||||
|
if (strcmp(prod, "GTS")==0) productKind = PRODUCT_GTS;
|
||||||
|
if (strcmp(prod, "ANY")==0) productKind = PRODUCT_ANY;
|
||||||
|
|
||||||
h = codes_handle_new_from_file(NULL, in, PRODUCT_ANY, &err);
|
h = codes_handle_new_from_file(NULL, in, productKind, &err);
|
||||||
assert(h);
|
assert(h);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
|
|
|
@ -15,29 +15,33 @@ tempGrib=temp.$label.grib
|
||||||
tempText=temp.$label.txt
|
tempText=temp.$label.txt
|
||||||
|
|
||||||
input=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
input=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
||||||
$EXEC ${test_dir}/codes_get_string $input dataDate
|
$EXEC ${test_dir}/codes_get_string GRIB $input dataDate
|
||||||
|
|
||||||
${tools_dir}/grib_set -s marsType=s3,marsStream=mpic $input $tempGrib
|
${tools_dir}/grib_set -s marsType=s3,marsStream=mpic $input $tempGrib
|
||||||
$EXEC ${test_dir}/codes_get_string $tempGrib dayOfTheYearDate # 2> $tempText
|
$EXEC ${test_dir}/codes_get_string GRIB $tempGrib dayOfTheYearDate # 2> $tempText
|
||||||
|
|
||||||
|
|
||||||
input=$data_dir/reduced_latlon_surface.grib2
|
input=$data_dir/reduced_latlon_surface.grib2
|
||||||
keys="identifier projString bitmap class year gridDefinitionDescription
|
keys="identifier projString bitmap class year gridDefinitionDescription
|
||||||
time validityTime packingType md5Headers parameterUnits"
|
time validityTime packingType md5Headers parameterUnits"
|
||||||
for k in $keys; do
|
for k in $keys; do
|
||||||
$EXEC ${test_dir}/codes_get_string $input $k 2> $tempText
|
$EXEC ${test_dir}/codes_get_string GRIB $input $k 2> $tempText
|
||||||
grep -q "Buffer too small" $tempText
|
grep -q "Buffer too small" $tempText
|
||||||
done
|
done
|
||||||
|
|
||||||
input=$ECCODES_SAMPLES_PATH/reduced_gg_ml_grib2.tmpl
|
input=$ECCODES_SAMPLES_PATH/reduced_gg_ml_grib2.tmpl
|
||||||
$EXEC ${test_dir}/codes_get_string "$input" gridName 2> $tempText
|
$EXEC ${test_dir}/codes_get_string GRIB "$input" gridName 2> $tempText
|
||||||
grep -q "Buffer too small" $tempText
|
grep -q "Buffer too small" $tempText
|
||||||
|
|
||||||
|
|
||||||
# shortName = swh
|
# shortName = swh
|
||||||
input=$data_dir/reduced_latlon_surface.grib1
|
input=$data_dir/reduced_latlon_surface.grib1
|
||||||
$EXEC ${test_dir}/codes_get_string "$input" shortName 2> $tempText
|
$EXEC ${test_dir}/codes_get_string GRIB "$input" shortName 2> $tempText
|
||||||
grep -q "Buffer too small" $tempText
|
grep -q "Buffer too small" $tempText
|
||||||
|
|
||||||
|
input=$data_dir/gts/EGRR20150317121020_00493212.DAT
|
||||||
|
$EXEC ${test_dir}/codes_get_string GTS "$input" theMessage 2> $tempText
|
||||||
|
grep -q "Buffer too small" $tempText
|
||||||
|
|
||||||
|
# Clean up
|
||||||
rm -f $tempText
|
rm -f $tempText
|
||||||
|
|
Loading…
Reference in New Issue