Tools: Test for error conditions

This commit is contained in:
Shahram Najm 2023-08-08 13:16:05 +01:00
parent 1a9b2f87e8
commit 44cb31cfd1
2 changed files with 12 additions and 2 deletions

View File

@ -191,5 +191,16 @@ set -e
[ $status -ne 0 ]
grep -q "Invalid type for key=shortName" $tempText
# Do list after an offset
file=tigge_pf_ecmwf.grib2
${tools_dir}/grib_ls -X 62414 $file
set +e
${tools_dir}/grib_ls -X -1 $file > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid file offset" $tempText
# Clean up
rm -f $temp1 $temp2 $tempText $tempLog

View File

@ -343,8 +343,7 @@ static int grib_tool_without_orderby(grib_runtime_options* options)
#endif
err = fseeko(infile->file, options->infile_offset, SEEK_SET);
if (err) {
/*fprintf(stderr, "Invalid file offset: %ld\n", options->infile_offset);*/
perror("Invalid file offset");
fprintf(stderr, "%s: Invalid file offset: %lld\n", tool_name, options->infile_offset);
exit(1);
}
}