From d76cfad42a29b94c129c8e48b145e61ebd03b183 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 9 Mar 2010 12:19:59 +0100 Subject: Add unittest module --- unittest/unittest.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 unittest/unittest.h (limited to 'unittest/unittest.h') diff --git a/unittest/unittest.h b/unittest/unittest.h new file mode 100644 index 0000000..0ed005f --- /dev/null +++ b/unittest/unittest.h @@ -0,0 +1,40 @@ +#ifndef _UNITTEST_H_ +#define _UNITTEST_H_ + +#include +#include +#include "stringify.h" + +#define TEST_PASS 0 +#define TEST_FAIL 1 + +#define assert_err(fmt, args...) \ + fprintf(stderr, "%s:%d: Assertion error: " fmt, __FILE__, __LINE__, ##args) + +/* Assert the expression 'expr' */ +#define test_assert(expr) ({if (!(expr)) { \ + assert_err(__stringify(expr) "\n"); \ + exit(TEST_FAIL); \ + }}) + +/* Assert the expression 'expr' and print 'msg' on fail */ +#define test_assert_msg(expr, msg) ({if (!(expr)) { \ + assert_err(msg "\n"); \ + exit(TEST_FAIL); \ + }}) + +/* Assert that a == b */ +#define test_assert_eq(a, b) ({ \ + if ((a) != (b)) { \ + assert_err(__stringify(a) " != " __stringify(b) "\n"); \ + exit(TEST_FAIL); \ + }}) + +/* Assert that a != b */ +#define test_assert_neq(a, b) ({ \ + if ((a) == (b)) { \ + assert_err(__stringify(a) " != " __stringify(b) "\n"); \ + exit(TEST_FAIL); \ + }}) + +#endif /* _UNITTEST_H_ */ -- cgit v1.2.3-54-g00ecf Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Marsh <bmarsh94@gmail.com>2016-04-24 20:16:02 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-04-29 17:40:50 -0700
commit9fea19a9a4bb22a237972d50e41219ddd479ea22 (patch)
tree946f29aa865f596a16e6e9de715c2d88b498dc46
parent0045c8ddd6965e15f638788e7180abe8765f6cbb (diff)
Staging: android: modify memory allocation style in ion_test.c
Modifies the memory allocation style ion_test.c in order to remove a checkpatch.pl warning Signed-off-by: Ben Marsh <bmarsh94@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>