summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Michalec <tm@semihalf.com>2021-04-14 11:45:50 +0200
committerCommit Bot <commit-bot@chromium.org>2021-04-16 13:30:00 +0000
commit81000c24119562a425500a881950155b47a41af2 (patch)
treec8770b26307dccc963a0dffcbc978d009db8b130
parent862e4d0da76cc65bce9e934059c40ac7e64a94c5 (diff)
downloadchrome-ec-81000c24119562a425500a881950155b47a41af2.tar.gz
zephyr: test_util: Add TEST_SUITE macro
TEST_SUITE macro allows to define Zephyr test as test suite instead of test_main(). Test suite can be used as part of bigger test. BUG=b:185205123 BRANCH=none TEST=zmake testall TEST=make runhosttests Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I834ccf38e256c918623e96bb39597a0b22a874c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825910 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r--include/test_util.h6
-rw-r--r--test/cbi.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/include/test_util.h b/include/test_util.h
index ff2c99d950..a4daaf7f87 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -359,6 +359,10 @@ int test_attach_i2c(const int port, const uint16_t addr_flags);
* This macro uses the lowest common denominator of the two (Zephyr) so tests
* that migrate from platform/ec to Zephyr will no longer be able to use the
* arguments (compile time checked).
+ * TEST_SUITE(name) macro is resolved to TEST_MAIN in platform/ec tests.
+ * In Zephyr tests it allows to use different name for entry point than
+ * test_main(void). Because of that, it is possible to combine multiple test
+ * suites in one test.
*
* Usage:
* TEST_MAIN()
@@ -368,6 +372,7 @@ int test_attach_i2c(const int port, const uint16_t addr_flags);
*/
#ifdef CONFIG_ZEPHYR
#define TEST_MAIN() void test_main(void)
+#define TEST_SUITE(name) void name(void)
#else
#define TEST_MAIN() \
void test_main(void); \
@@ -378,6 +383,7 @@ int test_attach_i2c(const int port, const uint16_t addr_flags);
test_print_result(); \
} \
void test_main(void)
+#define TEST_SUITE(name) TEST_MAIN()
#endif
/*
diff --git a/test/cbi.c b/test/cbi.c
index 2096ebce5a..222128ce8d 100644
--- a/test/cbi.c
+++ b/test/cbi.c
@@ -268,7 +268,7 @@ DECLARE_EC_TEST(test_bad_crc)
return EC_SUCCESS;
}
-TEST_MAIN()
+TEST_SUITE(test_suite_cbi)
{
ztest_test_suite(test_cbi,
ztest_unit_test_setup_teardown(test_uint8, test_setup,