From ae39f8e2457a31b6e9f00fbff991cf4f3f7e22ca Mon Sep 17 00:00:00 2001 From: Moral-Hao Date: Tue, 14 Nov 2023 07:44:59 +0800 Subject: [PATCH] Fix one typical misusage of CMock. (#1112) * Fix one typical misusage of CMock. CMock has three policies when dealing with pointer: 1. compare_ptr : compare the pointer itself; 2. compare_data : compare the data which is pointed by pointer; 3. smart : compare the pointer itself, or compare the data; By default, CMock use compare_data policy. Most test cases in FreeRTOS need to compare the pointer itself, and we haven't use CMock properly. For example, one test case of vTaskResume is wrong, because current CMock compares the data pointed by pointer, so the error didn't exposed. There are so many misusage need to fix, it will take a lot of work. I'm here to fix one typical misusage first. * Try to fix formatting syntax. --- FreeRTOS/Test/CMock/tasks/tasks.yml | 1 + FreeRTOS/Test/CMock/tasks/tasks_1_utest.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/FreeRTOS/Test/CMock/tasks/tasks.yml b/FreeRTOS/Test/CMock/tasks/tasks.yml index 7c6d2fbed..c9c74d781 100644 --- a/FreeRTOS/Test/CMock/tasks/tasks.yml +++ b/FreeRTOS/Test/CMock/tasks/tasks.yml @@ -1,6 +1,7 @@ :cmock: :mock_prefix: mock_ :when_no_prototypes: :warn + :when_ptr: :smart :treat_externs: :include :treat_inlines: :include :enforce_strict_ordering: TRUE diff --git a/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c b/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c index 1c7ba271d..eab913a17 100644 --- a/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c +++ b/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c @@ -2626,8 +2626,8 @@ void test_vTaskResume_success_task_event_list_orphan( void ) /* back */ uxListRemove_ExpectAndReturn( &ptcb->xStateListItem, pdTRUE ); /* prvAddTaskToReadyList*/ - listINSERT_END_Expect( &pxReadyTasksLists[ create_task_priority ], - &ptcb->xStateListItem ); + listINSERT_END_ExpectWithArray( &pxReadyTasksLists[ 3 ], 0, + &ptcb->xStateListItem, 0 ); /* API Call */ vTaskResume( task_handle ); /* not current tcb */ /* Validations */