Skip to content

Commit 643f86f

Browse files
Andrew Boienashif
authored andcommitted
tests: thread_apis: exercise some system calls
We had no system call coverage for k_thread_suspend and k_thread_resume. Some unnecessary cleanup tasks in the test case have been removed. Signed-off-by: Andrew Boie <[email protected]>
1 parent ffd182a commit 643f86f

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

tests/kernel/threads/thread_apis/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void test_main(void)
214214
ztest_unit_test(test_threads_spawn_forever),
215215
ztest_unit_test(test_thread_start),
216216
ztest_unit_test(test_threads_suspend_resume_cooperative),
217-
ztest_unit_test(test_threads_suspend_resume_preemptible),
217+
ztest_user_unit_test(test_threads_suspend_resume_preemptible),
218218
ztest_unit_test(test_threads_priority_set),
219219
ztest_user_unit_test(test_threads_abort_self),
220220
ztest_user_unit_test(test_threads_abort_others),

tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
K_THREAD_STACK_EXTERN(tstack);
1212
extern struct k_thread tdata;
13-
static int last_prio;
13+
static ZTEST_BMEM int last_prio;
1414

1515
static void thread_entry(void *p1, void *p2, void *p3)
1616
{
@@ -19,8 +19,6 @@ static void thread_entry(void *p1, void *p2, void *p3)
1919

2020
static void threads_suspend_resume(int prio)
2121
{
22-
int old_prio = k_thread_priority_get(k_current_get());
23-
2422
/* set current thread */
2523
last_prio = prio;
2624
k_thread_priority_set(k_current_get(), last_prio);
@@ -30,7 +28,7 @@ static void threads_suspend_resume(int prio)
3028

3129
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
3230
thread_entry, NULL, NULL, NULL,
33-
create_prio, 0, 0);
31+
create_prio, K_USER, 0);
3432
/* checkpoint: suspend current thread */
3533
k_thread_suspend(tid);
3634
k_sleep(100);
@@ -40,11 +38,6 @@ static void threads_suspend_resume(int prio)
4038
k_sleep(100);
4139
/* checkpoint: created thread should be executed after resume */
4240
zassert_true(last_prio == create_prio, NULL);
43-
44-
k_thread_abort(tid);
45-
46-
/* restore environment */
47-
k_thread_priority_set(k_current_get(), old_prio);
4841
}
4942

5043
/*test cases*/

0 commit comments

Comments
 (0)