diff options
author | Paul Fagerburg <pfagerburg@google.com> | 2020-12-28 12:24:34 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-31 00:48:30 +0000 |
commit | 660dce8ec1e7a6545fbcd8832b9c415f22a2905f (patch) | |
tree | 6f350fb22e8c1931d71b4af562276656fbc558eb /include | |
parent | 4db453bdf95a7d38aae7c24aef2b1ca86833ae93 (diff) | |
download | chrome-ec-660dce8ec1e7a6545fbcd8832b9c415f22a2905f.tar.gz |
zephyr: improve shimming for unit tests
* Move the Ztest-related definitions out of test_util and into a
shim version of that header.
* Add definitions for EC unit tests declaring additional tasks so
the task shim will pick them up correctly.
* Copy the prng functions into the shimmed test_util.
BUG=None
BRANCH=None
TEST=`make clobber ; make buildall -j ; make runhosttests`
Then build the unit tests that have been ported to Ztest,
e.g. `zmake configure --test -B build/base32 zephyr/test/base32`
for `base32`, `crc`, `hooks`, `i2c`,and `tasks`
Signed-off-by: Paul Fagerburg <pfagerburg@google.com>
Change-Id: Ia2873a4c2028fcb6960e80f683189def2f3a228d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2605231
Tested-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Auto-Submit: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/test_util.h | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/include/test_util.h b/include/test_util.h index d33691a626..ef2ec0a48a 100644 --- a/include/test_util.h +++ b/include/test_util.h @@ -8,24 +8,6 @@ #ifndef __CROS_EC_TEST_UTIL_H #define __CROS_EC_TEST_UTIL_H -#ifdef CONFIG_ZTEST - -#include <ztest.h> - -/* - * We need these macros so that a test can be built for either Ztest or the - * EC test framework. - * - * Ztest unit tests are void and do not return a value. In the EC framework, - * if none of the assertions fail, the test is supposed to return EC_SUCCESS, - * so just define that as empty and `return EC_SUCCESS;` will get pre-processed - * into `return ;` - */ -#define EC_TEST_RETURN void -#define EC_SUCCESS - -#else /* CONFIG_ZTEST */ - #include "common.h" #include "console.h" #include "stack_trace.h" @@ -329,6 +311,9 @@ int test_attach_i2c(const int port, const uint16_t addr_flags); */ #define EC_TEST_RETURN int +/* An EC task only has one void parameter */ +#define TASK_PARAMS void *p1 + /* * Map the Ztest assertions onto EC assertions. There are two significant * issues here. @@ -354,6 +339,4 @@ int test_attach_i2c(const int port, const uint16_t addr_flags); #define zassert_mem_equal(buf, exp, size, msg, ...) \ TEST_ASSERT_ARRAY_EQ(buf, exp, size) -#endif /* CONFIG_ZTEST */ - #endif /* __CROS_EC_TEST_UTIL_H */ |