Testing: Detect empty concept value

This commit is contained in:
shahramn 2024-04-22 13:35:25 +01:00
parent dace02c52f
commit 8a9186a37a
3 changed files with 13 additions and 3 deletions

View File

@ -204,6 +204,7 @@ sub process {
} }
elsif ($this =~ /'(.*)' *= *{/) { elsif ($this =~ /'(.*)' *= *{/) {
$concept = $1; $concept = $1;
die "File: $filename, line: $lineNum: Value is empty." if ($concept eq '');
die "File: $filename, line: $lineNum: Value contains invalid characters." if (non_printable($concept)); die "File: $filename, line: $lineNum: Value contains invalid characters." if (non_printable($concept));
if ($filename eq 'cfVarName.def') { if ($filename eq 'cfVarName.def') {
#if ($concept =~ /^[0-9]/) { #if ($concept =~ /^[0-9]/) {

View File

@ -59,6 +59,7 @@ static int scale_factor_missing(const char* value)
static int grib_check_param_concepts(const char* key, const char* filename) static int grib_check_param_concepts(const char* key, const char* filename)
{ {
int isLocal = 0; int isLocal = 0;
int count = 0;
grib_concept_value* concept_value = grib_parse_concept_file(NULL, filename); grib_concept_value* concept_value = grib_parse_concept_file(NULL, filename);
if (!concept_value) if (!concept_value)
return GRIB_IO_PROBLEM; return GRIB_IO_PROBLEM;
@ -67,6 +68,11 @@ static int grib_check_param_concepts(const char* key, const char* filename)
isLocal = 1; isLocal = 1;
} }
while (concept_value) { while (concept_value) {
count++;
if (strlen(concept_value->name) == 0) {
fprintf(stderr, "%s %s: Empty concept value (count=%d)\n", key, concept_value->name, count);
Assert(0);
}
grib_concept_condition* concept_condition = concept_value->conditions; grib_concept_condition* concept_condition = concept_value->conditions;
/* Convention: /* Convention:
* -1 key not present * -1 key not present

View File

@ -36,6 +36,12 @@ for a_dataset in $datasets; do
$EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/$a_dataset/shortName.def $EXEC ${test_dir}/grib_check_param_concepts shortName $ECCODES_DEFINITION_PATH/grib2/localConcepts/$a_dataset/shortName.def
done done
# Check WMO name.def etc
$EXEC ${test_dir}/grib_check_param_concepts name $ECCODES_DEFINITION_PATH/grib2/name.def
$EXEC ${test_dir}/grib_check_param_concepts units $ECCODES_DEFINITION_PATH/grib2/units.def
$EXEC ${test_dir}/grib_check_param_concepts units $ECCODES_DEFINITION_PATH/grib2/cfVarName.def
# Check the group: name.def paramId.def shortName.def units.def cfVarName.def # Check the group: name.def paramId.def shortName.def units.def cfVarName.def
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Check whether the Test::More Perl module is available # Check whether the Test::More Perl module is available
@ -56,11 +62,8 @@ defs_dirs="
$ECCODES_DEFINITION_PATH/grib1/localConcepts/ecmf $ECCODES_DEFINITION_PATH/grib1/localConcepts/ecmf
$ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf
$ECCODES_DEFINITION_PATH/grib1/localConcepts/ammc
$ECCODES_DEFINITION_PATH/grib1/localConcepts/eidb
$ECCODES_DEFINITION_PATH/grib1/localConcepts/ekmi $ECCODES_DEFINITION_PATH/grib1/localConcepts/ekmi
$ECCODES_DEFINITION_PATH/grib1/localConcepts/enmi $ECCODES_DEFINITION_PATH/grib1/localConcepts/enmi
$ECCODES_DEFINITION_PATH/grib1/localConcepts/eswi
$ECCODES_DEFINITION_PATH/grib1/localConcepts/lfpw $ECCODES_DEFINITION_PATH/grib1/localConcepts/lfpw
$ECCODES_DEFINITION_PATH/grib1/localConcepts/lowm $ECCODES_DEFINITION_PATH/grib1/localConcepts/lowm
$ECCODES_DEFINITION_PATH/grib1/localConcepts/rjtd $ECCODES_DEFINITION_PATH/grib1/localConcepts/rjtd