tests: kernel: mem_slab: Add no multithreading support
Extended mslab_api test suite with CONFIG_MULTITHREADING=n configuration. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
e99a015ba3
commit
693c3fbb9d
2 changed files with 22 additions and 10 deletions
|
@ -63,6 +63,7 @@ static void tmslab_alloc_timeout(void *data)
|
|||
struct k_mem_slab *pslab = (struct k_mem_slab *)data;
|
||||
void *block[BLK_NUM], *block_fail;
|
||||
int64_t tms;
|
||||
int err;
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
zassert_true(k_mem_slab_alloc(pslab, &block[i], K_NO_WAIT) == 0,
|
||||
|
@ -73,16 +74,21 @@ static void tmslab_alloc_timeout(void *data)
|
|||
/** TESTPOINT: -ENOMEM Returned without waiting.*/
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_NO_WAIT), -ENOMEM,
|
||||
NULL);
|
||||
/** TESTPOINT: -EAGAIN Waiting period timed out*/
|
||||
tms = k_uptime_get();
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_MSEC(TIMEOUT)),
|
||||
-EAGAIN,
|
||||
NULL);
|
||||
/**
|
||||
* TESTPOINT: timeout Maximum time to wait for operation to
|
||||
* complete (in milliseconds)
|
||||
*/
|
||||
zassert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL);
|
||||
err = k_mem_slab_alloc(pslab, &block_fail, K_MSEC(TIMEOUT));
|
||||
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
|
||||
/** TESTPOINT: -EAGAIN Waiting period timed out*/
|
||||
zassert_equal(err, -EAGAIN, NULL);
|
||||
/**
|
||||
* TESTPOINT: timeout Maximum time to wait for operation to
|
||||
* complete (in milliseconds)
|
||||
*/
|
||||
zassert_true(k_uptime_delta(&tms) >= TIMEOUT, NULL);
|
||||
} else {
|
||||
/* If no multithreading any timeout is treated as K_NO_WAIT */
|
||||
zassert_equal(err, -ENOMEM, NULL);
|
||||
zassert_true(k_uptime_delta(&tms) < TIMEOUT, NULL);
|
||||
}
|
||||
|
||||
for (int i = 0; i < BLK_NUM; i++) {
|
||||
k_mem_slab_free(pslab, &block[i]);
|
||||
|
@ -113,7 +119,7 @@ static void tmslab_used_get(void *data)
|
|||
zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL);
|
||||
|
||||
zassert_equal(k_mem_slab_alloc(pslab, &block_fail, K_MSEC(TIMEOUT)),
|
||||
-EAGAIN,
|
||||
IS_ENABLED(CONFIG_MULTITHREADING) ? -EAGAIN : -ENOMEM,
|
||||
NULL);
|
||||
zassert_equal(k_mem_slab_num_free_get(pslab), 0, NULL);
|
||||
zassert_equal(k_mem_slab_num_used_get(pslab), BLK_NUM, NULL);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
tests:
|
||||
kernel.memory_slabs.api:
|
||||
tags: kernel
|
||||
kernel.memory_slabs.api_no_multithreading:
|
||||
tags: kernel
|
||||
platform_allow: qemu_cortex_m3 qemu_cortex_m0
|
||||
extra_configs:
|
||||
- CONFIG_MULTITHREADING=n
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue