Skip to content

Commit

Permalink
tests: Updated all the tests which use k_thread_access_grant.
Browse files Browse the repository at this point in the history
With the new implementation we do not need a NULL terminated list
of kobjects. Therefore the list will only contain valid entries
of kobjects.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
  • Loading branch information
AdithyaBaglody committed Jan 3, 2019
1 parent 18dd538 commit 35ca98d
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 49 deletions.
8 changes: 4 additions & 4 deletions samples/userspace/shared_mem/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void main(void)

k_tid_t tPT, tENC, tCT;

k_thread_access_grant(k_current_get(), &allforone, NULL);
k_thread_access_grant(k_current_get(), &allforone);
/* initialize the partition structures */
FOR_EACH(appmem_init_part, part0, part1, part2, part3, part4);

Expand All @@ -117,7 +117,7 @@ void main(void)
(k_thread_entry_t)enc, NULL, NULL, NULL,
-1, K_USER,
K_FOREVER);
k_thread_access_grant(tENC, &allforone, NULL);
k_thread_access_grant(tENC, &allforone);
/* use K_FOREVER followed by k_thread_start*/
printk("ENC Thread Created %08X\n", (unsigned int) tENC);
appmem_init_domain_dom1(part2);
Expand All @@ -133,7 +133,7 @@ void main(void)
(k_thread_entry_t)pt, NULL, NULL, NULL,
-1, K_USER,
K_FOREVER);
k_thread_access_grant(tPT, &allforone, NULL);
k_thread_access_grant(tPT, &allforone);
printk("PT Thread Created %08X\n", (unsigned int) tPT);
appmem_init_domain_dom0(part0);
appmem_add_part_dom0(part1);
Expand All @@ -144,7 +144,7 @@ void main(void)
(k_thread_entry_t)ct, NULL, NULL, NULL,
-1, K_USER,
K_FOREVER);
k_thread_access_grant(tCT, &allforone, NULL);
k_thread_access_grant(tCT, &allforone);
printk("CT Thread Created %08X\n", (unsigned int) tCT);
appmem_init_domain_dom2(part4);
appmem_add_part_dom2(part3);
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/timing_info/src/userspace_bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void validation_overhead_user_thread(void *p1, void *p2, void *p3)
void validation_overhead(void)
{

k_thread_access_grant(k_current_get(), &test_sema, NULL);
k_thread_access_grant(k_current_get(), &test_sema);


k_thread_create(&my_thread_user, my_stack_area, STACK_SIZE,
Expand Down
3 changes: 1 addition & 2 deletions tests/drivers/i2s/i2s_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ void test_main(void)

k_thread_access_grant(k_current_get(),
&rx_0_mem_slab, &tx_0_mem_slab,
&rx_1_mem_slab, &tx_1_mem_slab,
NULL);
&rx_1_mem_slab, &tx_1_mem_slab);
dev_i2s = device_get_binding(I2S_DEV_NAME);
if (dev_i2s != NULL) {
k_object_access_grant(dev_i2s, k_current_get());
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/alert/alert_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ void test_main(void)
&thread_alerts[HANDLER_DEFAULT],
&thread_alerts[HANDLER_IGNORE],
&thread_alerts[HANDLER_0],
&thread_alerts[HANDLER_1], NULL);
&thread_alerts[HANDLER_1]);

k_alert_init(&thread_alerts[HANDLER_DEFAULT], K_ALERT_DEFAULT,
PENDING_MAX);
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/mem_pool/sys_mem_pool/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void test_sys_mem_pool_min_block_size(void)
/*test case main entry*/
void test_main(void)
{
k_thread_access_grant(k_current_get(), &pool_mutex, NULL);
k_thread_access_grant(k_current_get(), &pool_mutex);
sys_mem_pool_init(&pool);

ztest_test_suite(test_sys_mem_pool_api,
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/mem_protect/mem_protect/src/inherit.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void test_permission_inheritance(void *p1, void *p2, void *p3)
&inherit_sem,
&inherit_mutex,
&inherit_timer,
&inherit_msgq, &test_1_stack, NULL);
&inherit_msgq, &test_1_stack);

