Blame SOURCES/0233-testsuite-assert-for-common-function-results.patch

872084
From 6e854f3c2c159ccb25f76bed3dbcecafbee8fb34 Mon Sep 17 00:00:00 2001
872084
From: Jakub Filak <jfilak@redhat.com>
872084
Date: Fri, 8 Apr 2016 08:47:05 +0200
872084
Subject: [PATCH] testsuite: assert for common function results
872084
872084
Signed-off-by: Jakub Filak <jfilak@redhat.com>
872084
---
872084
 tests/helpers/testsuite.h | 22 +++++++++++++++++++++-
872084
 1 file changed, 21 insertions(+), 1 deletion(-)
872084
872084
diff --git a/tests/helpers/testsuite.h b/tests/helpers/testsuite.h
872084
index bc7abf1d..809edbc6 100644
872084
--- a/tests/helpers/testsuite.h
872084
+++ b/tests/helpers/testsuite.h
872084
@@ -217,7 +217,7 @@ FILE *g_testsuite_output_stream = 0;
872084
         const char *l_ts_lhs = (actual); \
872084
         const char *l_ts_rhs = (expected); \
872084
         if (l_ts_lhs == NULL && l_ts_rhs != NULL) { \
872084
-            TS_FAILURE("%s ("#actual" == "#expected")\n\tActual  : NULL\n\tExpected: %p\n", message ? message : "Assert", l_ts_rhs); \
872084
+            TS_FAILURE("%s ("#actual" == "#expected")\n\tActual  : NULL\n\tExpected: %s\n", message ? message : "Assert", l_ts_rhs); \
872084
         } \
872084
         else if (l_ts_lhs != NULL && l_ts_rhs == NULL) { \
872084
             TS_FAILURE("%s ("#actual" == "#expected")\n\tActual  : %s\n\tExpected: NULL\n", message ? message : "Assert", l_ts_lhs); \
872084
@@ -307,4 +307,24 @@ FILE *g_testsuite_output_stream = 0;
872084
     TS_ASSERT_PTR_OP_MESSAGE(actual, ==, expected, NULL);
872084
 
872084
 
872084
+
872084
+/*
872084
+ * Standard functions returning non-0 on errors
872084
+ */
872084
+
872084
+#define TS_ASSERT_FUNCTION_MESSAGE(call, message) \
872084
+    do { \
872084
+        const int l_ts_lhs = call; \
872084
+        if (l_ts_lhs == 0) { \
872084
+            TS_SUCCESS("%s ('"#call"')\n", message ? message : "Function SUCCEEDED"); \
872084
+        } \
872084
+        else { \
872084
+            TS_FAILURE("%s ('"#call"')\n\tCode  : %d\n", message ? message : "Function FAILED", l_ts_lhs); \
872084
+        } \
872084
+    } while(0)
872084
+
872084
+
872084
+#define TS_ASSERT_FUNCTION(call) \
872084
+    TS_ASSERT_FUNCTION_MESSAGE(call, NULL)
872084
+
872084
 #endif/*LIBREPORT_TESTSUITE_H*/
872084
-- 
872084
2.17.2
872084