diff options
author | Darian <32921628+Dazza0@users.noreply.github.com> | 2023-03-21 02:41:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-20 11:41:13 -0700 |
commit | e7d31258f633445068736af759481b7ecf06dcbd (patch) | |
tree | 79470c0e5af51e97321c29f48ef1de3654be4c83 /FreeRTOS/Test/CMock/timers/timers_1_utest.c | |
parent | c8c1c12765c1ec8f18b6db9036c4c2fdd5483161 (diff) | |
download | freertos-git-e7d31258f633445068736af759481b7ecf06dcbd.tar.gz |
Add unit tests for GetStaticBuffer functions (#964)
Add unit tests for the various ...GetStaticBuffer() functions added in
https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/641.
---------
Co-authored-by: Paul Bartell <pbartell@amazon.com>
Diffstat (limited to 'FreeRTOS/Test/CMock/timers/timers_1_utest.c')
-rw-r--r-- | FreeRTOS/Test/CMock/timers/timers_1_utest.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/FreeRTOS/Test/CMock/timers/timers_1_utest.c b/FreeRTOS/Test/CMock/timers/timers_1_utest.c index 04d74e757..e78ce6768 100644 --- a/FreeRTOS/Test/CMock/timers/timers_1_utest.c +++ b/FreeRTOS/Test/CMock/timers/timers_1_utest.c @@ -1784,3 +1784,63 @@ void test_timer_function_success_wrap_timer( void ) /* Validations */ TEST_ASSERT_EQUAL( 1, *retVal ); } + +void test_xTimerGetStaticBuffer_static( void ) +{ + TimerHandle_t ret_timer_create; + UBaseType_t pvTimerID; + StaticTimer_t pxTimerBuffer[ sizeof( StaticTimer_t ) ]; + StaticTimer_t * pxTimerBufferRet = NULL; + + /* Setup */ + /* Expectations */ + /* prvInitialiseNewTimer */ + /* prvCheckForValidListAndQueue */ + vListInitialise_ExpectAnyArgs(); + vListInitialise_ExpectAnyArgs(); + xQueueGenericCreateStatic_ExpectAnyArgsAndReturn( NULL ); + /* Back prvInitialiseNewTimer */ + vListInitialiseItem_ExpectAnyArgs(); + + /* API Call */ + ret_timer_create = xTimerCreateStatic( "ut_timer_task", + pdMS_TO_TICKS( 1000 ), + pdTRUE, + ( void * ) &pvTimerID, + xCallback_Test, + pxTimerBuffer ); + + TEST_ASSERT_EQUAL( pdTRUE, xTimerGetStaticBuffer( ret_timer_create, &pxTimerBufferRet ) ); + TEST_ASSERT_EQUAL( pxTimerBuffer, pxTimerBufferRet ); +} + +void test_xTimerGetStaticBuffer_dynamic( void ) +{ + TimerHandle_t xTimer = NULL; + UBaseType_t pvTimerID = 0; + Timer_t pxNewTimer = { 0 }; + StaticTimer_t * pxTimerBufferRet = NULL; + + pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer ); + + /* Setup */ + /* Expectations */ + /* prvInitialiseNewTimer */ + /* prvCheckForValidListAndQueue */ + vListInitialise_ExpectAnyArgs(); + vListInitialise_ExpectAnyArgs(); + xQueueGenericCreateStatic_ExpectAnyArgsAndReturn( NULL ); + /* Back prvInitialiseNewTimer */ + vListInitialiseItem_ExpectAnyArgs(); + + + /* API Call */ + xTimer = xTimerCreate( "ut_timer_task", + pdMS_TO_TICKS( 1000 ), + pdTRUE, + ( void * ) &pvTimerID, + xCallback_Test ); + + TEST_ASSERT_EQUAL( pdFALSE, xTimerGetStaticBuffer( xTimer, &pxTimerBufferRet ) ); + TEST_ASSERT_EQUAL( NULL, pxTimerBufferRet ); +} |