k_thread_create(&test_1_tid,
test_1_stack,
Expand Down
34 changes: 17 additions & 17 deletions tests/kernel/mem_protect/mem_protect/src/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void test_kobject_access_grant(void *p1, void *p2, void *p3)
k_thread_access_grant(k_current_get(),
&kobject_sem,
&kobject_mutex,
random_sem_type, NULL);
random_sem_type);

k_thread_user_mode_enter(kobject_user_tc1, NULL, NULL, NULL);

Expand Down Expand Up @@ -93,7 +93,7 @@ void test_syscall_invalid_kobject(void *p1, void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_sem,
&kobject_mutex, NULL);
&kobject_mutex);

k_thread_user_mode_enter(kobject_user_tc2, NULL, NULL, NULL);

Expand All @@ -118,7 +118,7 @@ void kobject_user_tc3(void *p1, void *p2, void *p3)
void test_thread_without_kobject_permission(void *p1, void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_mutex, NULL);
&kobject_mutex);

k_thread_user_mode_enter(kobject_user_tc3, NULL, NULL, NULL);

Expand Down Expand Up @@ -147,7 +147,7 @@ void kobject_user_test4(void *p1, void *p2, void *p3)
void test_kobject_revoke_access(void *p1, void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_sem, NULL);
&kobject_sem);

k_thread_create(&kobject_test_4_tid,
kobject_stack_1,
Expand Down Expand Up @@ -204,7 +204,7 @@ void kobject_user_2_test5(void *p1, void *p2, void *p3)
void test_kobject_grant_access_kobj(void *p1, void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_sem, &kobject_test_reuse_2_tid, NULL);
&kobject_sem, &kobject_test_reuse_2_tid);

k_thread_create(&kobject_test_reuse_1_tid,
kobject_stack_1,
Expand Down Expand Up @@ -255,7 +255,7 @@ void kobject_user_test6(void *p1, void *p2, void *p3)
void test_kobject_grant_access_kobj_invalid(void *p1, void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_sem, NULL);
&kobject_sem);

k_thread_create(&kobject_test_6_tid,
kobject_stack_3,
Expand Down Expand Up @@ -294,7 +294,7 @@ void kobject_user_test7(void *p1, void *p2, void *p3)
void test_kobject_release_from_user(void *p1, void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_sem, NULL);
&kobject_sem);

