trusty_unittest: Use shared implementation with kernel
Bug: 122921645
Change-Id: Iddf1fcd02aef7a32e14c481980a8fef5072b46a5
diff --git a/include/user/trusty_unittest.h b/include/user/trusty_unittest.h
index b5d67f7..0e5778d 100644
--- a/include/user/trusty_unittest.h
+++ b/include/user/trusty_unittest.h
@@ -21,112 +21,10 @@
#include <stdio.h>
#include <trusty_log.h>
-static unsigned int _tests_total = 0; /* Number of conditions checked */
-static unsigned int _tests_failed = 0; /* Number of conditions failed */
-
-/*
- * Begin and end test macro
- */
-#define TEST_BEGIN(name) \
- bool _all_ok = true; \
- const char* _test = name; \
- TLOGI("%s:\n", _test);
-
-#define TEST_END \
- { \
- if (_all_ok) \
- TLOGI("%s: PASSED\n", _test); \
- else \
- TLOGI("%s: FAILED\n", _test); \
- }
-
-/*
- * EXPECT_* macros to check test results.
- */
-#define EXPECT_EQ(expected, actual, msg) \
- { \
- __typeof__(actual) _e = expected; \
- __typeof__(actual) _a = actual; \
- _tests_total++; \
- if (_e != _a) { \
- TLOGI("%s: expected " #expected \
- " (%ld), " \
- "actual " #actual " (%ld)\n", \
- msg, (long)_e, (long)_a); \
- _tests_failed++; \
- _all_ok = false; \
- } \
- }
-
-#define EXPECT_NE(expected, actual, msg) \
- { \
- __typeof__(actual) _e = expected; \
- __typeof__(actual) _a = actual; \
- _tests_total++; \
- if (_e == _a) { \
- TLOGI("%s: expected not " #expected \
- " (%ld), " \
- "actual " #actual " (%ld)\n", \
- msg, (long)_e, (long)_a); \
- _tests_failed++; \
- _all_ok = false; \
- } \
- }
-
-#define EXPECT_GT(expected, actual, msg) \
- { \
- __typeof__(actual) _e = expected; \
- __typeof__(actual) _a = actual; \
- _tests_total++; \
- if (_e <= _a) { \
- TLOGI("%s: expected " #expected \
- " (%ld), " \
- "actual " #actual " (%ld)\n", \
- msg, (long)_e, (long)_a); \
- _tests_failed++; \
- _all_ok = false; \
- } \
- }
-
-#define EXPECT_GE_ZERO(actual, msg) \
- { \
- __typeof__(actual) _a = actual; \
- _tests_total++; \
- if (_a < 0) { \
- TLOGI("%s: expected >= 0 " \
- "actual " #actual " (%ld)\n", \
- msg, (long)_a); \
- _tests_failed++; \
- _all_ok = false; \
- } \
- }
-
-#define EXPECT_GT_ZERO(actual, msg) \
- { \
- __typeof__(actual) _a = actual; \
- _tests_total++; \
- if (_a <= 0) { \
- TLOGI("%s: expected > 0 " \
- "actual " #actual " (%ld)\n", \
- msg, (long)_a); \
- _tests_failed++; \
- _all_ok = false; \
- } \
- }
-
-#define ASSERT_ALL_OK() \
- if (!_all_ok) { \
- goto test_abort; \
- }
-
-#define ASSERT_EQ(e, a) \
- do { \
- EXPECT_EQ(e, a, ""); \
- ASSERT_ALL_OK(); \
+#define trusty_unittest_printf(args...) \
+ do { \
+ fprintf(stderr, args); \
+ unittest_printf(args); \
} while (0)
-#define ASSERT_NE(e, a) \
- do { \
- EXPECT_NE(e, a, ""); \
- ASSERT_ALL_OK(); \
- } while (0)
+#include <lk/trusty_unittest.h>