Update utest infrastructure
authorKevin Klues <klueska@cs.berkeley.edu>
Thu, 15 Oct 2015 05:19:57 +0000 (22:19 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 15 Oct 2015 16:07:00 +0000 (12:07 -0400)
Updated to allow passing of continuation to run in the case of an assert
failure. Also, we now print the actual test performed in an assert in
the case when no message is passed in.

Signed-off-by: Kevin Klues <klueska@cs.berkeley.edu>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/utest/include/utest.h

index c6ea6cf..8e4c357 100644 (file)
@@ -20,14 +20,15 @@ __BEGIN_DECLS
 /* 
  * Macros for assertions. 
  */
-#define UT_ASSERT(test)                                                          \
-       UT_ASSERT_M("", test)
+#define UT_ASSERT(test, ...)                                                     \
+       UT_ASSERT_M(#test, test, __VA_ARGS__)
 
-#define UT_ASSERT_M(message, test)                                               \
+#define UT_ASSERT_M(message, test, ...)                                               \
        do {                                                                         \
                if (!(test)) {                                                           \
                        char fmt[] = "Assertion failure in %s() at %s:%d: %s";               \
                        sprintf(utest_msg, fmt, __FUNCTION__, __FILE__, __LINE__, message);  \
+                       __VA_ARGS__;                                                         \
                        return false;                                                        \
                }                                                                        \
        } while (0)