test: msgq: imporve test coverage for message queue

Add code to wake up a thread waiting for message on a message
queue.

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
This commit is contained in:
Meng xianglin 2020-12-22 02:23:03 -05:00 committed by Anas Nashif
commit 912914a915
2 changed files with 8 additions and 0 deletions

View file

@ -1,3 +1,4 @@
CONFIG_ZTEST=y
CONFIG_IRQ_OFFLOAD=y
CONFIG_TEST_USERSPACE=y
CONFIG_OBJECT_TRACING=y

View file

@ -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);
}