]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: log the test result code after each libtest
authorDan Fandrich <dan@coneharvesters.com>
Wed, 13 Sep 2023 18:31:16 +0000 (11:31 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 16 Sep 2023 15:33:45 +0000 (08:33 -0700)
This makes it easier to determine the test status. Also, capitalize
FAILURE and ABORT messages in log lines to make them easier to spot.

tests/libtest/first.c
tests/unit/curlcheck.h

index ba7fc3365e43e0666746d053b478f7cf94bb6894..7bd129ab3441d6e118269d9dabdba2ae56454bca 100644 (file)
@@ -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 */
index 7c0ac4fb1da531a007f4524217bea8219f81cb66..756f76e3604c800973f86183b7975aa2f451d300 100644 (file)
 #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 {