tests: mem_protect/mem_protect: fix number of kobjects to test

In test_kobject_perm_error, there are 13 kobjects to test but
the loop only do 12. So amend the code to test all 13 kobjects.

Also remove the parameter of tid to child thread as the child
thread is not using it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2023-09-12 13:54:05 -07:00 committed by Carles Cufí
commit 4bebb65491

View file

@ -1333,8 +1333,7 @@ struct k_condvar condvar;
static void entry_error_perm(void *p1, void *p2, void *p3) static void entry_error_perm(void *p1, void *p2, void *p3)
{ {
set_fault_valid(true); set_fault_valid(true);
k_object_access_grant(p2, k_current_get()); k_object_access_grant(p1, k_current_get());
} }
/** /**
@ -1350,7 +1349,9 @@ static void entry_error_perm(void *p1, void *p2, void *p3)
*/ */
ZTEST(mem_protect_kobj, test_kobject_perm_error) ZTEST(mem_protect_kobj, test_kobject_perm_error)
{ {
void *kobj[16]; #define NUM_KOBJS 13
void *kobj[NUM_KOBJS];
kobj[0] = &ms; kobj[0] = &ms;
kobj[1] = &mq; kobj[1] = &mq;
@ -1366,16 +1367,18 @@ ZTEST(mem_protect_kobj, test_kobject_perm_error)
kobj[11] = &f; kobj[11] = &f;
kobj[12] = &condvar; kobj[12] = &condvar;
for (int i = 0; i < 12 ; i++) { for (int i = 0; i < NUM_KOBJS; i++) {
k_tid_t tid = k_thread_create(&child_thread, child_stack, k_tid_t tid = k_thread_create(&child_thread, child_stack,
K_THREAD_STACK_SIZEOF(child_stack), K_THREAD_STACK_SIZEOF(child_stack),
(k_thread_entry_t)entry_error_perm, (k_thread_entry_t)entry_error_perm,
(void *)&tid, kobj[i], NULL, kobj[i], NULL, NULL,
1, K_USER, K_NO_WAIT); 1, K_USER, K_NO_WAIT);
k_thread_join(tid, K_FOREVER); k_thread_join(tid, K_FOREVER);
} }
#undef NUM_KOBJS
} }
extern const char *otype_to_str(enum k_objects otype); extern const char *otype_to_str(enum k_objects otype);