add a set of dyn(create / destroy) interface
1. tos_ring_q_create_dyn 2. tos_chr_fifo_create_dyn 3. tos_msg_q_create_dyn 4. tos_mail_q_create_dyn 5. tos_bin_heap_create_dyn 6. tos_prio_q_create_dyn 7. tos_prio_msg_q_create_dyn 8. tos_prio_mail_q_create_dyn
This commit is contained in:
@@ -172,6 +172,68 @@ TEST test_tos_priority_message_queue_pend(void)
|
||||
PASS();
|
||||
}
|
||||
|
||||
TEST test_tos_priority_message_queue_pend_dyn(void)
|
||||
{
|
||||
k_err_t err;
|
||||
void *msg0 = (void *)0xDEAD0000, *msg1 = (void *)0xDEAD1111, *msg2 = (void *)0xDEAD2222;
|
||||
|
||||
test_msg_reset();
|
||||
test_context_reset();
|
||||
test_count_reset();
|
||||
test_task_hook_set(test_count_inc);
|
||||
|
||||
err = tos_prio_msg_q_create_dyn(&test_prio_msg_q_00, TEST_PRIO_MESSAGE_Q_MSG_CNT);
|
||||
ASSERT_EQ(err, K_ERR_NONE);
|
||||
|
||||
// create a test task with the same priority than current task
|
||||
err = tos_task_create(&test_task_00, "test_task", test_priority_message_queue_pend_task_entry,
|
||||
(void *)(&test_prio_msg_q_00), k_curr_task->prio,
|
||||
test_task_stack_00, sizeof(test_task_stack_00),
|
||||
0);
|
||||
ASSERT_EQ(err, K_ERR_NONE);
|
||||
|
||||
ASSERT_EQ(test_count, 0);
|
||||
ASSERT(test_context != TEST_CONTEXT_00); // test_task is not running yet
|
||||
|
||||
// we post msg2, msg1, msg0 with the certain priority, the test_task should receive message according the priority
|
||||
tos_prio_msg_q_post(&test_prio_msg_q_00, msg2, 2);
|
||||
tos_prio_msg_q_post(&test_prio_msg_q_00, msg1, 1);
|
||||
tos_prio_msg_q_post(&test_prio_msg_q_00, msg0, 0);
|
||||
|
||||
tos_task_yield(); // yeild to test_task
|
||||
|
||||
ASSERT_EQ(test_count, 0);
|
||||
ASSERT_EQ(test_err, K_ERR_NONE);
|
||||
ASSERT_EQ(test_context, TEST_CONTEXT_01);
|
||||
|
||||
ASSERT_EQ(test_msg, msg0);
|
||||
tos_task_yield(); // yeild to test_task
|
||||
|
||||
ASSERT_EQ(test_count, 1);
|
||||
ASSERT_EQ(test_err, K_ERR_NONE);
|
||||
ASSERT_EQ(test_context, TEST_CONTEXT_01);
|
||||
|
||||
ASSERT_EQ(test_msg, msg1);
|
||||
tos_task_yield(); // yeild to test_task
|
||||
|
||||
ASSERT_EQ(test_count, 2);
|
||||
ASSERT_EQ(test_err, K_ERR_NONE);
|
||||
ASSERT_EQ(test_context, TEST_CONTEXT_01);
|
||||
|
||||
ASSERT_EQ(test_msg, msg2);
|
||||
tos_task_yield(); // yeild to test_task
|
||||
|
||||
tos_prio_msg_q_destroy_dyn(&test_prio_msg_q_00);
|
||||
tos_task_yield(); // yeild to test_task
|
||||
ASSERT_EQ(test_err, K_ERR_PEND_DESTROY);
|
||||
ASSERT_EQ(test_context, TEST_CONTEXT_01);
|
||||
|
||||
err = tos_task_destroy(&test_task_00);
|
||||
ASSERT_EQ(err, K_ERR_NONE);
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
TEST test_tos_priority_message_queue_pend_timed(void)
|
||||
{
|
||||
k_err_t err;
|
||||
@@ -385,6 +447,7 @@ SUITE(suit_priority_message_queue)
|
||||
RUN_TEST(test_tos_priority_message_queue_create);
|
||||
RUN_TEST(test_tos_priority_message_queue_destroy);
|
||||
RUN_TEST(test_tos_priority_message_queue_pend);
|
||||
RUN_TEST(test_tos_priority_message_queue_pend_dyn);
|
||||
RUN_TEST(test_tos_priority_message_queue_pend_timed);
|
||||
RUN_TEST(test_tos_priority_message_queue_post_all);
|
||||
RUN_TEST(test_tos_priority_message_queue_flush);
|
||||
|
Reference in New Issue
Block a user