]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - testsuite/testsuite.h
testsuite: Add assert_return
[thirdparty/kmod.git] / testsuite / testsuite.h
index f2a75e5dd44266b19935861ca044c5ebff5f8733..47b72fd46955e17497c7fdf81950154024a713b9 100644 (file)
@@ -119,6 +119,16 @@ int test_run(const struct test *t);
 #define WARN(fmt, ...) _LOG("WARN: ", fmt, ## __VA_ARGS__)
 #define ERR(fmt, ...) _LOG("ERR: ", fmt, ## __VA_ARGS__)
 
+#define assert_return(expr, r)                                         \
+       do {                                                            \
+               if ((!(expr))) {                                        \
+                       ERR("Failed assertion: " #expr,                 \
+                           __FILE__, __LINE__, __PRETTY_FUNCTION__);   \
+                       return (r);                                     \
+               }                                                       \
+       } while (false)
+
+
 /* Test definitions */
 #define DEFINE_TEST(_name, ...) \
        const struct test s##_name = { \