Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: kernel: metairq: Ensure meta-IRQ can preempt a cooperative thread #84509

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/kernel/sched/metairq/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ void metairq_thread(void *p1, void *p2, void *p3)

k_msleep(WAIT_MS);

zassert_not_equal(coop_cnt2, LOOP_CNT, "thread2 wasn't preempted");

printk("give sem1\n");
k_sem_give(&coop_sem1);

Expand Down Expand Up @@ -113,6 +115,8 @@ void coop_thread1(void *p1, void *p2, void *p3)
cnt2 = coop_cnt2;
zassert_equal(cnt2, LOOP_CNT, "Unexpected cnt2 at end: %d", cnt2);

printk("thread1 end\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug code? Do we need this in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily. As the cooperative thread already printed when it ended, I added these for the other two threads. It also makes the failure case more clear in the logs, I think:

Running TESTSUITE suite_preempt_metairq
===================================================================
START - test_preempt_metairq
thread1 take sem
thread2 take sem
metairq start
give sem2
thread2 got sem
thread2 loop iteration 0
thread2 loop iteration 1
thread2 loop iteration 2
thread2 loop iteration 3
thread2 end

    Assertion failed at WEST_TOPDIR/zephyr/tests/kernel/sched/metairq/src/main.c:80: metairq_thread: (coop_cnt2 equal to LOOP_CNT)
thread2 wasn't preempted
 FAIL - test_preempt_metairq in 0.065 seconds


k_sem_give(&coop_sem1);
}

Expand Down Expand Up @@ -155,6 +159,8 @@ void coop_thread2(void *p1, void *p2, void *p3)
cnt2 = coop_cnt2;
zassert_equal(cnt2, LOOP_CNT, "Unexpected cnt2 at end: %d", cnt2);

printk("thread2 end\n");

k_sem_give(&coop_sem2);
}

Expand Down
Loading