[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
135
kernel/FreeRTOS/Test/CMock/queue/tracing/FreeRTOSConfig.h
Normal file
135
kernel/FreeRTOS/Test/CMock/queue/tracing/FreeRTOSConfig.h
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#include "fake_assert.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See
|
||||
* https://www.FreeRTOS.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
|
||||
#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 52 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 12 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 20
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 1
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configUSE_ALTERNATIVE_API 0
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 5
|
||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||
#define configINITIAL_TICK_COUNT ( ( TickType_t ) 0 ) /* For test. */
|
||||
#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 1 /* As there are a lot of tasks running. */
|
||||
|
||||
/* Software timer related configuration options. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 20
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
|
||||
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
|
||||
/* Run time stats gathering configuration options. */
|
||||
unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that returns run time counter. */
|
||||
void vConfigureTimerForRunTimeStats( void ); /* Prototype of function that initialises the run time counter. */
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
|
||||
/* This demo makes use of one or more example stats formatting functions. These
|
||||
* format the raw data provided by the uxTaskGetSystemState() function in to human
|
||||
* readable ASCII form. See the notes in the implementation of vTaskList() within
|
||||
* FreeRTOS/Source/tasks.c for limitations. */
|
||||
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
* to exclude the API function. In most cases the linker will remove unused
|
||||
* functions anyway. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 0
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
#define INCLUDE_xTaskGetHandle 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskAbortDelay 1
|
||||
|
||||
/* It is a good idea to define configASSERT() while developing. configASSERT()
|
||||
* uses the same semantics as the standard C assert() macro. */
|
||||
#define configASSERT( x ) \
|
||||
do \
|
||||
{ \
|
||||
if( x ) \
|
||||
{ \
|
||||
vFakeAssert( true, __FILE__, __LINE__ ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
vFakeAssert( false, __FILE__, __LINE__ ); \
|
||||
} \
|
||||
} while( 0 )
|
||||
|
||||
#define mtCOVERAGE_TEST_MARKER() __asm volatile ( "NOP" )
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 )
|
||||
extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer );
|
||||
#define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer )
|
||||
#endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
50
kernel/FreeRTOS/Test/CMock/queue/tracing/Makefile
Normal file
50
kernel/FreeRTOS/Test/CMock/queue/tracing/Makefile
Normal file
@ -0,0 +1,50 @@
|
||||
# Indent with spaces
|
||||
.RECIPEPREFIX := $(.RECIPEPREFIX) $(.RECIPEPREFIX)
|
||||
|
||||
# Do not move this line below the include
|
||||
MAKEFILE_ABSPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
include ../../makefile.in
|
||||
|
||||
# PROJECT_SRC lists the .c files under test
|
||||
PROJECT_SRC += queue.c
|
||||
|
||||
# PROJECT_DEPS_SRC list the .c file that are dependencies of PROJECT_SRC files
|
||||
# Files in PROJECT_DEPS_SRC are excluded from coverage measurements
|
||||
PROJECT_DEPS_SRC += list.c
|
||||
|
||||
# PROJECT_HEADER_DEPS: headers that should be excluded from coverage measurements.
|
||||
PROJECT_HEADER_DEPS += FreeRTOS.h
|
||||
|
||||
# SUITE_UT_SRC: .c files that contain test cases (must end in _utest.c)
|
||||
SUITE_UT_SRC += queue_registry_utest.c
|
||||
SUITE_UT_SRC += queue_trace_utest.c
|
||||
SUITE_UT_SRC += queue_delete_dynamic_utest.c
|
||||
SUITE_UT_SRC += queue_delete_static_utest.c
|
||||
|
||||
# SUITE_SUPPORT_SRC: .c files used for testing that do not contain test cases.
|
||||
# Paths are relative to PROJECT_DIR
|
||||
SUITE_SUPPORT_SRC += queue_utest_common.c
|
||||
SUITE_SUPPORT_SRC += td_task.c
|
||||
SUITE_SUPPORT_SRC += td_port.c
|
||||
|
||||
# List the headers used by PROJECT_SRC that you would like to mock
|
||||
MOCK_FILES_FP += $(KERNEL_DIR)/include/task.h
|
||||
MOCK_FILES_FP += $(UT_ROOT_DIR)/config/fake_assert.h
|
||||
MOCK_FILES_FP += $(UT_ROOT_DIR)/config/fake_port.h
|
||||
|
||||
# List any addiitonal flags needed by the preprocessor
|
||||
CPPFLAGS += -DportUSING_MPU_WRAPPERS=0
|
||||
|
||||
# List any addiitonal flags needed by the compiler
|
||||
CFLAGS +=
|
||||
|
||||
# Try not to edit beyond this line unless necessary.
|
||||
|
||||
# Project / Suite are determined based on path: $(UT_ROOT_DIR)/$(PROJECT)/$(SUITE)
|
||||
PROJECT := $(lastword $(subst /, ,$(dir $(abspath $(MAKEFILE_ABSPATH)/../))))
|
||||
SUITE := $(lastword $(subst /, ,$(dir $(MAKEFILE_ABSPATH))))
|
||||
|
||||
# Make variables available to included makefile
|
||||
export
|
||||
|
||||
include ../../testdir.mk
|
||||
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
/*! @file queue_delete_dynamic_utest.c */
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../queue_utest_common.h"
|
||||
|
||||
/* Queue includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "queue.h"
|
||||
|
||||
#include "mock_fake_port.h"
|
||||
|
||||
/* ============================ GLOBAL VARIABLES =========================== */
|
||||
|
||||
/* =========================== CALLBACK FUNCTIONS =========================== */
|
||||
|
||||
/* ============================= Unity Fixtures ============================= */
|
||||
|
||||
void setUp( void )
|
||||
{
|
||||
commonSetUp();
|
||||
}
|
||||
|
||||
void tearDown( void )
|
||||
{
|
||||
commonTearDown();
|
||||
}
|
||||
|
||||
void suiteSetUp()
|
||||
{
|
||||
commonSuiteSetUp();
|
||||
}
|
||||
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return commonSuiteTearDown( numFailures );
|
||||
}
|
||||
|
||||
/* =========================== Helper functions ============================ */
|
||||
|
||||
/* ============================== Test Cases =============================== */
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with an invalid QueueHandle
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_invalid_handle( void )
|
||||
{
|
||||
EXPECT_ASSERT_BREAK( vQueueDelete( NULL ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with a statically allocated queue of size 6 x 4 bytes
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_empty( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( QUEUE_T_SIZE + ( 6 * 4 ), getLastMallocSize() );
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
TEST_ASSERT_EQUAL_PTR( ( void * ) xQueue, getLastFreedAddress() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with a half-full queue of size 6 x 4 bytes
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_half_full( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( QUEUE_T_SIZE + ( 6 * 4 ), getLastMallocSize() );
|
||||
|
||||
for( uint32_t i = 0; i < 3; i++ )
|
||||
{
|
||||
xQueueSend( xQueue, &i, 0 );
|
||||
}
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
TEST_ASSERT_EQUAL_PTR( ( void * ) xQueue, getLastFreedAddress() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with a full queue of size 6 x 4 bytes
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_full( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( QUEUE_T_SIZE + ( 6 * 4 ), getLastMallocSize() );
|
||||
|
||||
for( uint32_t i = 0; i < 6; i++ )
|
||||
{
|
||||
xQueueSend( xQueue, &i, 0 );
|
||||
}
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
TEST_ASSERT_EQUAL_PTR( ( void * ) xQueue, getLastFreedAddress() );
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
/*! @file queue_delete_static_utest.c */
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../queue_utest_common.h"
|
||||
|
||||
/* Queue includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "queue.h"
|
||||
|
||||
#include "mock_fake_port.h"
|
||||
|
||||
/* ============================ GLOBAL VARIABLES =========================== */
|
||||
|
||||
/* ========================== CALLBACK FUNCTIONS =========================== */
|
||||
|
||||
/* ============================= Unity Fixtures ============================= */
|
||||
|
||||
void setUp( void )
|
||||
{
|
||||
commonSetUp();
|
||||
}
|
||||
|
||||
void tearDown( void )
|
||||
{
|
||||
commonTearDown();
|
||||
}
|
||||
|
||||
void suiteSetUp()
|
||||
{
|
||||
commonSuiteSetUp();
|
||||
}
|
||||
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return commonSuiteTearDown( numFailures );
|
||||
}
|
||||
|
||||
/* ========================== Helper functions =========================== */
|
||||
|
||||
/* ============================= Test Cases ============================== */
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with an invalid QueueHandle
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_invalid_handle( void )
|
||||
{
|
||||
EXPECT_ASSERT_BREAK( vQueueDelete( NULL ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with a statically allocated queue of size 6 x 4 bytes
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_empty( void )
|
||||
{
|
||||
void * queueBuffer = malloc( sizeof( StaticQueue_t ) );
|
||||
void * queueData = malloc( 6 * sizeof( uint32_t ) );
|
||||
QueueHandle_t xQueue = xQueueCreateStatic( 6, sizeof( uint32_t ), queueData, queueBuffer );
|
||||
|
||||
/* Verify that no call to malloc occurred */
|
||||
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
/* Veirfy that free was not called */
|
||||
TEST_ASSERT_EQUAL_PTR( NULL, getLastFreedAddress() );
|
||||
free( queueBuffer );
|
||||
free( queueData );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with a half-full queue of size 6 x 4 bytes
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_half_full( void )
|
||||
{
|
||||
void * queueBuffer = malloc( sizeof( StaticQueue_t ) );
|
||||
void * queueData = malloc( 6 * sizeof( uint32_t ) );
|
||||
QueueHandle_t xQueue = xQueueCreateStatic( 6, sizeof( uint32_t ), queueData, queueBuffer );
|
||||
|
||||
/* Verify that no call to malloc occurred */
|
||||
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
|
||||
|
||||
for( uint32_t i = 0; i < 3; i++ )
|
||||
{
|
||||
xQueueSend( xQueue, &i, 0 );
|
||||
}
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
|
||||
/* Veirfy that free was not called */
|
||||
TEST_ASSERT_EQUAL_PTR( NULL, getLastFreedAddress() );
|
||||
free( queueBuffer );
|
||||
free( queueData );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueDelete with a full queue of size 6 x 4 bytes
|
||||
* @coverage vQueueDelete
|
||||
*/
|
||||
void test_vQueueDelete_full( void )
|
||||
{
|
||||
void * queueBuffer = malloc( sizeof( StaticQueue_t ) );
|
||||
void * queueData = malloc( 6 * sizeof( uint32_t ) );
|
||||
QueueHandle_t xQueue = xQueueCreateStatic( 6, sizeof( uint32_t ), queueData, queueBuffer );
|
||||
|
||||
/* Verify that no call to malloc occurred */
|
||||
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
|
||||
|
||||
for( uint32_t i = 0; i < 6; i++ )
|
||||
{
|
||||
xQueueSend( xQueue, &i, 0 );
|
||||
}
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
|
||||
/* Veirfy that free was not called */
|
||||
TEST_ASSERT_EQUAL_PTR( NULL, getLastFreedAddress() );
|
||||
free( queueBuffer );
|
||||
free( queueData );
|
||||
}
|
||||
395
kernel/FreeRTOS/Test/CMock/queue/tracing/queue_registry_utest.c
Normal file
395
kernel/FreeRTOS/Test/CMock/queue/tracing/queue_registry_utest.c
Normal file
@ -0,0 +1,395 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
/*! @file queue_registry_utest.c */
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../queue_utest_common.h"
|
||||
|
||||
/* Queue includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* ============================ GLOBAL VARIABLES =========================== */
|
||||
|
||||
/**
|
||||
* @brief Copy of QueueRegistryItem_t from queue.c to allow clearing items between test cases.
|
||||
*/
|
||||
typedef struct QUEUE_REGISTRY_ITEM
|
||||
{
|
||||
const char * pcQueueName;
|
||||
QueueHandle_t xHandle;
|
||||
} xQueueRegistryItem;
|
||||
typedef xQueueRegistryItem QueueRegistryItem_t;
|
||||
|
||||
/* Access the xQueueRegistry to clear between test cases */
|
||||
extern PRIVILEGED_DATA QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];
|
||||
|
||||
/* ========================== CALLBACK FUNCTIONS =========================== */
|
||||
|
||||
/* ============================= Unity Fixtures ============================= */
|
||||
|
||||
void setUp( void )
|
||||
{
|
||||
commonSetUp();
|
||||
/* Clear the queue registry between test cases */
|
||||
memset( &xQueueRegistry, 0, ( configQUEUE_REGISTRY_SIZE * sizeof( QueueRegistryItem_t ) ) );
|
||||
}
|
||||
|
||||
void tearDown( void )
|
||||
{
|
||||
commonTearDown();
|
||||
}
|
||||
|
||||
void suiteSetUp()
|
||||
{
|
||||
commonSuiteSetUp();
|
||||
}
|
||||
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return commonSuiteTearDown( numFailures );
|
||||
}
|
||||
|
||||
/* =========================== Helper functions ============================ */
|
||||
|
||||
static bool helper_find_in_queue_registry( QueueHandle_t xQueue,
|
||||
const char * pcQueueName )
|
||||
{
|
||||
for( int i = 0; i < configQUEUE_REGISTRY_SIZE; i++ )
|
||||
{
|
||||
if( ( xQueueRegistry[ i ].pcQueueName == pcQueueName ) &&
|
||||
( xQueueRegistry[ i ].xHandle == xQueue ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool helper_find_handle_in_queue_registry( QueueHandle_t xQueue )
|
||||
{
|
||||
for( int i = 0; i < configQUEUE_REGISTRY_SIZE; i++ )
|
||||
{
|
||||
if( xQueueRegistry[ i ].xHandle == xQueue )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ============================== Test Cases =============================== */
|
||||
|
||||
/**
|
||||
* @brief Test vQueueAddToRegistry with a NULL QueueHandle_t
|
||||
* @details Verify that a NULL QueueHandle_t results in the string being stored
|
||||
* to the QueueRegistry and a configASSERT failure.
|
||||
* @coverage vQueueAddToRegistry
|
||||
**/
|
||||
void test_vQueueAddToRegistry_null_xQueue( void )
|
||||
{
|
||||
const char * pcFakeStringPtr = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Expect a failed configASSERT when adding a NULL xQueue to the QueueRegistry */
|
||||
fakeAssertExpectFail();
|
||||
|
||||
vQueueAddToRegistry( NULL, pcFakeStringPtr );
|
||||
TEST_ASSERT_TRUE( fakeAssertGetFlagAndClear() );
|
||||
|
||||
TEST_ASSERT_TRUE( helper_find_in_queue_registry( NULL, pcFakeStringPtr ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueAddToRegistry with a NULL pcQueueName
|
||||
* @details Verify that a NULL pcQueueName results in the NULL string being stored
|
||||
* in the QueueRegistry and a configASSERT failure.
|
||||
* @coverage vQueueAddToRegistry
|
||||
**/
|
||||
void test_vQueueAddToRegistry_null_pcQueueName( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
vQueueAddToRegistry( xFakeHandle, NULL );
|
||||
|
||||
TEST_ASSERT_FALSE( helper_find_in_queue_registry( xFakeHandle, NULL ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueAddToRegistry with a valid xQueue and pcQueueName
|
||||
* @details Verify that calling vQueueAddToRegistry with a valid xQueue and
|
||||
* pcQueueName stores the tuple.
|
||||
* @coverage vQueueAddToRegistry
|
||||
**/
|
||||
void test_vQueueAddToRegistry_success( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Add an item to the registry */
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString );
|
||||
|
||||
/* Verify that the value was added to the registry */
|
||||
TEST_ASSERT_TRUE( helper_find_in_queue_registry( xFakeHandle, pcFakeString ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueAddToRegistry with the same QueueHandle_t twice
|
||||
* @details Verify that a given QueueHandle_t can be added to the queue registry
|
||||
* multiple times and that the l
|
||||
* @coverage vQueueAddToRegistry
|
||||
**/
|
||||
void test_vQueueAddToRegistry_twice( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString1 = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString2 = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Add an item to the registry */
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString1 );
|
||||
|
||||
TEST_ASSERT_TRUE( helper_find_in_queue_registry( xFakeHandle, pcFakeString1 ) );
|
||||
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString2 );
|
||||
|
||||
/* Verify that pcFakeString2 is now in the queue registry */
|
||||
TEST_ASSERT_TRUE( helper_find_in_queue_registry( xFakeHandle, pcFakeString2 ) );
|
||||
|
||||
/* Verify that pcFakeString1 is no longer in the queue registry */
|
||||
TEST_ASSERT_FALSE( helper_find_in_queue_registry( xFakeHandle, pcFakeString1 ) );
|
||||
|
||||
vQueueUnregisterQueue( xFakeHandle );
|
||||
|
||||
/* Verify that pcFakeString2 has been removed from the registry */
|
||||
TEST_ASSERT_FALSE( helper_find_in_queue_registry( xFakeHandle, pcFakeString2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueAddToRegistry with a queue registry that is already full.
|
||||
* @details Verify that a call to vQueueAddToRegistry with a full queue registry
|
||||
* fails silently.
|
||||
* @coverage vQueueAddToRegistry
|
||||
**/
|
||||
void test_vQueueAddToRegistry_full( void )
|
||||
{
|
||||
TEST_ASSERT_TRUE( configQUEUE_REGISTRY_SIZE < UINT32_MAX );
|
||||
|
||||
/* Fill the queue registry and verify that the max items were successfully stored.
|
||||
* Start at i=1 since a NULL / 0 pcQueueName denotes an empty queue registry location */
|
||||
for( BaseType_t i = 1; i <= configQUEUE_REGISTRY_SIZE; i++ )
|
||||
{
|
||||
QueueHandle_t fakeHandle = ( QueueHandle_t ) i;
|
||||
const char * fakeString = ( char * ) i;
|
||||
|
||||
/* Add our fake QueueHandle_t and const char* to the registry */
|
||||
vQueueAddToRegistry( fakeHandle, fakeString );
|
||||
|
||||
/* Verify that the fake queue handle was added to the registry */
|
||||
TEST_ASSERT_EQUAL( pcQueueGetName( fakeHandle ), fakeString );
|
||||
}
|
||||
|
||||
/* Prepare one more fake item to add to the registry */
|
||||
QueueHandle_t fakeHandle = ( QueueHandle_t ) ( configQUEUE_REGISTRY_SIZE + 1 );
|
||||
const char * fakeString = ( char * ) ( configQUEUE_REGISTRY_SIZE + 1 );
|
||||
|
||||
/* Add one more item */
|
||||
vQueueAddToRegistry( fakeHandle, fakeString );
|
||||
|
||||
TEST_ASSERT_FALSE( helper_find_in_queue_registry( fakeHandle, fakeString ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test pcQueueGetName with a NULL QueueHandle_t
|
||||
* @details Verify that a NULL QueueHandle_t can be used as a lookup value with
|
||||
* pcQueueGetName, but causes a failed configASSERT.
|
||||
* @coverage pcQueueGetName
|
||||
**/
|
||||
void test_pcQueueGetName_null_xQueue( void )
|
||||
{
|
||||
const char * pcFakeString = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Expect a failed configASSERT when adding a NULL xQueue to the QueueRegistry */
|
||||
fakeAssertExpectFail();
|
||||
|
||||
vQueueAddToRegistry( NULL, pcFakeString );
|
||||
fakeAssertGetFlagAndClear();
|
||||
|
||||
TEST_ASSERT_TRUE( helper_find_in_queue_registry( NULL, pcFakeString ) );
|
||||
|
||||
/* Expect a failed configASSERT when pcQueueGetName with a NULL xQueue */
|
||||
fakeAssertExpectFail();
|
||||
|
||||
/* Validate the value returned by pcQueueGetName */
|
||||
TEST_ASSERT_EQUAL( pcQueueGetName( NULL ), pcFakeString );
|
||||
TEST_ASSERT_TRUE( fakeAssertGetFlagAndClear() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test pcQueueGetName with an xQueue handle that was not registered.
|
||||
* @details Verify that a call to pcQueueGetName with an unregistered xQueue
|
||||
* returns a NULL pointer.
|
||||
* @coverage pcQueueGetName
|
||||
**/
|
||||
void test_pcQueueGetName_not_registered( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Add an item to the registry */
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString );
|
||||
|
||||
/* Verify the value returned by pcQueueGetName matches the value added to the registry */
|
||||
TEST_ASSERT_EQUAL( pcQueueGetName( xFakeHandle ), pcFakeString );
|
||||
|
||||
vQueueUnregisterQueue( xFakeHandle );
|
||||
|
||||
/* Verify the value returned by pcQueueGetName matches the value added to the registry */
|
||||
TEST_ASSERT_EQUAL( NULL, pcQueueGetName( xFakeHandle ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test pcQueueGetName with an xQueue handle that was previously registered.
|
||||
* @details Verify that a call to pcQueueGetName with a registered xQueue handle
|
||||
* returns the correct pointer
|
||||
* @coverage pcQueueGetName
|
||||
**/
|
||||
void test_pcQueueGetName_registered( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Add an item to the registry */
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString );
|
||||
|
||||
/* Verify the value returned by pcQueueGetName matches the value added to the registry */
|
||||
TEST_ASSERT_EQUAL( pcQueueGetName( xFakeHandle ), pcFakeString );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueUnregisterQueue with a NULL xQueue handle
|
||||
* @details Verify that calling vQueueUnregisterQueue with a NULL xQueue results
|
||||
* in a configASSERT failure.
|
||||
* @coverage vQueueUnregisterQueue
|
||||
**/
|
||||
void test_vQueueUnregisterQueue_null_handle( void )
|
||||
{
|
||||
fakeAssertExpectFail();
|
||||
|
||||
vQueueUnregisterQueue( NULL );
|
||||
|
||||
TEST_ASSERT_TRUE( fakeAssertGetFlagAndClear() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueUnregisterQueue with an unregistered xQueue handle
|
||||
* @details Verify that calling vQueueUnregisterQueue does not result in an assertion.
|
||||
* @coverage vQueueUnregisterQueue
|
||||
**/
|
||||
void test_vQueueUnregisterQueue_queue_not_registered( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
vQueueUnregisterQueue( xFakeHandle );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueUnregisterQueue on a registered xQueue
|
||||
* @details Verify that calling vQueueUnregisterQueue with a registered xQueue
|
||||
* removes the xQueue from the Queue Registry and does not result in a
|
||||
* configASSERT failure.
|
||||
* @coverage vQueueUnregisterQueue
|
||||
**/
|
||||
void test_vQueueUnregisterQueue( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Add an item to the registry */
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString );
|
||||
|
||||
TEST_ASSERT_TRUE( helper_find_handle_in_queue_registry( xFakeHandle ) );
|
||||
TEST_ASSERT_EQUAL( pcFakeString, pcQueueGetName( xFakeHandle ) );
|
||||
|
||||
vQueueUnregisterQueue( xFakeHandle );
|
||||
|
||||
TEST_ASSERT_FALSE( helper_find_handle_in_queue_registry( xFakeHandle ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test two subsequent calls to vQueueUnregisterQueue on a registered xQueue
|
||||
* @details Verify that calling vQueueUnregisterQueue twice on a registered xQueue
|
||||
* succeeds the first time and results in no change on the second call.
|
||||
* @coverage vQueueUnregisterQueue
|
||||
**/
|
||||
void test_vQueueUnregisterQueue_twice( void )
|
||||
{
|
||||
QueueHandle_t xFakeHandle = ( QueueHandle_t ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
const char * pcFakeString = ( char * ) ( BaseType_t ) getNextMonotonicTestValue();
|
||||
|
||||
/* Add an item to the registry */
|
||||
vQueueAddToRegistry( xFakeHandle, pcFakeString );
|
||||
|
||||
/* Verify that the value was added to the registry */
|
||||
TEST_ASSERT_TRUE( helper_find_handle_in_queue_registry( xFakeHandle ) );
|
||||
|
||||
vQueueUnregisterQueue( xFakeHandle );
|
||||
|
||||
TEST_ASSERT_FALSE( helper_find_handle_in_queue_registry( xFakeHandle ) );
|
||||
|
||||
vQueueUnregisterQueue( xFakeHandle );
|
||||
|
||||
TEST_ASSERT_FALSE( helper_find_handle_in_queue_registry( xFakeHandle ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test that vQueueDelete removes the xQueue from the Queue Registry
|
||||
* @details Verify that vQueueDelete removes a queue from the Queue Registry
|
||||
* by calling vQueueUnregisterQueue.
|
||||
* @coverage vQueueDelete vQueueUnregisterQueue
|
||||
**/
|
||||
void test_vQueueDelete_vQueueUnregisterQueue( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
const char * xQueueName = "Testing 123";
|
||||
|
||||
/* Add the queue to the registry */
|
||||
vQueueAddToRegistry( xQueue, xQueueName );
|
||||
|
||||
/* Verify the value returned by pcQueueGetName matches the value added to the registry */
|
||||
TEST_ASSERT_EQUAL( xQueueName, pcQueueGetName( xQueue ) );
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
|
||||
/* Verify the value returned by pcQueueGetName is now NULL */
|
||||
TEST_ASSERT_EQUAL( NULL, pcQueueGetName( xQueue ) );
|
||||
}
|
||||
195
kernel/FreeRTOS/Test/CMock/queue/tracing/queue_trace_utest.c
Normal file
195
kernel/FreeRTOS/Test/CMock/queue/tracing/queue_trace_utest.c
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* FreeRTOS V202212.01
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
/*! @file queue_trace_utest.c */
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../queue_utest_common.h"
|
||||
|
||||
/* Queue includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* ============================ GLOBAL VARIABLES =========================== */
|
||||
|
||||
/* ========================== CALLBACK FUNCTIONS =========================== */
|
||||
|
||||
/* ============================= Unity Fixtures ============================= */
|
||||
|
||||
void setUp( void )
|
||||
{
|
||||
commonSetUp();
|
||||
}
|
||||
|
||||
void tearDown( void )
|
||||
{
|
||||
commonTearDown();
|
||||
}
|
||||
|
||||
void suiteSetUp()
|
||||
{
|
||||
commonSuiteSetUp();
|
||||
}
|
||||
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return commonSuiteTearDown( numFailures );
|
||||
}
|
||||
|
||||
/* ========================== Helper functions =========================== */
|
||||
|
||||
/**
|
||||
* @brief Test vQueueSetQueueNumber and uxQueueGetQueueNumber
|
||||
* @details Verify that the queue number set with vQueueSetQueueNumber is returned
|
||||
* by a subsequent call to uxQueueGetQueueNumber.
|
||||
* @coverage vQueueSetQueueNumber uxQueueGetQueueNumber
|
||||
*/
|
||||
void test_vQueueSetQueueNumber_uxQueueGetQueueNumber( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
|
||||
vQueueSetQueueNumber( xQueue, getNextMonotonicTestValue() );
|
||||
|
||||
TEST_ASSERT_EQUAL( getLastMonotonicTestValue(), uxQueueGetQueueNumber( xQueue ) );
|
||||
vQueueDelete( xQueue );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueSetQueueNumber and uxQueueGetQueueNumber with UINT64_MAX
|
||||
* @details Verify that the queue number of UINT64_MAX set with
|
||||
* vQueueSetQueueNumber is returned by a subsequent call to uxQueueGetQueueNumber.
|
||||
* @coverage vQueueSetQueueNumber uxQueueGetQueueNumber
|
||||
*/
|
||||
void test_vQueueSetQueueNumber_uxQueueGetQueueNumber_max( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
|
||||
vQueueSetQueueNumber( xQueue, UINT64_MAX );
|
||||
|
||||
TEST_ASSERT_EQUAL( UINT64_MAX, uxQueueGetQueueNumber( xQueue ) );
|
||||
vQueueDelete( xQueue );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test vQueueSetQueueNumber and uxQueueGetQueueNumber with 0
|
||||
* @details Verify that the queue number of 0 set with vQueueSetQueueNumber
|
||||
* is returned by a subsequent call to uxQueueGetQueueNumber.
|
||||
* @coverage vQueueSetQueueNumber uxQueueGetQueueNumber
|
||||
*/
|
||||
void test_vQueueSetQueueNumber_uxQueueGetQueueNumber_zero( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
|
||||
vQueueSetQueueNumber( xQueue, 0 );
|
||||
|
||||
TEST_ASSERT_EQUAL( 0, uxQueueGetQueueNumber( xQueue ) );
|
||||
vQueueDelete( xQueue );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test ucQueueGetQueueType with a Queue
|
||||
* @details Verify that ucQueueGetQueueType returns queueQUEUE_TYPE_BASE for a normal queue.
|
||||
* @coverage ucQueueGetQueueType prvInitialiseNewQueue
|
||||
*/
|
||||
void test_ucQueueGetQueueType_queue( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( queueQUEUE_TYPE_BASE, ucQueueGetQueueType( xQueue ) );
|
||||
vQueueDelete( xQueue );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test ucQueueGetQueueType with a QueueSet
|
||||
* @details Verify that ucQueueGetQueueType returns queueQUEUE_TYPE_SET for a QueueSet.
|
||||
* @coverage ucQueueGetQueueType prvInitialiseNewQueue
|
||||
*/
|
||||
void test_ucQueueGetQueueType_queue_set( void )
|
||||
{
|
||||
QueueSetHandle_t xQueueSet = xQueueCreateSet( 1 );
|
||||
|
||||
TEST_ASSERT_EQUAL( queueQUEUE_TYPE_SET, ucQueueGetQueueType( xQueueSet ) );
|
||||
vQueueDelete( xQueueSet );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test ucQueueGetQueueType with a Mutex
|
||||
* @details Verify that ucQueueGetQueueType returns queueQUEUE_TYPE_MUTEX for a Mutex.
|
||||
* @coverage ucQueueGetQueueType prvInitialiseNewQueue
|
||||
*/
|
||||
void test_ucQueueGetQueueType_mutex( void )
|
||||
{
|
||||
xTaskPriorityDisinherit_ExpectAndReturn( NULL, pdFALSE );
|
||||
SemaphoreHandle_t xSemaphore = xSemaphoreCreateMutex();
|
||||
|
||||
TEST_ASSERT_EQUAL( queueQUEUE_TYPE_MUTEX, ucQueueGetQueueType( xSemaphore ) );
|
||||
vSemaphoreDelete( xSemaphore );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test ucQueueGetQueueType with a Counting Semaphore
|
||||
* @details Verify that ucQueueGetQueueType returns queueQUEUE_TYPE_COUNTING_SEMAPHORE for a Counting Semaphore.
|
||||
* @coverage ucQueueGetQueueType prvInitialiseNewQueue
|
||||
*/
|
||||
void test_ucQueueGetQueueType_counting_semaphore( void )
|
||||
{
|
||||
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 1, 0 );
|
||||
|
||||
TEST_ASSERT_EQUAL( queueQUEUE_TYPE_COUNTING_SEMAPHORE, ucQueueGetQueueType( xSemaphore ) );
|
||||
vSemaphoreDelete( xSemaphore );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test ucQueueGetQueueType with a Binary Semaphore
|
||||
* @details Verify that ucQueueGetQueueType returns queueQUEUE_TYPE_BINARY_SEMAPHORE for a Binary Semaphore.
|
||||
* @coverage ucQueueGetQueueType prvInitialiseNewQueue
|
||||
*/
|
||||
void test_ucQueueGetQueueType_binary_semaphore( void )
|
||||
{
|
||||
SemaphoreHandle_t xSemaphore = xSemaphoreCreateBinary();
|
||||
|
||||
TEST_ASSERT_EQUAL( queueQUEUE_TYPE_BINARY_SEMAPHORE, ucQueueGetQueueType( xSemaphore ) );
|
||||
vSemaphoreDelete( xSemaphore );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test ucQueueGetQueueType with a Recursive Mutex
|
||||
* @details Verify that ucQueueGetQueueType returns queueQUEUE_TYPE_RECURSIVE_MUTEX for a Recursive Mutex.
|
||||
* @coverage ucQueueGetQueueType prvInitialiseNewQueue
|
||||
*/
|
||||
void test_ucQueueGetQueueType_recursive_mutex( void )
|
||||
{
|
||||
xTaskPriorityDisinherit_ExpectAndReturn( NULL, pdFALSE );
|
||||
SemaphoreHandle_t xSemaphore = xSemaphoreCreateRecursiveMutex();
|
||||
|
||||
TEST_ASSERT_EQUAL( queueQUEUE_TYPE_RECURSIVE_MUTEX, ucQueueGetQueueType( xSemaphore ) );
|
||||
vSemaphoreDelete( xSemaphore );
|
||||
}
|
||||
Reference in New Issue
Block a user