diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2014-06-06 02:19:01 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2014-06-06 02:19:28 -0300 |
commit | 30471c80a48fc6888b9359056226438e5d2482ca (patch) | |
tree | f51b340585120aa12d88be374c2ce12c7592c5dc | |
parent | f988e25c6864a9467eb53262cbd718752204f80f (diff) | |
download | kmod-30471c80a48fc6888b9359056226438e5d2482ca.tar.gz kmod-30471c80a48fc6888b9359056226438e5d2482ca.tar.bz2 kmod-30471c80a48fc6888b9359056226438e5d2482ca.zip |
testsuite: Add assert_return
Add assert_return to use in testcases instead of assert. The issues
with assert are:
1) It's disabled when NDEBUG is defined
2) Even if it's well supported by testsuite (the parent will
report the child died) it can't output any meaningful
error message
-rw-r--r-- | testsuite/testsuite.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h index f2a75e5..47b72fd 100644 --- a/testsuite/testsuite.h +++ b/testsuite/testsuite.h @@ -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 = { \ |