diff options
author | Yicheng Li <yichengli@chromium.org> | 2020-06-11 18:17:42 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-15 04:48:51 +0000 |
commit | 7fcbf4757ac5298031d1723f136e08ca0c8a4ebc (patch) | |
tree | 469f09e55843351dfd606d09dfe593afcf003a09 /test/utils.c | |
parent | 58732e1f79886bd816e7000159d00f8c90c30f82 (diff) | |
download | chrome-ec-7fcbf4757ac5298031d1723f136e08ca0c8a4ebc.tar.gz |
test: Let shared_mem test support shmalloc implementation
There are 2 implementations of shared_mem, an older one in
common/share_mem.c and a newer one in common/shmalloc.c
The newer one in shmalloc.c has higher quality, but will only
be linked if CONFIG_MALLOC is configured. We would like to
make the "utils" unit tests use shmalloc.c (for host and boards
that run this test on-device). The shared_mem_acquire function
in shmalloc.c sets the the buffer pointer to NULL on error, so
the part of test_shared_mem that intentionally triggers an error
must use a different pointer.
After this change, this test can pass for both implementations.
There will be follow-up changes that switch boards to use the shmalloc
implementation, including the test on host.
BRANCH=none
BUG=b:155230812
TEST=verified that test_shared_mem and test_shared_mem_acquire_twice
pass on bloonchipper (which uses shmalloc implementation).
Signed-off-by: Yicheng Li <yichengli@chromium.org>
Change-Id: Ic839cb841b4232a956882b0f9451b6f6861efcac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242354
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'test/utils.c')
-rw-r--r-- | test/utils.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/utils.c b/test/utils.c index 061e10b87b..c46b6ab192 100644 --- a/test/utils.c +++ b/test/utils.c @@ -235,19 +235,19 @@ static int test_shared_mem(void) { int i; int sz = shared_mem_size(); - char *mem; + char *mem1, *mem2; - TEST_ASSERT(shared_mem_acquire(sz, &mem) == EC_SUCCESS); - TEST_ASSERT(shared_mem_acquire(sz, &mem) == EC_ERROR_BUSY); + TEST_ASSERT(shared_mem_acquire(sz, &mem1) == EC_SUCCESS); + TEST_ASSERT(shared_mem_acquire(sz, &mem2) == EC_ERROR_BUSY); for (i = 0; i < 256; ++i) { - memset(mem, i, sz); - TEST_ASSERT_MEMSET(mem, (char)i, sz); + memset(mem1, i, sz); + TEST_ASSERT_MEMSET(mem1, (char)i, sz); if ((i & 0xf) == 0) msleep(20); /* Yield to other tasks */ } - shared_mem_release(mem); + shared_mem_release(mem1); return EC_SUCCESS; } |