libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit f79ee91c075c5ac4c7f629705d28b46cd51c8a58
parent c46a09ddab0e7d87589682ce1fabaf1ab008ef15
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Sun, 15 Jun 2025 15:39:45 +0200

test_lib_info_version: improved reporting

Diffstat:
Msrc/tests/basic/test_lib_info_version.c | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/tests/basic/test_lib_info_version.c b/src/tests/basic/test_lib_info_version.c @@ -53,6 +53,7 @@ tst_EXPECT_OK_helper (enum MHD_StatusCode code, if (MHD_SC_OK == code) return 1; + fflush (stdout); (void) fprintf (stderr, "At the line number %lu: " "MHD function failed: \n" @@ -75,17 +76,6 @@ tst_EXPECT_OK_helper (enum MHD_StatusCode code, #define tst_EXPECT_OK(mhd_func_call) \ (tst_EXPECT_OK_helper ((mhd_func_call), __LINE__, #mhd_func_call)) -/** - * Check whether SC code is OK, print error if not. - * @warning Do not use function call in the argument - * @param sc the status code to check - */ -#define tst_EXPECT_FAIL(sc) \ - ( (MHD_SC_OK != (sc)) ? (! 0) : \ - (ERR_PRINT_LINE (), \ - ((void) fprintf (stderr, "MHD function unexpectedly succeed.\n")), \ - (0)) ) - /* The test */ @@ -118,6 +108,7 @@ test_macro1_vs_macro2_str (void) printf ("Checking PACKAGE_VERSION macro vs VERSION macro.\n"); if (0 != strcmp (str_macro_pkg_ver, str_macro_ver)) { + fflush (stdout); fprintf (stderr, "'%s' vs '%s' - FAILED.\n", str_macro_pkg_ver, str_macro_ver); return 1; @@ -144,11 +135,13 @@ test_macro2_vs_func_str (void) "function.\n"); if (NULL == info_data.v_version_string.cstr) { + fflush (stdout); fprintf (stderr, "info_data.v_string.cstr is NULL.\n"); return 1; } if (0 != strcmp (str_macro_ver, info_data.v_version_string.cstr)) { + fflush (stdout); fprintf (stderr, "'%s' vs '%s' - FAILED.\n", str_macro_ver, info_data.v_version_string.cstr); return 1; @@ -187,12 +180,14 @@ test_func_str_vs_macro_bin (void) #endif /* ! HAVE_SNPRINTF */ if ((9 < res) || (0 >= res)) { + fflush (stdout); fprintf (stderr, "snprintf() error.\n"); exit (99); } if (0 != strcmp (info_data.v_version_string.cstr, bin_print)) { + fflush (stdout); fprintf (stderr, "'%s' vs '0x%08lX' ('%s') - FAILED.\n", info_data.v_version_string.cstr, (unsigned long) bin_macro, @@ -217,6 +212,7 @@ test_macro_vs_func_bin (void) "MHD_lib_get_info_ver_num() function.\n"); if (bin_macro != bin_func) { + fflush (stdout); fprintf (stderr, "'0x%08lX' vs '0x%08lX' - FAILED.\n", (unsigned long) bin_macro, (unsigned long) bin_func); return 1; @@ -240,6 +236,7 @@ test_func_bin_format (void) if ((0xA <= (test_byte & 0xF)) || (0xA <= (test_byte >> 4))) { + fflush (stdout); fprintf (stderr, "Invalid value in the first (most significant) byte: %02X\n", test_byte); @@ -249,6 +246,7 @@ test_func_bin_format (void) if ((0xA <= (test_byte & 0xF)) || (0xA <= (test_byte >> 4))) { + fflush (stdout); fprintf (stderr, "Invalid value in the second byte: %02X\n", test_byte); @@ -258,6 +256,7 @@ test_func_bin_format (void) if ((0xA <= (test_byte & 0xF)) || (0xA <= (test_byte >> 4))) { + fflush (stdout); fprintf (stderr, "Invalid value in the third byte: %02X\n", test_byte); @@ -265,6 +264,7 @@ test_func_bin_format (void) } if (0 != ret) { + fflush (stdout); fprintf (stderr, "The value (0x%08lX) returned by MHD_get_version_bin() " "function is invalid as it cannot be used as packed BCD form " @@ -296,6 +296,7 @@ test_func_str_format (void) if (ver_len != info_data.v_version_string.len) { + fflush (stdout); fprintf (stderr, "strlen(info_data.v_string.cstr) ('%lu') != " "info_data.v_string.len ('%lu') - FAILED.\n", @@ -333,6 +334,7 @@ main (int argc, char *argv[]) if (0 != num_err) { + fflush (stdout); fprintf (stderr, "Number of failed checks: %d\n", num_err); return 2; }