Add new macro fail_msg
authorPavel Březina <pbrezina@redhat.com>
Wed, 17 Jul 2013 09:07:39 +0000 (11:07 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 18 Jul 2013 09:07:05 +0000 (11:07 +0200)
Signed-off-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
include/cmocka.h

index 372e134..02757ef 100644 (file)
@@ -1246,6 +1246,18 @@ void fail(void);
 
 #ifdef DOXYGEN
 /**
+ * @brief Forces the test to fail immediately and quit, printing the reason.
+ */
+void fail_msg(const char *msg, ...);
+#else
+#define fail_msg(msg, ...) do { \
+    print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
+    fail(); \
+} while (0)
+#endif
+
+#ifdef DOXYGEN
+/**
  * @brief Generic method to run a single test.
  *
  * @param[in]  #function The function to test.