From: Dan Fandrich Date: Wed, 13 Sep 2023 18:31:16 +0000 (-0700) Subject: tests: log the test result code after each libtest X-Git-Tag: curl-8_4_0~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06cdfad49f98d997352251bc09b06abb7679b65d;p=thirdparty%2Fcurl.git tests: log the test result code after each libtest This makes it easier to determine the test status. Also, capitalize FAILURE and ABORT messages in log lines to make them easier to spot. --- diff --git a/tests/libtest/first.c b/tests/libtest/first.c index ba7fc3365e..7bd129ab34 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -172,6 +172,7 @@ int main(int argc, char **argv) fprintf(stderr, "URL: %s\n", URL); result = test(URL); + fprintf(stderr, "Test ended with result %d\n", result); #ifdef WIN32 /* flush buffers of all streams regardless of mode */ diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h index 7c0ac4fb1d..756f76e360 100644 --- a/tests/unit/curlcheck.h +++ b/tests/unit/curlcheck.h @@ -24,19 +24,19 @@ #include "test.h" /* The fail macros mark the current test step as failed, and continue */ -#define fail_if(expr, msg) \ - do { \ - if(expr) { \ - fprintf(stderr, "%s:%d Assertion '%s' met: %s\n", \ - __FILE__, __LINE__, #expr, msg); \ - unitfail++; \ - } \ +#define fail_if(expr, msg) \ + do { \ + if(expr) { \ + fprintf(stderr, "%s:%d FAILED Assertion '%s' met: %s\n", \ + __FILE__, __LINE__, #expr, msg); \ + unitfail++; \ + } \ } while(0) #define fail_unless(expr, msg) \ do { \ if(!(expr)) { \ - fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \ + fprintf(stderr, "%s:%d Assertion '%s' FAILED: %s\n", \ __FILE__, __LINE__, #expr, msg); \ unitfail++; \ } \ @@ -44,9 +44,9 @@ #define verify_memory(dynamic, check, len) \ do { \ - if(dynamic && memcmp(dynamic, check, len)) { \ - fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \ - __FILE__, __LINE__, len, \ + if(dynamic && memcmp(dynamic, check, len)) { \ + fprintf(stderr, "%s:%d Memory buffer FAILED match size %d. " \ + "'%s' is not\n", __FILE__, __LINE__, len, \ hexdump((const unsigned char *)check, len)); \ fprintf(stderr, "%s:%d the same as '%s'\n", __FILE__, __LINE__, \ hexdump((const unsigned char *)dynamic, len)); \ @@ -57,7 +57,7 @@ /* fail() is for when the test case figured out by itself that a check proved a failure */ #define fail(msg) do { \ - fprintf(stderr, "%s:%d test failed: '%s'\n", \ + fprintf(stderr, "%s:%d test FAILED: '%s'\n", \ __FILE__, __LINE__, msg); \ unitfail++; \ } while(0) @@ -67,7 +67,7 @@ #define abort_if(expr, msg) \ do { \ if(expr) { \ - fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n", \ + fprintf(stderr, "%s:%d ABORT assertion '%s' met: %s\n", \ __FILE__, __LINE__, #expr, msg); \ unitfail++; \ goto unit_test_abort; \ @@ -77,7 +77,7 @@ #define abort_unless(expr, msg) \ do { \ if(!(expr)) { \ - fprintf(stderr, "%s:%d Abort assertion '%s' failed: %s\n", \ + fprintf(stderr, "%s:%d ABORT assertion '%s' failed: %s\n", \ __FILE__, __LINE__, #expr, msg); \ unitfail++; \ goto unit_test_abort; \ @@ -86,7 +86,7 @@ #define abort_test(msg) \ do { \ - fprintf(stderr, "%s:%d test aborted: '%s'\n", \ + fprintf(stderr, "%s:%d test ABORTED: '%s'\n", \ __FILE__, __LINE__, msg); \ unitfail++; \ goto unit_test_abort; \ @@ -100,7 +100,7 @@ extern int unitfail; { \ (void)arg; \ if(unit_setup()) { \ - fail("unit_setup() failure"); \ + fail("unit_setup() FAILURE"); \ } \ else {