Testing: grib_to_netcdf error conditions

This commit is contained in:
shahramn 2024-08-20 11:44:01 +01:00
parent cdb2e68f87
commit a2bd712308
2 changed files with 26 additions and 0 deletions

View File

@ -104,8 +104,23 @@ echo "Test shuffle and deflate ..."
if [ $have_netcdf4 -eq 1 ]; then
input=${data_dir}/sst_globus0083.grib
${tools_dir}/grib_to_netcdf -s -d9 -k4 -o $tempNetcdf $input
set +e
${tools_dir}/grib_to_netcdf -s -o $tempNetcdf $input > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid shuffle option. Deflate option needed" $tempText
set +e
${tools_dir}/grib_to_netcdf -s -dy -o $tempNetcdf $input > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid number" $tempText
fi
echo "Test ECC-1060 ..."
# ----------------------
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
@ -172,6 +187,16 @@ set -e
grep -q "not on a regular lat/lon grid or on a regular Gaussian grid" $tempText
echo "No output ..."
# --------------------------
set +e
${tools_dir}/grib_to_netcdf $input > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "No output file" $tempText
# ECC-1783: No error message when input file has invalid fields
input=$data_dir/bad.grib
set +e

View File

@ -4294,6 +4294,7 @@ int grib_tool_finalise_action(grib_runtime_options* options)
int creation_mode = NC_CLOBBER;
if (options->outfile == NULL || options->outfile->name == NULL) {
grib_context_log(ctx, GRIB_LOG_ERROR, "No output file. Exiting!");
usage();
exit(1);
}