k_thread_create(&kobject_test_7_tid,
kobject_stack_1,
Expand Down Expand Up @@ -394,7 +394,7 @@ void test_thread_has_residual_permissions(void *p1, void *p2, void *p3)
{

k_thread_access_grant(k_current_get(),
&kobject_sem, NULL);
&kobject_sem);

k_thread_create(&kobject_test_9_tid,
kobject_stack_1,
Expand Down Expand Up @@ -503,7 +503,7 @@ void test_access_kobject_without_init_with_access(void *p1,
void *p2, void *p3)
{
k_thread_access_grant(k_current_get(),
&kobject_sem_no_init_access, NULL);
&kobject_sem_no_init_access);

k_thread_create(&kobject_test_13_tid,
kobject_stack_1,
Expand Down Expand Up @@ -589,7 +589,7 @@ void test_create_new_thread_from_user(void *p1, void *p2, void *p3)

k_thread_access_grant(&kobject_test_reuse_3_tid,
&kobject_test_reuse_4_tid,
&kobject_stack_2, NULL);
&kobject_stack_2);

k_thread_create(&kobject_test_reuse_3_tid,
kobject_stack_1,
Expand Down Expand Up @@ -639,7 +639,7 @@ void test_create_new_thread_from_user_no_access_stack(void *p1,
{

k_thread_access_grant(&kobject_test_reuse_5_tid,
&kobject_test_reuse_6_tid, NULL);
&kobject_test_reuse_6_tid);

k_thread_create(&kobject_test_reuse_5_tid,
kobject_stack_1,
Expand Down Expand Up @@ -689,7 +689,7 @@ void test_create_new_thread_from_user_invalid_stacksize(void *p1,

k_thread_access_grant(&kobject_test_reuse_1_tid,
&kobject_test_reuse_2_tid,
&kobject_stack_3, NULL);
&kobject_stack_3);

k_thread_create(&kobject_test_reuse_1_tid,
kobject_stack_3,
Expand Down Expand Up @@ -749,7 +749,7 @@ void test_create_new_thread_from_user_huge_stacksize(void *p1,

k_thread_access_grant(&kobject_test_reuse_3_tid,
&kobject_test_reuse_4_tid,
&kobject_stack_2, NULL);
&kobject_stack_2);

k_thread_create(&kobject_test_reuse_3_tid,
kobject_stack_1,
Expand Down Expand Up @@ -801,7 +801,7 @@ void test_create_new_supervisor_thread_from_user(void *p1, void *p2, void *p3)
{
k_thread_access_grant(&kobject_test_reuse_7_tid,
&kobject_test_reuse_8_tid,
&kobject_stack_2, NULL);
&kobject_stack_2);

k_thread_create(&kobject_test_reuse_7_tid,
kobject_stack_1,
Expand Down Expand Up @@ -847,7 +847,7 @@ void test_create_new_essential_thread_from_user(void *p1, void *p2, void *p3)
{
k_thread_access_grant(&kobject_test_reuse_1_tid,
&kobject_test_reuse_2_tid,
&kobject_stack_2, NULL);
&kobject_stack_2);

k_thread_create(&kobject_test_reuse_1_tid,
kobject_stack_1,
Expand Down Expand Up @@ -896,7 +896,7 @@ void test_create_new_higher_prio_thread_from_user(void *p1, void *p2, void *p3)
{
k_thread_access_grant(&kobject_test_reuse_3_tid,
&kobject_test_reuse_4_tid,
&kobject_stack_2, NULL);
&kobject_stack_2);

k_thread_create(&kobject_test_reuse_3_tid,
kobject_stack_1,
Expand Down Expand Up @@ -945,7 +945,7 @@ void test_create_new_invalid_prio_thread_from_user(void *p1, void *p2, void *p3)
{
k_thread_access_grant(&kobject_test_reuse_5_tid,
&kobject_test_reuse_6_tid,
&kobject_stack_2, NULL);
&kobject_stack_2);


k_thread_create(&kobject_test_reuse_5_tid,
Expand Down
3 changes: 1 addition & 2 deletions tests/kernel/mem_protect/userspace/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,7 @@ void test_main(void)
&kthread_thread, &kthread_stack,
&uthread_thread, &uthread_stack,
&uthread_start_sem, &uthread_end_sem,
&test_revoke_sem, &kpipe, &expect_fault_sem,
NULL);
&test_revoke_sem, &kpipe, &expect_fault_sem);
ztest_test_suite(userspace,
ztest_user_unit_test(is_usermode),
ztest_user_unit_test(write_control),
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/msgq/msgq_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ K_THREAD_STACK_EXTERN(tstack);
void test_main(void)
{
k_thread_access_grant(k_current_get(), &kmsgq, &msgq, &end_sema,
&tdata, &tstack, NULL);
&tdata, &tstack);

k_thread_resource_pool_assign(k_current_get(), &test_pool);

Expand Down
4 changes: 2 additions & 2 deletions tests/kernel/mutex/mutex/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ void test_main(void)
{
k_thread_access_grant(k_current_get(), &private_mutex,
&mutex_1, &mutex_2, &mutex_3, &mutex_4,
&thread_12_thread_data, &thread_12_stack_area,
NULL);
&thread_12_thread_data, &thread_12_stack_area);

ztest_test_suite(mutex_complex, ztest_user_unit_test(test_mutex));
ztest_run_test_suite(mutex_complex);
}
3 changes: 1 addition & 2 deletions tests/kernel/pipe/pipe/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ void test_main(void)
k_thread_access_grant(k_current_get(),
&test_pipe, &put_sem, &get_sem,
&sync_sem, &multiple_send_sem,
&get_single_tid, &stack_1,
NULL);
&get_single_tid, &stack_1);

ztest_test_suite(test_pipe,
ztest_user_unit_test(test_pipe_on_single_elements),
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/pipe/pipe_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void test_main(void)
{
k_thread_access_grant(k_current_get(), &pipe,
&kpipe, &end_sema, &tdata, &tstack,
&khalfpipe, &put_get_pipe, NULL);
&khalfpipe, &put_get_pipe);

k_thread_resource_pool_assign(k_current_get(), &test_pool);

Expand Down
3 changes: 1 addition & 2 deletions tests/kernel/poll/src/test_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,5 @@ void test_poll_grant_access(void)
&wait_signal, &poll_wait_helper_thread,
&poll_wait_helper_stack, &multi_sem,
&multi_reply, &multi_thread, &multi_stack,
&multi_thread_lowprio, &multi_stack_lowprio,
NULL);
&multi_thread_lowprio, &multi_stack_lowprio);
}
3 changes: 1 addition & 2 deletions tests/kernel/semaphore/sema_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ void test_sema_count_get(void)
/*test case main entry*/
void test_main(void)
{
k_thread_access_grant(k_current_get(), &ksema, &tdata, &sema, &tstack,
NULL);
k_thread_access_grant(k_current_get(), &ksema, &tdata, &sema, &tstack);

ztest_test_suite(sema_api,
ztest_user_unit_test(test_sema_thread2thread),
Expand Down
3 changes: 1 addition & 2 deletions tests/kernel/semaphore/semaphore/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,7 @@ void test_main(void)
&simple_sem, &multiple_thread_sem,
&low_prio_sem, &mid_prio_sem, &high_prio_sem,
&stack_1, &stack_2, &stack_3, &timeout_info_pipe,
&sem_tid, &sem_tid_1, &sem_tid_2,
NULL);
&sem_tid, &sem_tid_1, &sem_tid_2);

ztest_test_suite(test_semaphore,
ztest_unit_test(test_simple_sem_from_isr),
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/stack/stack_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ K_THREAD_STACK_EXTERN(threadstack);
void test_main(void)
{
k_thread_access_grant(k_current_get(), &kstack, &stack, &thread_data,
&end_sema, &threadstack, NULL);
&end_sema, &threadstack);

k_thread_resource_pool_assign(k_current_get(), &test_pool);

Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/stack/stack_usage/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static void test_isr_stack_play(void)
void test_main(void)
{
k_thread_access_grant(k_current_get(), &stack1, &stack2, &thread_data,
&end_sema, &threadstack, NULL);
&end_sema, &threadstack);

ztest_test_suite(test_stack_usage,
ztest_user_unit_test(test_single_stack_play),
Expand Down
3 changes: 1 addition & 2 deletions tests/kernel/threads/dynamic_thread/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ static void dyn_thread_entry(void *p1, void *p2, void *p3)
static void prep(void)
{
k_thread_access_grant(k_current_get(), dyn_thread_stack,
&start_sem, &end_sem,
NULL);
&start_sem, &end_sem);
}

static void create_dynamic_thread(void)
Expand Down
4 changes: 2 additions & 2 deletions tests/kernel/threads/thread_apis/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ void test_user_mode(void)

void test_main(void)
{
k_thread_access_grant(k_current_get(), &tdata, tstack, NULL);
k_thread_access_grant(k_current_get(), &tdata_custom, tstack_custom, NULL);
k_thread_access_grant(k_current_get(), &tdata, tstack);
k_thread_access_grant(k_current_get(), &tdata_custom, tstack_custom);
main_prio = k_thread_priority_get(k_current_get());

ztest_test_suite(threads_lifecycle,
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/threads/thread_init/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void test_kinit_coop_thread(void)
void test_main(void)
{
k_thread_access_grant(k_current_get(), &thread_preempt, &stack_preempt,
&start_sema, &end_sema, NULL);
&start_sema, &end_sema);

ztest_test_suite(thread_init,
ztest_user_unit_test(test_kdefine_preempt_thread),
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/workq/work_queue_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void test_main(void)
main_thread = k_current_get();
k_thread_access_grant(main_thread, &sync_sema, &user_workq.thread,
&user_workq.queue,
&user_tstack, NULL);
&user_tstack);
k_sem_init(&sync_sema, 0, NUM_OF_WORK);
k_thread_system_pool_assign(k_current_get());

Expand Down

0 comments on commit 35ca98d

Please sign in to comment.