Skip to content

Commit

Permalink
test: msgq: imporve test coverage for message queue
Browse files Browse the repository at this point in the history
Add code to wake up a thread waiting for message on a message
queue.

Signed-off-by: Meng xianglin <[email protected]>
  • Loading branch information
mengxianglinx authored and nashif committed Jan 15, 2021
1 parent f70efbc commit 912914a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/kernel/msgq/msgq_api/prj.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_ZTEST=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_TEST_USERSPACE=y
CONFIG_OBJECT_TRACING=y
7 changes: 7 additions & 0 deletions tests/kernel/msgq/msgq_api/src/test_msgq_contexts.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ void test_msgq_empty(void)
k_sem_take(&end_sema, K_FOREVER);
/* that getting thread is being blocked now */
zassert_equal(tid->base.thread_state, _THREAD_PENDING, NULL);
/* since there is a thread is waiting for message, this queue
* can't be cleanup
*/
ret = k_msgq_cleanup(&msgq1);
zassert_equal(ret, -EBUSY, NULL);
/* put a message to wake that getting thread */
k_msgq_put(&msgq1, &data[0], K_NO_WAIT);
k_thread_abort(tid);
}

Expand Down

0 comments on commit 912914a

Please sign in to comment.