@@ -45,27 +45,26 @@ static void tmutex_test_lock(struct k_mutex *pmutex,
4545 void (* entry_fn )(void * , void * , void * ))
4646{
4747 k_mutex_init (pmutex );
48- k_tid_t tid = k_thread_create (& tdata , tstack , STACK_SIZE ,
49- entry_fn , pmutex , NULL , NULL ,
50- K_PRIO_PREEMPT (0 ), 0 , 0 );
48+ k_thread_create (& tdata , tstack , STACK_SIZE ,
49+ entry_fn , pmutex , NULL , NULL ,
50+ K_PRIO_PREEMPT (0 ),
51+ K_USER | K_INHERIT_PERMS , 0 );
5152 k_mutex_lock (pmutex , K_FOREVER );
5253 TC_PRINT ("access resource from main thread\n" );
5354
5455 /* wait for spawn thread to take action */
5556 k_sleep (TIMEOUT );
56-
57- /* teardown */
58- k_thread_abort (tid );
5957}
6058
6159static void tmutex_test_lock_timeout (struct k_mutex * pmutex ,
6260 void (* entry_fn )(void * , void * , void * ))
6361{
6462 /**TESTPOINT: test k_mutex_init mutex*/
6563 k_mutex_init (pmutex );
66- k_tid_t tid = k_thread_create (& tdata , tstack , STACK_SIZE ,
67- entry_fn , pmutex , NULL , NULL ,
68- K_PRIO_PREEMPT (0 ), 0 , 0 );
64+ k_thread_create (& tdata , tstack , STACK_SIZE ,
65+ entry_fn , pmutex , NULL , NULL ,
66+ K_PRIO_PREEMPT (0 ),
67+ K_USER | K_INHERIT_PERMS , 0 );
6968 k_mutex_lock (pmutex , K_FOREVER );
7069 TC_PRINT ("access resource from main thread\n" );
7170
@@ -74,8 +73,6 @@ static void tmutex_test_lock_timeout(struct k_mutex *pmutex,
7473 k_mutex_unlock (pmutex );
7574 k_sleep (TIMEOUT );
7675
77- /* teardown */
78- k_thread_abort (tid );
7976}
8077
8178static void tmutex_test_lock_unlock (struct k_mutex * pmutex )
@@ -98,9 +95,11 @@ void test_mutex_reent_lock_forever(void)
9895 /**TESTPOINT: test k_mutex_init mutex*/
9996 k_mutex_init (& mutex );
10097 tmutex_test_lock (& mutex , tThread_entry_lock_forever );
98+ k_thread_abort (& tdata );
10199
102100 /**TESTPOINT: test K_MUTEX_DEFINE mutex*/
103101 tmutex_test_lock (& kmutex , tThread_entry_lock_forever );
102+ k_thread_abort (& tdata );
104103}
105104
106105void test_mutex_reent_lock_no_wait (void )
@@ -138,3 +137,19 @@ void test_mutex_lock_unlock(void)
138137 /**TESTPOINT: test K_MUTEX_DEFINE mutex*/
139138 tmutex_test_lock_unlock (& kmutex );
140139}
140+
141+ /*test case main entry*/
142+ void test_main (void )
143+ {
144+ k_thread_access_grant (k_current_get (), & tdata , & tstack , & kmutex ,
145+ & mutex );
146+
147+ ztest_test_suite (mutex_api ,
148+ ztest_user_unit_test (test_mutex_lock_unlock ),
149+ ztest_user_unit_test (test_mutex_reent_lock_forever ),
150+ ztest_user_unit_test (test_mutex_reent_lock_no_wait ),
151+ ztest_user_unit_test (test_mutex_reent_lock_timeout_fail ),
152+ ztest_user_unit_test (test_mutex_reent_lock_timeout_pass )
153+ );
154+ ztest_run_test_suite (mutex_api );
155+ }
0 commit comments