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 /zephyr/shim/src/test_util.c | |
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 'zephyr/shim/src/test_util.c')
-rw-r--r-- | zephyr/shim/src/test_util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/zephyr/shim/src/test_util.c b/zephyr/shim/src/test_util.c new file mode 100644 index 0000000000..28be596043 --- /dev/null +++ b/zephyr/shim/src/test_util.c @@ -0,0 +1,20 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Test utilities. + */ + +#include "test_util.h" + +/* Linear congruential pseudo random number generator */ +uint32_t prng(uint32_t seed) +{ + return 22695477 * seed + 1; +} + +uint32_t prng_no_seed(void) +{ + static uint32_t seed = 0x1234abcd; + return seed = prng(seed); +} |