mirror of https://github.com/ecmwf/eccodes.git
Testing: Count of failed compares
This commit is contained in:
parent
f690fdf798
commit
aa1a3ea6e7
|
@ -18,6 +18,7 @@ int main(int argc, char* argv[])
|
|||
grib_handle* h2 = NULL;
|
||||
int err = 0;
|
||||
int failed = 0;
|
||||
size_t count = 0;
|
||||
|
||||
Assert(argc == 3);
|
||||
f1 = fopen(argv[1], "rb");
|
||||
|
@ -40,6 +41,7 @@ int main(int argc, char* argv[])
|
|||
if (err) {
|
||||
fprintf(stderr, "key: %s (%s)\n", name, grib_get_error_message(err));
|
||||
failed = 1;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +52,7 @@ int main(int argc, char* argv[])
|
|||
fclose(f1);
|
||||
fclose(f2);
|
||||
if (failed) {
|
||||
fprintf(stderr, "\nComparison failed: One or more keys are different\n");
|
||||
fprintf(stderr, "\nComparison failed: %zu key(s) are different\n", count);
|
||||
}
|
||||
return failed;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
. ./include.ctest.sh
|
||||
|
||||
label="codes_compare_keys_test"
|
||||
tempGrib=temp.${label}.grib
|
||||
tempRef=temp.${label}.ref
|
||||
tempLog=temp.$label.log
|
||||
|
||||
|
@ -37,9 +38,30 @@ key: minutesAfterDataCutoff (Long values are different)
|
|||
key: numberOfValues (Long values are different)
|
||||
key: referenceValue (Double values are different)
|
||||
|
||||
Comparison failed: One or more keys are different
|
||||
Comparison failed: 13 key(s) are different
|
||||
EOF
|
||||
|
||||
diff $tempRef $tempLog
|
||||
rm -f $tempRef $tempLog
|
||||
|
||||
# Different values
|
||||
# ---------------------
|
||||
input=${data_dir}/sample.grib2
|
||||
${tools_dir}/grib_set -s scaleValuesBy=1.01 $input $tempGrib
|
||||
set +e
|
||||
$EXEC ${test_dir}/codes_compare_keys $input $tempGrib > $tempLog 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
cat $tempLog
|
||||
cat > $tempRef <<EOF
|
||||
key: referenceValue (Double values are different)
|
||||
key: codedValues (Double values are different)
|
||||
|
||||
Comparison failed: 2 key(s) are different
|
||||
EOF
|
||||
|
||||
diff $tempRef $tempLog
|
||||
|
||||
rm -f $tempLog $tempRef
|
||||
# Clean up
|
||||
rm -f $tempLog $tempRef $tempGrib
|
||||
|
|
Loading…
Reference in New Issue