tests: queue: add a test case for coverage
Add a test case for k_queue_unique_append() API. Signed-off-by: Lixin Guo <lixinx.guo@intel.com>
This commit is contained in:
parent
5b9c6264af
commit
7fb38330f6
3 changed files with 29 additions and 0 deletions
|
@ -55,6 +55,7 @@ void test_main(void)
|
|||
ztest_1cpu_unit_test(test_queue_poll_race),
|
||||
ztest_unit_test(test_multiple_queues),
|
||||
ztest_unit_test(test_queue_multithread_competition),
|
||||
ztest_unit_test(test_queue_unique_append),
|
||||
ztest_unit_test(test_access_kernel_obj_with_priv_data),
|
||||
ztest_unit_test(test_queue_append_list_error),
|
||||
ztest_unit_test(test_queue_merge_list_error),
|
||||
|
|
|
@ -38,6 +38,7 @@ extern void test_queue_multithread_competition(void);
|
|||
extern void test_access_kernel_obj_with_priv_data(void);
|
||||
extern void test_queue_append_list_error(void);
|
||||
extern void test_queue_merge_list_error(void);
|
||||
extern void test_queue_unique_append(void);
|
||||
|
||||
extern struct k_heap test_pool;
|
||||
|
||||
|
|
|
@ -526,3 +526,30 @@ void test_queue_multithread_competition(void)
|
|||
/* Revert priority of the main thread */
|
||||
k_thread_priority_set(k_current_get(), old_prio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify k_queue_unique_append()
|
||||
*
|
||||
* @ingroup kernel_queue_tests
|
||||
*
|
||||
* @details Append the same data to the queue repeatedly,
|
||||
* see if it returns expected value.
|
||||
* And verify operation succeed if append different data to
|
||||
* the queue.
|
||||
*
|
||||
* @see k_queue_unique_append()
|
||||
*/
|
||||
void test_queue_unique_append(void)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
k_queue_init(&queue);
|
||||
ret = k_queue_unique_append(&queue, (void *)&data[0]);
|
||||
zassert_true(ret, "queue unique append failed");
|
||||
|
||||
ret = k_queue_unique_append(&queue, (void *)&data[0]);
|
||||
zassert_false(ret, "queue unique append should fail");
|
||||
|
||||
ret = k_queue_unique_append(&queue, (void *)&data[1]);
|
||||
zassert_true(ret, "queue unique append failed");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue