Testing: Error messages should go to stderr

This commit is contained in:
Shahram Najm 2022-12-21 11:23:48 +00:00
parent f6ff36c09a
commit def66fe512
5 changed files with 11 additions and 12 deletions

View File

@ -14,7 +14,7 @@
* Description: How to decode GRIB2 multi-field messages.
* Try to turn the multi support on and off to
* see the difference. Default is OFF.
* For all the tools default is multi support ON.
* For all the tools (e.g., grib_ls etc) multi support is ON.
*/
#include <stdio.h>
#include <assert.h>

View File

@ -48,7 +48,7 @@ int main(int argc, char* argv[])
for (i = 0; i < nvalues; i++) {
if (values[i].error == err) name = (char*)values[i].name;
}
printf("Error: \"%s\" %s\n", name, codes_get_error_message(err));
fprintf(stderr, "Error: \"%s\" %s\n", name, codes_get_error_message(err));
}
values[1].name = "levelll";
@ -57,7 +57,7 @@ int main(int argc, char* argv[])
for (i = 0; i < nvalues; i++) {
if (values[i].error == err) name = (char*)values[i].name;
}
printf("Error: \"%s\" %s\n", name, codes_get_error_message(err));
fprintf(stderr, "Error: \"%s\" %s\n", name, codes_get_error_message(err));
}
codes_handle_delete(h);

View File

@ -12,7 +12,6 @@
# Define a common label for all the tmp files
label="grib_values_check_c"
tempOut=${label}.tmp.out
tempErr=${label}.tmp.err
tempRef=${label}.tmp.ref
@ -22,11 +21,11 @@ Error: "levelll" Key/value not found
EOF
# Input GRIB file path is hard coded in the example
${examples_dir}/c_grib_values_check > $tempOut
${examples_dir}/c_grib_values_check 2> $tempErr
# Compare output with the reference
cat $tempOut
diff $tempRef $tempOut
# Compare stderr with the reference
cat $tempErr
diff $tempRef $tempErr
# Clean up
rm -f $tempRef $tempErr $tempOut
rm -f $tempRef $tempErr

View File

@ -26,7 +26,7 @@ int main()
numbytes = ni * nj * sizeof(double);
values = (double*)malloc(numbytes);
if (!values) {
printf("Malloc failed - requested %lu bytes\n", (unsigned long)numbytes);
fprintf(stderr, "Malloc failed - requested %zu bytes\n", numbytes);
return 1;
}

View File

@ -10,7 +10,7 @@
! Description: How to decode GRIB messages containing multiple
! fields. Try to turn on and off multi support to
! see the difference. Default is OFF.
! For all the tools default is multi support ON.
! For all the tools (e.g., grib_ls etc) multi support is ON.
!
!
program multi