UT_ASSERT_M() just prints the message verbatim.  Its va_args are cleanup
routines.  UT_ASSERT_FMT() takes a format string, and its va_args is the
values for the format string.

Signed-off-by: Barret Rhoden <[email protected]>
---
 user/utest/include/utest.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/user/utest/include/utest.h b/user/utest/include/utest.h
index 646e492441ce..ceddcb662692 100644
--- a/user/utest/include/utest.h
+++ b/user/utest/include/utest.h
@@ -32,6 +32,19 @@ __BEGIN_DECLS
                }                                                               
         \
        } while (0)
 
+
+/* If 'test' fails, Sets an assert message, which can be a format string, and
+ * returns false. */
+#define UT_ASSERT_FMT(message, test, ...)                                      
\
+       do {                                                                    
   \
+               if (!(test)) {                                                  
       \
+                       char fmt[] = "Assertion failure in %s() at %s:%d: " 
#message;      \
+                       sprintf(utest_msg, fmt, __func__, __FILE__, __LINE__,   
           \
+                               ##__VA_ARGS__);                                 
           \
+                       return false;                                           
           \
+               }                                                               
       \
+       } while (0)
+
 /*
  * Structs and macros for registering test cases.
  */
-- 
2.6.0.rc2.230.g3dd15c0

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to