Skip to content
Permalink
Browse files

tests: userspace: cover z_object_recycle()

We didn't have code coverage for this function anywhere
except indirectly through some network tests; exercise it
in the suite of userspace tests.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information...
andrewboie committed Jun 24, 2019
1 parent d053ba5 commit 848221812f885860b657af66246149959cc89db2
Showing with 25 additions and 1 deletion.
  1. +25 −1 tests/kernel/mem_protect/userspace/src/main.c
@@ -1108,6 +1108,29 @@ void test_bad_syscall(void)

}

static struct k_sem recycle_sem;


void test_object_recycle(void)
{
struct _k_object *ko;
int perms_count = 0;

ko = z_object_find(&recycle_sem);
(void)memset(ko->perms, 0xFF, sizeof(ko->perms));

z_object_recycle(&recycle_sem);
zassert_true(ko != NULL, "kernel object not found");
zassert_true(ko->flags & K_OBJ_FLAG_INITIALIZED,
"object wasn't marked as initialized");

for (int i = 0; i < CONFIG_MAX_THREAD_BYTES; i++) {
perms_count += popcount(ko->perms[i]);
}

zassert_true(perms_count == 1, "invalid number of thread permissions");
}

void test_main(void)
{
struct k_mem_partition *parts[] = {&part0, &part1,
@@ -1159,7 +1182,8 @@ void test_main(void)
ztest_unit_test(domain_remove_thread_context_switch),
ztest_unit_test(test_stack_buffer),
ztest_user_unit_test(test_unimplemented_syscall),
ztest_user_unit_test(test_bad_syscall)
ztest_user_unit_test(test_bad_syscall),
ztest_unit_test(test_object_recycle)
);
ztest_run_test_suite(userspace);
}

0 comments on commit 8482218

Please sign in to comment.
You can’t perform that action at this time.