Kernel timers.c tasks.c Unit Test (#539)
* Test: add multi config ability to build system * Remove Tests that are not implemented yet from the makefile * Fix header check * Test: Unit Test tasks.c * UnitTest: tasks.c Save progress * saving some work 70% coverage * coverage 77% * tasks.c coverage 90% * tasks.c coverage 95% * Cleanup and common header * Cover some extra branches, no_mutex +stack growth * Fix Makefile not to use modified version of c-preprocessor * Remove c-preprocessor errros * Rebase and add some tests * Fortify_source=1 and O0 are mutually exclusive * Style: Uncrustify code * Style: Fix indent * Fix Header checks * Add prototypes * Build: use unifdef instead of the c-preprocessor to generate different configurations * Build: fix makefile cflags * Fix UT after upgrading kernel version * Resolve conflicts and test failures * Comment fix version number * Fix build error * Update FreeRTOS/Test/CMock/Makefile Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>pull/842/head
parent
c00078e729
commit
1ac492d6aa
@ -0,0 +1,99 @@
|
||||
COVINFO := $(abspath $(SCRATCH_DIR)/..)/$(EXEC_PREFIX).info
|
||||
COVINFO_INITIAL := $(SCRATCH_DIR)/$(EXEC_PREFIX)_initial.info
|
||||
LCOV_LIST := $(addsuffix .info,$(addprefix $(SCRATCH_DIR)/,$(SUITE_UT_SRC:.c=)))
|
||||
PROJ_GCDA_LIST := $(PROJ_SRC_LIST:.c=.gcda)
|
||||
COV_REPORT_DIR := $(SCRATCH_DIR)/coverage
|
||||
COVINFO_COMBINE := $(SCRATCH_DIR)/$(EXEC_PREFIX)_combined.info
|
||||
|
||||
|
||||
GCOV_OPTS := --unconditional-branches --branch-probabilities
|
||||
|
||||
# Cases that run test binaries cannot be run in parallel.
|
||||
.NOTPARALLEL : $(COVINFO) $(LCOV_LIST) $(PROJ_GCDA_LIST)
|
||||
|
||||
# Prevent deletion of intermediate files
|
||||
NO_DELETE : $(MOCK_HDR_LIST) $(MOCK_SRC_LIST) $(MOCK_OBJ_LIST) \
|
||||
$(DEPS_OBJ_LIST) $(SF_OBJ_LIST) $(EXEC_LIST) \
|
||||
$(PROJ_PP_LIST) $(PROJ_OBJ_LIST) $(PROJ_GCDA_LIST) \
|
||||
$(SUITE_OBJ_LIST) $(RUNNER_SRC_LIST) $(RUNNER_OBJ_LIST) \
|
||||
$(COVINFO) $(LCOV_LIST)
|
||||
|
||||
|
||||
# Generate gcov files by default
|
||||
run : gcov
|
||||
|
||||
gcov : $(PROJ_GCDA_LIST)
|
||||
|
||||
clean :
|
||||
rm -rf $(SCRATCH_DIR)
|
||||
rm -f $(BIN_DIR)/$(PROJECT)_utest_*
|
||||
rm -f $(COVINFO)
|
||||
|
||||
libs :
|
||||
make -C $(UT_ROOT_DIR) libs
|
||||
|
||||
define run-test
|
||||
$(1)
|
||||
endef
|
||||
|
||||
$(PROJ_GCDA_LIST) : $(EXEC_LIST)
|
||||
rm -f $(PROJ_DIR)/*.gcda
|
||||
mkdir -p $(BIN_DIR)
|
||||
# run each test case
|
||||
$(foreach bin,$^,$(call run-test,$(bin)))
|
||||
|
||||
# Run and generate lcov
|
||||
lcov : $(COVINFO)
|
||||
|
||||
lcovhtml : $(COVINFO)
|
||||
mkdir -p $(COV_REPORT_DIR)
|
||||
genhtml $(COVINFO) $(LCOV_OPTS) --output-directory $(COV_REPORT_DIR)
|
||||
|
||||
bin: $(EXEC_LIST)
|
||||
|
||||
# Run and append to gcov data files
|
||||
|
||||
# Generate callgraph for coverage filtering
|
||||
$(PROJ_DIR)/callgraph.json : $(PROJ_SRC_LIST)
|
||||
mkdir -p $(PROJ_DIR)
|
||||
#python3 $(UT_ROOT_DIR)/tools/callgraph.py --out $@ $^
|
||||
|
||||
# Generate baseline inital coverage data from .gcno file
|
||||
$(COVINFO_INITIAL) : $(EXEC_LIST)
|
||||
lcov $(LCOV_OPTS) --capture --initial --directory $(SCRATCH_DIR) -o $@
|
||||
|
||||
# Run the test runner and genrate a filtered gcov.json.gz file
|
||||
$(SCRATCH_DIR)/%_utest.info : $(BIN_DIR)/$(EXEC_PREFIX)_%_utest \
|
||||
$(PROJ_DIR)/callgraph.json
|
||||
# Remove any existing coverage data
|
||||
rm -f $(PROJ_DIR)/*.gcda
|
||||
|
||||
# run the testrunner
|
||||
$<
|
||||
|
||||
lcov $(LCOV_OPTS) --directory $(SCRATCH_DIR) --capture -o $@
|
||||
# Gather coverage into a json.gz file
|
||||
|
||||
#gcov $(GCOV_OPTS) $(SCRATCH_DIR)/$*/$(PROJECT).gcda \
|
||||
# --json-format --stdout | gzip > $(subst .info,.json.gz,$@)
|
||||
|
||||
# Filter coverage based on tags in unit test file
|
||||
# $(TOOLS_DIR)/filtercov.py --in $(subst .info,.json.gz,$@) \
|
||||
# --map $(PROJ_DIR)/callgraph.json \
|
||||
# --test $(PROJ_DIR)/$(PROJECT)_utest_$*.c \
|
||||
# --format lcov \
|
||||
# --out $@
|
||||
lcov $(LCOV_OPTS) --summary $@
|
||||
|
||||
# Remove temporary files
|
||||
rm -f $(subst .info,.json.gz,$@)
|
||||
rm -f $(PROJ_GCDA_LIST)
|
||||
|
||||
# Combine lcov from each test bin into one lcov info file for the suite
|
||||
$(COVINFO_COMBINE) : $(LCOV_LIST)
|
||||
lcov $(LCOV_OPTS) -o $@ $(foreach cov,$(LCOV_LIST),--add-tracefile $(cov) )
|
||||
|
||||
# Add baseline / initial coverage generated by gcc to point out untagged functions
|
||||
$(COVINFO) : $(COVINFO_COMBINE) $(COVINFO_INITIAL)
|
||||
lcov $(LCOV_OPTS) -o $@ --add-tracefile $(COVINFO_INITIAL) --add-tracefile $(COVINFO_COMBINE)
|
||||
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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
|
||||
|
||||
/* XXX: this file will be processed by unifdef to generate new header files
|
||||
* that can be mocked according to the configurations desired
|
||||
* it has a few limitations on the format of this file such as:
|
||||
* no config that spans more than one line
|
||||
* no strings in config names
|
||||
* for more info please check the man file with $ man unifdef
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* 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
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_TICKLESS_IDLE 1
|
||||
#define configUSE_TIME_SLICING 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 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
||||
#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 ( 9 )
|
||||
|
||||
/* 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 0
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
#define portUSING_MPU_WRAPPERS 0
|
||||
#define configENABLE_MPU 0
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING 0
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
|
||||
|
||||
/* Co-routine related configuration options. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
|
||||
/* 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 0
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
|
||||
/* 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 0
|
||||
#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 )
|
||||
#define portREMOVE_STATIC_QUALIFIER 1
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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
|
||||
|
||||
/* XXX: this file will be processed by unifdef to generate new header files
|
||||
* that can be mocked according to the configurations desired
|
||||
* it has a few limitations on the format of this file such as:
|
||||
* no config that spans more than one line
|
||||
* no strings in config names
|
||||
* for more info please check the man file with $ man unifdef
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* 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
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define portSTACK_GROWTH ( 1 )
|
||||
#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 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 0 /* diff config 1 */
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||
#define configUSE_RECURSIVE_MUTEXES 0
|
||||
#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 0
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
#define portUSING_MPU_WRAPPERS 0
|
||||
#define configENABLE_MPU 0
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING 1
|
||||
#define portCRITICAL_NESTING_IN_TCB 1
|
||||
|
||||
/* Co-routine related configuration options. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* 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 0
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
|
||||
/* 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 0
|
||||
#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 )
|
||||
#define portREMOVE_STATIC_QUALIFIER 1
|
||||
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
|
||||
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
@ -0,0 +1,181 @@
|
||||
# Change according to what your unit test directory is.
|
||||
# For example if testing queue.c your directory should be called queue
|
||||
# and the project name should be queue
|
||||
# if testing list.c your directory should be called list
|
||||
# and the project name should be list
|
||||
|
||||
include ../makefile.in
|
||||
|
||||
PROJECT := tasks
|
||||
#
|
||||
# Test/CMock/tasks
|
||||
PROJECT_DIR := $(abspath .)
|
||||
PROJ_DIR := $(abspath .)
|
||||
|
||||
# List the dependency files you wish to mock
|
||||
MOCK_FILES_FP := $(KERNEL_DIR)/include/timers.h
|
||||
MOCK_FILES_FP += $(KERNEL_DIR)/include/list.h
|
||||
MOCK_FILES_FP += $(KERNEL_DIR)/include/portable.h
|
||||
MOCK_FILES_FP += $(PROJECT_DIR)/list_macros.h
|
||||
|
||||
UNDEF_MOCKED_HEADER_MACROS := -UlistLIST_IS_EMPTY -UlistGET_OWNER_OF_HEAD_ENTRY\
|
||||
-UlistIS_CONTAINED_WITHIN -UlistGET_LIST_ITEM_VALUE \
|
||||
-UlistSET_LIST_ITEM_VALUE \
|
||||
-UlistLIST_ITEM_CONTAINER -UlistCURRENT_LIST_LENGTH
|
||||
|
||||
# List special compilation flags for this module
|
||||
CFLAGS += -Wno-unused-function
|
||||
|
||||
# List special preprocessing flags for this module
|
||||
CPPFLAGS +=
|
||||
|
||||
# List special linking flags for this module
|
||||
LDFLAGS +=
|
||||
|
||||
# Makefile Debug Flags (if needed)
|
||||
#MAKEFLAGS += -rR
|
||||
|
||||
# Try not to edit beyond this line
|
||||
|
||||
COVERAGE_OPTS := -fprofile-arcs -ftest-coverage -fprofile-generate
|
||||
|
||||
# build/generated/queue
|
||||
SCRATCH_DIR := $(GENERATED_DIR)/$(PROJECT)
|
||||
|
||||
# list.h timers.h portable.h
|
||||
MOCK_FILES := $(notdir $(MOCK_FILES_FP))
|
||||
|
||||
# ...tasks/%/mocks/mock_list.o tasks/%/mocks/mock_timers.o
|
||||
MOCK_OBJS := $(addprefix $(SCRATCH_DIR)/%/mocks/mock_,$(MOCK_FILES:.h=.o))
|
||||
|
||||
# ...tasks/%/mocks/mock_list.c tasks/%/mocks/mock_timers.c
|
||||
MOCK_SRC_LIST := $(addprefix $(SCRATCH_DIR)/%/mocks/,$(addprefix mock_,$(MOCK_FILES:.h=.c)))
|
||||
|
||||
# tasks/%/cpp/timers.h tasks/%/cpp/list.h
|
||||
CPP_FILES := $(addprefix $(SCRATCH_DIR)/%/cpp/,$(notdir $(MOCK_FILES_FP)))
|
||||
DEP_FILES := $(addsuffix .d,$(addprefix $(SCRATCH_DIR)/%/cpp/,$(notdir $(MOCK_FILES_FP))))
|
||||
|
||||
# tasks_1_utest.c tasks_2_utest.c ...
|
||||
PROJ_SRC_LIST := $(sort $(wildcard $(PROJECT)_*_utest.c))
|
||||
|
||||
# 1_utest.c dynamic_utest.c
|
||||
SUITE_UT_SRC := $(subst $(PROJECT)_,,$(PROJ_SRC_LIST))
|
||||
|
||||
# 1 2 3 config1 assert ...
|
||||
DISCRIMINATOR := $(subst _utest,,$(subst .c,,$(subst $(PROJECT)_,,$(PROJ_SRC_LIST))))
|
||||
|
||||
# tasks/1/mocks tasks/2/mocks
|
||||
MOCK_DIRS := $(addsuffix /mocks,$(addprefix $(SCRATCH_DIR)/,$(DISCRIMINATOR)))
|
||||
# queue/1/cpp queue/2/cpp
|
||||
CPP_DIRS := $(addsuffix /cpp,$(addprefix $(SCRATCH_DIR)/,$(DISCRIMINATOR)))
|
||||
# tasks/1/include tasks/2/include
|
||||
INCLUDE_DIRS := $(addsuffix /include,$(addprefix $(SCRATCH_DIR)/,$(DISCRIMINATOR)))
|
||||
#list/1 list/2 ....
|
||||
CONFIG_DIRS := $(addprefix $(SCRATCH_DIR)/,$(DISCRIMINATOR))
|
||||
|
||||
ifeq ($(MOCK_FILES_FP),)
|
||||
$(shell mkdir -p $(MOCK_DIRS))
|
||||
$(shell for n in $(MOCK_DIRS) ; do touch -a $(n)/mock_dummy.c)
|
||||
endif
|
||||
|
||||
EXEC_LIST := $(addprefix $(BIN_DIR)/,$(patsubst %.c,%,$(PROJ_SRC_LIST)))
|
||||
EXEC_PATH := $(addsuffix _%_utest,$(addprefix $(BIN_DIR)/,$(PROJECT)))
|
||||
PROJ_OBJ_LIST := $(EXEC_LIST)
|
||||
|
||||
.PHONY: all Makefile directories
|
||||
|
||||
.SECONDARY:
|
||||
all : directories $(EXEC_LIST)
|
||||
|
||||
# Build the executables 1 per configuration
|
||||
$(EXEC_PATH) : $(MOCK_OBJS) \
|
||||
$(SCRATCH_DIR)/%/test_runner.o \
|
||||
$(SCRATCH_DIR)/%/$(PROJECT).o \
|
||||
$(SCRATCH_DIR)/%/$(PROJECT)_utest.o \
|
||||
| libs directories
|
||||
$(CC) $+ $(LDFLAGS) -o $@
|
||||
|
||||
# Mock All preprocessed header files
|
||||
$(MOCK_SRC_LIST) : $(CPP_FILES) \
|
||||
Makefile \
|
||||
$(PROJECT_DIR)/$(PROJECT).yml \
|
||||
| directories
|
||||
cd $(@D) && cd .. && \
|
||||
ruby $(CMOCK_EXEC_DIR)/cmock.rb -o$(PROJECT_DIR)/$(PROJECT).yml \
|
||||
$(<D)/*
|
||||
|
||||
# Copy FreeRTOSConfig_$(DISCRIMINATOR).h to the apropriate directory and remove
|
||||
# its guard ( FREERTOS_CONFIG_H ) to be able to be ingested into unifdef
|
||||
$(CPP_FILES) : | directories
|
||||
cp $(PROJECT_DIR)/FreeRTOSConfig_$*.h $(SCRATCH_DIR)/$*/include/FreeRTOSConfig.h
|
||||
cp $(PROJECT_DIR)/FreeRTOSConfig_$*.h $(SCRATCH_DIR)/$*/include/FreeRTOSConfig.def
|
||||
sed -i '/#ifndef FREERTOS_CONFIG_H/d' $(SCRATCH_DIR)/$*/include/FreeRTOSConfig.def
|
||||
sed -i '/#define FREERTOS_CONFIG_H/d' $(SCRATCH_DIR)/$*/include/FreeRTOSConfig.def
|
||||
sed -i '/#endif/d' $(SCRATCH_DIR)/$*/include/FreeRTOSConfig.def
|
||||
for h_file in $(MOCK_FILES_FP) ; do \
|
||||
unifdef -f $(SCRATCH_DIR)/$*/include/FreeRTOSConfig.def $$h_file \
|
||||
> $(SCRATCH_DIR)/$*/cpp/$$(basename $$h_file) ; \
|
||||
done
|
||||
|
||||
# Build ALL the mock objects for the config
|
||||
# This target is called ONLY once per configuration pattern (%)
|
||||
$(MOCK_OBJS) : $(MOCK_SRC_LIST)
|
||||
$(eval INCLUDE = -I$(SCRATCH_DIR)/$*/include)
|
||||
$(eval INCLUDE += -I$(SCRATCH_DIR)/$*/mocks) \
|
||||
$(eval INCLUDE += -I$(KERNEL_DIR)/include) \
|
||||
for files in $^ ; do \
|
||||
new_name=$${files%.c}.o; \
|
||||
$(CC) -c $$files $(INCLUDE) $(CPPFLAGS) $(CFLAGS) -fPIC \
|
||||
-DUNITY_EXCLUDE_MATH_H -DUNITY_EXCLUDE_STDINT_H \
|
||||
-DUNITY_OUTPUT_CHAR -o $$new_name ; \
|
||||
done
|
||||
|
||||
# Build test_runner.o from test_runner.c
|
||||
$(SCRATCH_DIR)/%/test_runner.o : $(SCRATCH_DIR)/%/test_runner.c \
|
||||
$(SCRATCH_DIR)/%/$(PROJECT).o
|
||||
$(eval INCLUDE = -I$(SCRATCH_DIR)/$*/include)
|
||||
$(eval INCLUDE += -I$(SCRATCH_DIR)/$*/mocks)
|
||||
$(eval INCLUDE += -I$(KERNEL_DIR)/include)
|
||||
$(CC) -c $< $(INCLUDE) $(CPPFLAGS) $(CFLAGS) -o $@
|
||||
|
||||
# Build tasks_utest.o from tasks_utest_%.c
|
||||
$(SCRATCH_DIR)/%/$(PROJECT)_utest.o : $(PROJECT_DIR)/$(PROJECT)_%_utest.c \
|
||||
global_vars.h \
|
||||
| directories
|
||||
$(eval INCLUDE = -I$(SCRATCH_DIR)/$*/include)
|
||||
$(eval INCLUDE += -I$(SCRATCH_DIR)/$*/mocks)
|
||||
$(eval INCLUDE += -I$(KERNEL_DIR)/include)
|
||||
$(CC) -c $< $(INCLUDE) $(CPPFLAGS) $(CFLAGS) -o $@
|
||||
|
||||
# Build tasks.o from tasks.i with the custom FreeRTOSConfig.h and place it in
|
||||
# its configuration directory
|
||||
$(SCRATCH_DIR)/%/$(PROJECT).o : $(SCRATCH_DIR)/%/$(PROJECT).i | directories
|
||||
$(CC) -c $< $(CFLAGS) $(COVERAGE_OPTS) -o $@
|
||||
|
||||
# Build tasks.i from tasks.c with the custom FreeRTOSConfig.h and place it in
|
||||
# its configuration directory
|
||||
$(SCRATCH_DIR)/%/$(PROJECT).i : $(KERNEL_DIR)/$(PROJECT).c | directories
|
||||
$(eval INCLUDE = -I$(SCRATCH_DIR)/$*/include)
|
||||
$(eval INCLUDE += -I$(SCRATCH_DIR)/$*/mocks) \
|
||||
$(eval INCLUDE += -I$(KERNEL_DIR)/include) \
|
||||
$(CC) -E $< $(INCLUDE) $(CPPFLAGS) -include list_macros.h -o $@
|
||||
|
||||
# Generate test_runner.c which contains the main function from the test file
|
||||
$(SCRATCH_DIR)/%/test_runner.c : $(PROJECT_DIR)/$(PROJECT)_%_utest.c \
|
||||
Makefile | directories
|
||||
ruby $(UNITY_BIN_DIR)/generate_test_runner.rb "--use_param_tests=1" \
|
||||
$(PROJECT)_$*_utest.c $(PROJECT_DIR)/$(PROJECT).yml $@
|
||||
|
||||
# Create needed directories
|
||||
directories :
|
||||
-mkdir -p $(SCRATCH_DIR)
|
||||
-mkdir -p $(CONFIG_DIRS)
|
||||
-mkdir -p $(MOCK_DIRS)
|
||||
-mkdir -p $(CPP_DIRS)
|
||||
-mkdir -p $(INCLUDE_DIRS)
|
||||
-mkdir -p $(BIN_DIR)
|
||||
-mkdir -p $(LIB_DIR)
|
||||
|
||||
EXEC_PREFIX := $(PROJECT)
|
||||
|
||||
include ../coverage.mk
|
@ -0,0 +1,336 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 GBLOBAL_VARS_H
|
||||
#define GBLOBAL_VARS_H
|
||||
|
||||
#include "task.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */
|
||||
{
|
||||
volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */
|
||||
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */
|
||||
#endif
|
||||
|
||||
ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
|
||||
ListItem_t xEventListItem; /*< Used to reference a task from an event list. */
|
||||
UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */
|
||||
StackType_t * pxStack; /*< Points to the start of the stack. */
|
||||
char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
|
||||
#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
|
||||
StackType_t * pxEndOfStack; /*< Points to the highest valid address for the stack. */
|
||||
#endif
|
||||
|
||||
#if ( portCRITICAL_NESTING_IN_TCB == 1 )
|
||||
UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */
|
||||
#endif
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */
|
||||
UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */
|
||||
#endif
|
||||
|
||||
#if ( configUSE_MUTEXES == 1 )
|
||||
UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */
|
||||
UBaseType_t uxMutexesHeld;
|
||||
#endif
|
||||
|
||||
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
|
||||
TaskHookFunction_t pxTaskTag;
|
||||
#endif
|
||||
|
||||
#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
|
||||
void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
|
||||
#endif
|
||||
|
||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||
uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */
|
||||
#endif
|
||||
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
|
||||
/* Allocate a Newlib reent structure that is specific to this task.
|
||||
* Note Newlib support has been included by popular demand, but is not
|
||||
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
|
||||
* responsible for resulting newlib operation. User must be familiar with
|
||||
* newlib and must provide system-wide implementations of the necessary
|
||||
* stubs. Be warned that (at the time of writing) the current newlib design
|
||||
* implements a system-wide malloc() that must be provided with locks.
|
||||
*
|
||||
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
* for additional information. */
|
||||
struct _reent xNewLib_reent;
|
||||
#endif
|
||||
|
||||
#if ( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
volatile uint32_t ulNotifiedValue[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
|
||||
volatile uint8_t ucNotifyState[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
|
||||
#endif
|
||||
|
||||
/* See the comments in FreeRTOS.h with the definition of
|
||||
* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */
|
||||
#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
|
||||
uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */
|
||||
#endif
|
||||
|
||||
#if ( INCLUDE_xTaskAbortDelay == 1 )
|
||||
uint8_t ucDelayAborted;
|
||||
#endif
|
||||
|
||||
#if ( configUSE_POSIX_ERRNO == 1 )
|
||||
int iTaskErrno;
|
||||
#endif
|
||||
} tskTCB;
|
||||
|
||||
|
||||
/* =========================== DEFINES CONSTANTS ========================== */
|
||||
typedef tskTCB TCB_t;
|
||||
typedef void (* port_yield_operation)( void );
|
||||
|
||||
/* =========================== GLOBAL VARIABLES =========================== */
|
||||
|
||||
|
||||
/* ============================ MACRO FUNCTIONS ============================ */
|
||||
#define ASSERT_IF_IN_ISR_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_assert_if_in_isr_called ); \
|
||||
port_assert_if_in_isr_called = false; \
|
||||
} while( 0 )
|
||||
#define ASSERT_IF_IN_ISR_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_assert_if_in_isr_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_SETUP_TCB_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_setup_tcb_called ); \
|
||||
port_setup_tcb_called = false; \
|
||||
} while( 0 )
|
||||
#define ASSERT_SETUP_TCB_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_setup_tcb_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_YIELD_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_yield_called ); \
|
||||
port_yield_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_YIELD_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_yield_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_ENABLE_INTERRUPT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_enable_interrupts_called ); \
|
||||
port_enable_interrupts_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_ENABLE_INTERRUPT_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_enable_interrupts_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_DISABLE_INTERRUPT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_disable_interrupts_called ); \
|
||||
port_disable_interrupts_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_DISABLE_INTERRUPT_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_disable_interrupts_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_YIELD_WITHIN_API_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_yield_within_api_called ); \
|
||||
port_yield_within_api_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_YIELD_WITHIN_API_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_yield_within_api_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_TASK_DELETE_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( vTaskDeletePre_called ); \
|
||||
vTaskDeletePre_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_TASK_DELETE_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( vTaskDeletePre_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APP_TICK_HOOK_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( vApplicationTickHook_called ); \
|
||||
vApplicationTickHook_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APP_TICK_HOOK_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( vApplicationTickHook_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_CLEAR_INTERRUPT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( portClear_Interrupt_called ); \
|
||||
portClear_Interrupt_called = false; \
|
||||
} while( 0 )
|
||||
#define ASSERT_PORT_CLEAR_INTERRUPT_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( portClear_Interrupt_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_CLEAR_INTERRUPT_FROM_ISR_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( portClear_Interrupt_from_isr_called ); \
|
||||
portClear_Interrupt_from_isr_called = false; \
|
||||
} while( 0 )
|
||||
#define ASSERT_PORT_CLEAR_INTERRUPT_FROM_ISR_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( portClear_Interrupt_from_isr_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_SET_INTERRUPT_FROM_ISR_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( portSet_Interrupt_from_isr_called ); \
|
||||
portSet_Interrupt_from_isr_called = false; \
|
||||
} while( 0 )
|
||||
#define ASSERT_PORT_SET_INTERRUPT_FROM_ISR_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( portSet_Interrupt_from_isr_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_SET_INTERRUPT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( portSet_Interrupt_called ); \
|
||||
portSet_Interrupt_called = false; \
|
||||
} while( 0 )
|
||||
#define ASSERT_PORT_SET_INTERRUPT_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( portSet_Interrupt_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_INVALID_INTERRUPT_PRIORITY_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_invalid_interrupt_called ); \
|
||||
port_invalid_interrupt_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APPLICATION_IDLE_HOOK_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( vApplicationIdleHook_called ); \
|
||||
vApplicationIdleHook_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APPLICATION_IDLE_HOOK_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( vApplicationIdleHook_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APPLICATION_MALLOC_FAILED_HOOK_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( vApplicationMallocFailedHook_called ); \
|
||||
vApplicationMallocFailedHook_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APPLICATION_MALLOC_FAILED_HOOK_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( vApplicationMallocFailedHook_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_ALLOCATE_SECURE_CONTEXT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( port_allocate_secure_context_called ); \
|
||||
port_allocate_secure_context_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_PORT_ALLOCATE_SECURE_CONTEXT_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( port_allocate_secure_context_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APP_STACK_OVERFLOW_HOOK_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( vApplicationStackOverflowHook_called ); \
|
||||
vApplicationStackOverflowHook_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_APP_STACK_OVERFLOW_HOOK_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( vApplicationStackOverflowHook_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_GET_IDLE_TASK_MEMORY_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_TRUE( getIddleTaskMemory_called ); \
|
||||
getIddleTaskMemory_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define ASSERT_GET_IDLE_TASK_MEMORY_NOT_CALLED() \
|
||||
do { \
|
||||
TEST_ASSERT_FALSE( getIddleTaskMemory_called ); \
|
||||
} while( 0 )
|
||||
|
||||
#define RESET_ALL_HOOKS() \
|
||||
do { \
|
||||
vApplicationTickHook_called = false; \
|
||||
vTaskDeletePre_called = false; \
|
||||
getIddleTaskMemory_called = false; \
|
||||
port_yield_called = false; \
|
||||
port_enable_interrupts_called = false; \
|
||||
port_disable_interrupts_called = false; \
|
||||
port_yield_within_api_called = false; \
|
||||
port_setup_tcb_called = false; \
|
||||
portClear_Interrupt_called = false; \
|
||||
portSet_Interrupt_called = false; \
|
||||
portClear_Interrupt_from_isr_called = false; \
|
||||
portSet_Interrupt_from_isr_called = false; \
|
||||
port_invalid_interrupt_called = false; \
|
||||
vApplicationStackOverflowHook_called = false; \
|
||||
port_allocate_secure_context_called = false; \
|
||||
port_assert_if_in_isr_called = false; \
|
||||
} while( 0 )
|
||||
|
||||
#define HOOK_DIAG() \
|
||||
do { \
|
||||
printf( "%s Called\n", __FUNCTION__ ); \
|
||||
} while( 0 )
|
||||
|
||||
#undef HOOK_DIAG
|
||||
#define HOOK_DIAG()
|
||||
|
||||
#endif /* ifndef GBLOBAL_VARS_H */
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 LIST_MACRO_H
|
||||
#define LIST_MACRO_H
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <portmacro.h>
|
||||
#include <list.h>
|
||||
|
||||
struct tskTaskControlBlock;
|
||||
typedef struct tskTaskControlBlock TCB_t;
|
||||
|
||||
#undef listLIST_IS_EMPTY
|
||||
BaseType_t listLIST_IS_EMPTY( const List_t * pxList );
|
||||
|
||||
#undef listGET_OWNER_OF_HEAD_ENTRY
|
||||
TCB_t * listGET_OWNER_OF_HEAD_ENTRY( const List_t * pxList );
|
||||
|
||||
#undef listIS_CONTAINED_WITHIN
|
||||
BaseType_t listIS_CONTAINED_WITHIN( List_t * list,
|
||||
const ListItem_t * listItem );
|
||||
|
||||
#undef listGET_LIST_ITEM_VALUE
|
||||
TickType_t listGET_LIST_ITEM_VALUE( ListItem_t * listItem );
|
||||
|
||||
#undef listSET_LIST_ITEM_VALUE
|
||||
void listSET_LIST_ITEM_VALUE( ListItem_t * listItem,
|
||||
TickType_t itemValue );
|
||||
|
||||
|
||||
#undef listLIST_ITEM_CONTAINER
|
||||
List_t * listLIST_ITEM_CONTAINER( const ListItem_t * listItem );
|
||||
|
||||
#undef listCURRENT_LIST_LENGTH
|
||||
UBaseType_t listCURRENT_LIST_LENGTH( List_t * list );
|
||||
|
||||
#undef listGET_ITEM_VALUE_OF_HEAD_ENTRY
|
||||
TickType_t listGET_ITEM_VALUE_OF_HEAD_ENTRY( List_t * list );
|
||||
|
||||
#undef listGET_LIST_ITEM_OWNER
|
||||
TCB_t * listGET_LIST_ITEM_OWNER( ListItem_t * listItem );
|
||||
|
||||
#undef listINSERT_END
|
||||
void listINSERT_END( List_t * pxList,
|
||||
ListItem_t * listItem );
|
||||
|
||||
#undef listREMOVE_ITEM
|
||||
void listREMOVE_ITEM( ListItem_t * listItem );
|
||||
|
||||
#endif /* ifndef LIST_MACRO_H */
|
@ -0,0 +1,32 @@
|
||||
:cmock:
|
||||
:mock_prefix: mock_
|
||||
:when_no_prototypes: :warn
|
||||
:treat_externs: :include
|
||||
:treat_inlines: :include
|
||||
:enforce_strict_ordering: TRUE
|
||||
:plugins:
|
||||
- :ignore
|
||||
- :ignore_arg
|
||||
- :expect_any_args
|
||||
- :array
|
||||
- :callback
|
||||
- :return_thru_ptr
|
||||
:callback_include_count: true # include a count arg when calling the callback
|
||||
:callback_after_arg_check: false # check arguments before calling the callback
|
||||
:treat_as:
|
||||
uint8: HEX8
|
||||
uint16: HEX16
|
||||
uint32: UINT32
|
||||
int8: INT8
|
||||
bool: UINT8
|
||||
:includes: # This will add these includes to each mock.
|
||||
- "FreeRTOSConfig.h"
|
||||
- "FreeRTOS.h"
|
||||
- "task.h"
|
||||
:weak: __attribute__((weak))
|
||||
:verbosity: 3
|
||||
:attributes:
|
||||
- PRIVILEGED_FUNCTION
|
||||
:strippables:
|
||||
- PRIVILEGED_FUNCTION
|
||||
- portDONT_DISCARD
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,758 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 tasks_utest_2.c */
|
||||
|
||||
/* Tasks includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "task.h"
|
||||
|
||||
#include "mock_list.h"
|
||||
#include "mock_list_macros.h"
|
||||
#include "mock_timers.h"
|
||||
#include "mock_portable.h"
|
||||
|
||||
/* Test includes. */
|
||||
#include "unity.h"
|
||||
#include "global_vars.h"
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* =========================== EXTERN VARIABLES =========================== */
|
||||
extern TCB_t * volatile pxCurrentTCB;
|
||||
extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
|
||||
extern List_t xDelayedTaskList1;
|
||||
extern List_t xDelayedTaskList2;
|
||||
extern List_t * volatile pxDelayedTaskList;
|
||||
extern List_t * volatile pxOverflowDelayedTaskList;
|
||||
extern List_t xPendingReadyList;
|
||||
/* INCLUDE_vTaskDelete */
|
||||
extern List_t xTasksWaitingTermination;
|
||||
extern volatile UBaseType_t uxDeletedTasksWaitingCleanUp;
|
||||
extern List_t xSuspendedTaskList;
|
||||
|
||||
extern volatile UBaseType_t uxCurrentNumberOfTasks;
|
||||
extern volatile TickType_t xTickCount;
|
||||
extern volatile UBaseType_t uxTopReadyPriority;
|
||||
extern volatile BaseType_t xSchedulerRunning;
|
||||
extern volatile TickType_t xPendedTicks;
|
||||
extern volatile BaseType_t xYieldPending;
|
||||
extern volatile BaseType_t xNumOfOverflows;
|
||||
extern UBaseType_t uxTaskNumber;
|
||||
extern volatile TickType_t xNextTaskUnblockTime;
|
||||
extern TaskHandle_t xIdleTaskHandle;
|
||||
extern volatile UBaseType_t uxSchedulerSuspended;
|
||||
|
||||
|
||||
/* =========================== GLOBAL VARIABLES =========================== */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
|
||||
|
||||
static TCB_t * ptcb;
|
||||
static StackType_t stack[ ( ( size_t ) 300 ) * sizeof( StackType_t ) ];
|
||||
static TCB_t tcb[ 10 ]; /* simulate up to 10 tasks: add more if needed */
|
||||
static bool getIddleTaskMemoryValid = false;
|
||||
static uint32_t critical_section_counter = 0;
|
||||
static bool is_first_task = true;
|
||||
static uint32_t created_tasks = 0;
|
||||
static uint32_t create_task_priority = 3;
|
||||
static port_yield_operation py_operation;
|
||||
static bool vTaskDeletePre_called = false;
|
||||
static bool getIddleTaskMemory_called = false;
|
||||
static bool vApplicationTickHook_called = false;
|
||||
static bool port_yield_called = false;
|
||||
static bool port_enable_interrupts_called = false;
|
||||
static bool port_disable_interrupts_called = false;
|
||||
static bool port_yield_within_api_called = false;
|
||||
static bool port_setup_tcb_called = false;
|
||||
static bool portClear_Interrupt_called = false;
|
||||
static bool portSet_Interrupt_called = false;
|
||||
static bool portClear_Interrupt_from_isr_called = false;
|
||||
static bool portSet_Interrupt_from_isr_called = false;
|
||||
static bool port_invalid_interrupt_called = false;
|
||||
static bool vApplicationStackOverflowHook_called = false;
|
||||
static bool vApplicationIdleHook_called = false;
|
||||
static bool port_allocate_secure_context_called = false;
|
||||
static bool port_assert_if_in_isr_called = false;
|
||||
static bool vApplicationMallocFailedHook_called = false;
|
||||
|
||||
|
||||
/* =========================== Static Functions =========================== */
|
||||
static void start_scheduler()
|
||||
{
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
/* set owner */
|
||||
listSET_LIST_ITEM_VALUE_ExpectAnyArgs();
|
||||
/* set owner */
|
||||
|
||||
pxPortInitialiseStack_ExpectAnyArgsAndReturn( uxIdleTaskStack );
|
||||
|
||||
if( is_first_task )
|
||||
{
|
||||
is_first_task = false;
|
||||
|
||||
for( int i = ( UBaseType_t ) 0U; i < ( UBaseType_t ) configMAX_PRIORITIES; i++ )
|
||||
{
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
}
|
||||
|
||||
/* Delayed Task List 1 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Delayed Task List 2 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Pending Ready List */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskDelete */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskSuspend */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
}
|
||||
|
||||
listINSERT_END_ExpectAnyArgs();
|
||||
|
||||
xTimerCreateTimerTask_ExpectAndReturn( pdPASS );
|
||||
xPortStartScheduler_ExpectAndReturn( pdTRUE );
|
||||
getIddleTaskMemoryValid = true;
|
||||
vTaskStartScheduler();
|
||||
ASSERT_GET_IDLE_TASK_MEMORY_CALLED();
|
||||
TEST_ASSERT_TRUE( xSchedulerRunning );
|
||||
TEST_ASSERT_EQUAL( configINITIAL_TICK_COUNT, xTickCount );
|
||||
TEST_ASSERT_EQUAL( portMAX_DELAY, xNextTaskUnblockTime );
|
||||
}
|
||||
static TaskHandle_t create_task()
|
||||
{
|
||||
TaskFunction_t pxTaskCode = NULL;
|
||||
const char * const pcName = { __FUNCTION__ };
|
||||
const uint32_t usStackDepth = 300;
|
||||
void * const pvParameters = NULL;
|
||||
UBaseType_t uxPriority = create_task_priority;
|
||||
TaskHandle_t taskHandle;
|
||||
BaseType_t ret;
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( TCB_t ), &tcb[ created_tasks ] );
|
||||
pvPortMalloc_ExpectAndReturn( usStackDepth * sizeof( StackType_t ), stack );
|
||||
|
||||
vListInitialiseItem_Expect( &( tcb[ created_tasks ].xStateListItem ) );
|
||||
vListInitialiseItem_Expect( &( tcb[ created_tasks ].xEventListItem ) );
|
||||
/* TODO: expect set owner */
|
||||
listSET_LIST_ITEM_VALUE_ExpectAnyArgs();
|
||||
/* TODO: expect set owner */
|
||||
|
||||
pxPortInitialiseStack_ExpectAnyArgsAndReturn( stack );
|
||||
|
||||
if( is_first_task )
|
||||
{
|
||||
/* prvInitialiseTaskLists */
|
||||
for( int i = ( UBaseType_t ) 0U; i < ( UBaseType_t ) configMAX_PRIORITIES; i++ )
|
||||
{
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
}
|
||||
|
||||
/* Delayed Task List 1 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Delayed Task List 2 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Pending Ready List */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskDelete */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskSuspend */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
is_first_task = false;
|
||||
}
|
||||
|
||||
/* prvAddTaskToReadyList */
|
||||
listINSERT_END_ExpectAnyArgs();
|
||||
ret = xTaskCreate( pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
pvParameters,
|
||||
uxPriority,
|
||||
&taskHandle );
|
||||
TEST_ASSERT_EQUAL( pdPASS, ret );
|
||||
ASSERT_SETUP_TCB_CALLED();
|
||||
created_tasks++;
|
||||
return taskHandle;
|
||||
}
|
||||
/* ============================ HOOK FUNCTIONS ============================ */
|
||||
static void dummy_operation()
|
||||
{
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
void vFakePortAssertIfISR( void )
|
||||
{
|
||||
port_assert_if_in_isr_called = true;
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
void port_allocate_secure_context( BaseType_t stackSize )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
port_allocate_secure_context_called = true;
|
||||
}
|
||||
|
||||
void vApplicationIdleHook( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
vApplicationIdleHook_called = true;
|
||||
}
|
||||
|
||||
void vApplicationMallocFailedHook( void )
|
||||
{
|
||||
vApplicationMallocFailedHook_called = true;
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
|
||||
StackType_t ** ppxIdleTaskStackBuffer,
|
||||
uint32_t * pulIdleTaskStackSize )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
|
||||
if( getIddleTaskMemoryValid == true )
|
||||
{
|
||||
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
|
||||
* state will be stored. */
|
||||
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
|
||||
|
||||
/* Pass out the array that will be used as the Idle task's stack. */
|
||||
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
|
||||
|
||||
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
|
||||
* Note that, as the array is necessarily of type StackType_t,
|
||||
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
|
||||
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppxIdleTaskTCBBuffer = NULL;
|
||||
*ppxIdleTaskStackBuffer = NULL;
|
||||
*pulIdleTaskStackSize = 0;
|
||||
}
|
||||
|
||||
getIddleTaskMemory_called = true;
|
||||
}
|
||||
|
||||
void vConfigureTimerForRunTimeStats( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
long unsigned int ulGetRunTimeCounterValue( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
return 3;
|
||||
}
|
||||
|
||||
void vApplicationTickHook()
|
||||
{
|
||||
HOOK_DIAG();
|
||||
vApplicationTickHook_called = true;
|
||||
}
|
||||
|
||||
void vPortCurrentTaskDying( void * pvTaskToDelete,
|
||||
volatile BaseType_t * pxPendYield )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
vTaskDeletePre_called = true;
|
||||
}
|
||||
|
||||
void vFakePortEnterCriticalSection( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
critical_section_counter++;
|
||||
}
|
||||
|
||||
void vFakePortExitCriticalSection( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
critical_section_counter--;
|
||||
}
|
||||
|
||||
void vFakePortYieldWithinAPI()
|
||||
{
|
||||
HOOK_DIAG();
|
||||
port_yield_within_api_called = true;
|
||||
py_operation();
|
||||
}
|
||||
|
||||
void vFakePortYieldFromISR()
|
||||
{
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
void vFakePortDisableInterrupts()
|
||||
{
|
||||
port_disable_interrupts_called = true;
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
void vFakePortEnableInterrupts()
|
||||
{
|
||||
port_enable_interrupts_called = true;
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
void vFakePortYield()
|
||||
{
|
||||
HOOK_DIAG();
|
||||
port_yield_called = true;
|
||||
py_operation();
|
||||
}
|
||||
|
||||
void portSetupTCB_CB( void * tcb )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
port_setup_tcb_called = true;
|
||||
}
|
||||
|
||||
void vFakePortClearInterruptMask( UBaseType_t bt )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
portClear_Interrupt_called = true;
|
||||
}
|
||||
|
||||
UBaseType_t ulFakePortSetInterruptMask( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
portSet_Interrupt_called = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void vFakePortClearInterruptMaskFromISR( UBaseType_t bt )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
portClear_Interrupt_from_isr_called = true;
|
||||
}
|
||||
|
||||
UBaseType_t ulFakePortSetInterruptMaskFromISR( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
portSet_Interrupt_from_isr_called = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void vFakePortAssertIfInterruptPriorityInvalid( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
port_invalid_interrupt_called = true;
|
||||
}
|
||||
|
||||
void vApplicationStackOverflowHook( TaskHandle_t xTask,
|
||||
char * stack )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
vApplicationStackOverflowHook_called = true;
|
||||
}
|
||||
|
||||
/* ============================ Unity Fixtures ============================ */
|
||||
/*! called before each testcase */
|
||||
void setUp( void )
|
||||
{
|
||||
RESET_ALL_HOOKS();
|
||||
|
||||
pxCurrentTCB = NULL;
|
||||
memset( &tcb, 0x00, sizeof( TCB_t ) );
|
||||
ptcb = NULL;
|
||||
memset( &pxReadyTasksLists, 0x00, configMAX_PRIORITIES * sizeof( List_t ) );
|
||||
memset( &xDelayedTaskList1, 0x00, sizeof( List_t ) );
|
||||
memset( &xDelayedTaskList2, 0x00, sizeof( List_t ) );
|
||||
|
||||
/*
|
||||
* pxDelayedTaskList = NULL;
|
||||
* pxOverflowDelayedTaskList = NULL;
|
||||
*/
|
||||
memset( &xPendingReadyList, 0x00, sizeof( List_t ) );
|
||||
|
||||
memset( &xTasksWaitingTermination, 0x00, sizeof( List_t ) );
|
||||
uxDeletedTasksWaitingCleanUp = 0;
|
||||
memset( &xSuspendedTaskList, 0x00, sizeof( List_t ) );
|
||||
|
||||
uxCurrentNumberOfTasks = ( UBaseType_t ) 0U;
|
||||
xTickCount = ( TickType_t ) 500; /* configINITIAL_TICK_COUNT */
|
||||
uxTopReadyPriority = tskIDLE_PRIORITY;
|
||||
xSchedulerRunning = pdFALSE;
|
||||
xPendedTicks = ( TickType_t ) 0U;
|
||||
xYieldPending = pdFALSE;
|
||||
xNumOfOverflows = ( BaseType_t ) 0;
|
||||
uxTaskNumber = ( UBaseType_t ) 0U;
|
||||
xNextTaskUnblockTime = ( TickType_t ) 0U;
|
||||
xIdleTaskHandle = NULL;
|
||||
uxSchedulerSuspended = ( UBaseType_t ) 0;
|
||||
/* ulTaskSwitchedInTime = 0UL; */
|
||||
/*ulTotalRunTime = 0UL; */
|
||||
is_first_task = true;
|
||||
created_tasks = 0;
|
||||
|
||||
py_operation = dummy_operation;
|
||||
}
|
||||
|
||||
/*! called after each testcase */
|
||||
void tearDown( void )
|
||||
{
|
||||
TEST_ASSERT_EQUAL( 0, critical_section_counter );
|
||||
}
|
||||
|
||||
/*! called at the beginning of the whole suite */
|
||||
void suiteSetUp()
|
||||
{
|
||||
}
|
||||
|
||||
/*! called at the end of the whole suite */
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return numFailures;
|
||||
}
|
||||
|
||||
/* ============================== Test Cases ============================== */
|
||||
|
||||
/*!
|
||||
* @brief create a static new task with a success path
|
||||
*/
|
||||
void test_xTaskCreateStatic_success( void )
|
||||
{
|
||||
StackType_t puxStackBuffer[ 300 ];
|
||||
StaticTask_t * pxTaskBuffer = malloc( sizeof( TCB_t ) );
|
||||
TaskFunction_t pxTaskCode = NULL;
|
||||
const char * const pcName = { __FUNCTION__ };
|
||||
const uint32_t ulStackDepth = 300;
|
||||
void * const pvParameters = NULL;
|
||||
UBaseType_t uxPriority = 3;
|
||||
TaskHandle_t ret;
|
||||
|
||||
/* Setup */
|
||||
memset( puxStackBuffer, 0xa5U, ulStackDepth * sizeof( StackType_t ) );
|
||||
|
||||
/* Expectations */
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
|
||||
listSET_LIST_ITEM_VALUE_ExpectAnyArgs();
|
||||
pxPortInitialiseStack_ExpectAnyArgsAndReturn( puxStackBuffer );
|
||||
|
||||
for( int i = ( UBaseType_t ) 0U; i < ( UBaseType_t ) configMAX_PRIORITIES; i++ )
|
||||
{
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
}
|
||||
|
||||
/* Delayed Task List 1 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Delayed Task List 2 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Pending Ready List */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskDelete */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskSuspend */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
|
||||
listINSERT_END_ExpectAnyArgs();
|
||||
|
||||
/* API Call */
|
||||
ret = xTaskCreateStatic( pxTaskCode,
|
||||
pcName,
|
||||
ulStackDepth,
|
||||
pvParameters,
|
||||
uxPriority,
|
||||
puxStackBuffer,
|
||||
pxTaskBuffer );
|
||||
ptcb = ( TCB_t * ) pxTaskBuffer;
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL_PTR( puxStackBuffer, ptcb->pxStack );
|
||||
TEST_ASSERT_NOT_EQUAL( NULL, ret );
|
||||
TEST_ASSERT_EQUAL( 2, ptcb->ucStaticallyAllocated );
|
||||
TEST_ASSERT_EQUAL( 0,
|
||||
memcmp( ptcb->pxStack,
|
||||
puxStackBuffer,
|
||||
ulStackDepth * sizeof( StackType_t ) ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( ptcb->pxEndOfStack,
|
||||
ptcb->pxStack + ( 300 - 1 ) );
|
||||
TEST_ASSERT_EQUAL( 0, memcmp( ptcb->pcTaskName, pcName, configMAX_TASK_NAME_LEN - 1 ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( ptcb->uxPriority, uxPriority );
|
||||
|
||||
TEST_ASSERT_EQUAL( 1, uxCurrentNumberOfTasks );
|
||||
ASSERT_SETUP_TCB_CALLED();
|
||||
free( pxTaskBuffer );
|
||||
}
|
||||
|
||||
void test_xTaskCreate_success( void )
|
||||
{
|
||||
TaskFunction_t pxTaskCode = NULL;
|
||||
const char * const pcName = NULL;
|
||||
const uint32_t usStackDepth = 300;
|
||||
void * const pvParameters = NULL;
|
||||
UBaseType_t uxPriority = configMAX_PRIORITIES;
|
||||
TaskHandle_t taskHandle;
|
||||
BaseType_t ret;
|
||||
StackType_t stack[ ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ];
|
||||
|
||||
/* Setup */
|
||||
/* Expectations */
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( TCB_t ), &tcb[ 0 ] );
|
||||
pvPortMalloc_ExpectAndReturn( usStackDepth * sizeof( StackType_t ), stack );
|
||||
|
||||
vListInitialiseItem_Expect( &( tcb[ 0 ].xStateListItem ) );
|
||||
vListInitialiseItem_Expect( &( tcb[ 0 ].xEventListItem ) );
|
||||
listSET_LIST_ITEM_VALUE_ExpectAnyArgs();
|
||||
pxPortInitialiseStack_ExpectAnyArgsAndReturn( stack );
|
||||
|
||||
for( int i = ( UBaseType_t ) 0U; i < ( UBaseType_t ) configMAX_PRIORITIES; i++ )
|
||||
{
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
}
|
||||
|
||||
/* Delayed Task List 1 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Delayed Task List 2 */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* Pending Ready List */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskDelete */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
/* INCLUDE_vTaskSuspend */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
|
||||
listINSERT_END_ExpectAnyArgs();
|
||||
|
||||
/* API Call */
|
||||
ret = xTaskCreate( pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
pvParameters,
|
||||
uxPriority,
|
||||
&taskHandle );
|
||||
/* Validations */
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL( pdPASS, ret );
|
||||
TEST_ASSERT_EQUAL( 0, tcb[ 0 ].ucStaticallyAllocated );
|
||||
TEST_ASSERT_EQUAL_PTR( &tcb[ 0 ], ptcb );
|
||||
TEST_ASSERT_EQUAL( stack, tcb[ 0 ].pxStack );
|
||||
TEST_ASSERT_EQUAL( 1, uxCurrentNumberOfTasks );
|
||||
TEST_ASSERT_EQUAL( configMAX_PRIORITIES - 1, ptcb->uxPriority );
|
||||
TEST_ASSERT_EQUAL( NULL, ptcb->pcTaskName[ 0 ] );
|
||||
ASSERT_SETUP_TCB_CALLED();
|
||||
}
|
||||
|
||||
void test_xTaskCreate_fail_stack_malloc( void )
|
||||
{
|
||||
TaskFunction_t pxTaskCode = NULL;
|
||||
const char * const pcName = { __FUNCTION__ };
|
||||
const uint32_t usStackDepth = 300;
|
||||
void * const pvParameters = NULL;
|
||||
UBaseType_t uxPriority = 3;
|
||||
TaskHandle_t taskHandle;
|
||||
BaseType_t ret;
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( TCB_t ), NULL );
|
||||
|
||||
ret = xTaskCreate( pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
pvParameters,
|
||||
uxPriority,
|
||||
&taskHandle );
|
||||
TEST_ASSERT_EQUAL( errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY, ret );
|
||||
TEST_ASSERT_EQUAL( 0, uxCurrentNumberOfTasks );
|
||||
ASSERT_SETUP_TCB_NOT_CALLED();
|
||||
}
|
||||
|
||||
void test_xTaskCreate_fail_tcb_malloc( void )
|
||||
{
|
||||
TaskFunction_t pxTaskCode = NULL;
|
||||
const char * const pcName = { __FUNCTION__ };
|
||||
const uint32_t usStackDepth = 300;
|
||||
void * const pvParameters = NULL;
|
||||
UBaseType_t uxPriority = 3;
|
||||
TaskHandle_t taskHandle;
|
||||
BaseType_t ret;
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( TCB_t ), &tcb[ 0 ] );
|
||||
pvPortMalloc_ExpectAndReturn( usStackDepth * sizeof( StackType_t ), NULL );
|
||||
vPortFree_Expect( &tcb[ 0 ] );
|
||||
|
||||
ret = xTaskCreate( pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
pvParameters,
|
||||
uxPriority,
|
||||
&taskHandle );
|
||||
TEST_ASSERT_EQUAL( errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY, ret );
|
||||
TEST_ASSERT_EQUAL( 0, uxCurrentNumberOfTasks );
|
||||
ASSERT_SETUP_TCB_NOT_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskPrioritySet_success_gt_curr_prio( void )
|
||||
{
|
||||
TaskHandle_t taskHandle2;
|
||||
TCB_t * ptcb;
|
||||
|
||||
create_task_priority = 3;
|
||||
create_task();
|
||||
create_task_priority = 4;
|
||||
taskHandle2 = create_task();
|
||||
ptcb = ( TCB_t * ) taskHandle2;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, taskHandle2 );
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( 0 );
|
||||
listSET_LIST_ITEM_VALUE_Expect( &( ptcb->xEventListItem ),
|
||||
configMAX_PRIORITIES - 5 );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ 5 ],
|
||||
&( ptcb->xStateListItem ),
|
||||
pdTRUE );
|
||||
uxListRemove_ExpectAndReturn( &( ptcb->xStateListItem ), 0 );
|
||||
/* port Reset ready priority */
|
||||
/* add task to ready list macro */
|
||||
|
||||
listINSERT_END_Expect( &( pxReadyTasksLists[ 5 ] ),
|
||||
&( ptcb->xStateListItem ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( 4, ptcb->uxPriority );
|
||||
vTaskPrioritySet( taskHandle2, create_task_priority + 1 );
|
||||
TEST_ASSERT_EQUAL( 4 + 1, ptcb->uxPriority );
|
||||
ASSERT_PORT_YIELD_NOT_CALLED();
|
||||
}
|
||||
/* ----------------- testing portCRITICAL_NESTING_IN_TCB ------------------- */
|
||||
|
||||
void vTaskEnterCritical( void );
|
||||
void vTaskExitCritical( void );
|
||||
|
||||
void test_vTaskExitCritical_succes( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
start_scheduler();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskExitCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 0, task_handle->uxCriticalNesting );
|
||||
ASSERT_PORT_ENABLE_INTERRUPT_NOT_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskExitCritical_success_enable_interrupts( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
start_scheduler();
|
||||
vTaskEnterCritical();
|
||||
ASSERT_IF_IN_ISR_CALLED();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskExitCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 0, task_handle->uxCriticalNesting );
|
||||
ASSERT_PORT_ENABLE_INTERRUPT_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskExitCritical_success_enable_too_many_nests( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
start_scheduler();
|
||||
vTaskEnterCritical();
|
||||
ASSERT_IF_IN_ISR_CALLED();
|
||||
vTaskEnterCritical();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskExitCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 1, task_handle->uxCriticalNesting );
|
||||
ASSERT_PORT_ENABLE_INTERRUPT_NOT_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskExitCritical_scheduler_off( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskExitCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 0, task_handle->uxCriticalNesting );
|
||||
ASSERT_PORT_ENABLE_INTERRUPT_NOT_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskEnterCritical_succes( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
start_scheduler();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskEnterCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 1, task_handle->uxCriticalNesting );
|
||||
ASSERT_IF_IN_ISR_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskEnterCritical_succes_twice( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
start_scheduler();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskEnterCritical();
|
||||
ASSERT_IF_IN_ISR_CALLED();
|
||||
vTaskEnterCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 2, task_handle->uxCriticalNesting );
|
||||
ASSERT_IF_IN_ISR_NOT_CALLED();
|
||||
}
|
||||
|
||||
void test_vTaskEnterCritical_no_op_no_sched( void )
|
||||
{
|
||||
TaskHandle_t task_handle;
|
||||
|
||||
/* Setup */
|
||||
task_handle = create_task();
|
||||
/* Expectations */
|
||||
/* API Call */
|
||||
vTaskEnterCritical();
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 0, task_handle->uxCriticalNesting );
|
||||
ASSERT_IF_IN_ISR_NOT_CALLED();
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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
|
||||
|
||||
/* XXX: this file will be processed by unifdef to generate new header files
|
||||
* that can be mocked according to the configurations desired
|
||||
* it has a few limitations on the format of this file such as:
|
||||
* no config that spans more than one line
|
||||
* no strings in config names
|
||||
* for more info please check the man file with $ man unifdef
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* 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
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_TICKLESS_IDLE 1
|
||||
#define configUSE_TIME_SLICING 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 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
||||
#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 configSUPPORT_DYNAMIC_ALLOCATION 0
|
||||
#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 ( 9 )
|
||||
|
||||
/* 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 0
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
#define portUSING_MPU_WRAPPERS 0
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING 0
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
|
||||
|
||||
/* Co-routine related configuration options. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
|
||||
/* 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 0
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
|
||||
/* 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 0
|
||||
#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 )
|
||||
#define portREMOVE_STATIC_QUALIFIER 1
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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
|
||||
|
||||
/* XXX: this file will be processed by unifdef to generate new header files
|
||||
* that can be mocked according to the configurations desired
|
||||
* it has a few limitations on the format of this file such as:
|
||||
* no config that spans more than one line
|
||||
* no strings in config names
|
||||
* for more info please check the man file with $ man unifdef
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* 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
|
||||
* http://www.freertos.org/a00110.html
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#define configUSE_TICKLESS_IDLE 1
|
||||
#define configUSE_TIME_SLICING 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 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 1
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
||||
#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 0
|
||||
#define configSUPPORT_DYNAMIC_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 ( 9 )
|
||||
|
||||
/* 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 0
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
|
||||
#define portUSING_MPU_WRAPPERS 0
|
||||
#define portHAS_STACK_OVERFLOW_CHECKING 0
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
|
||||
|
||||
/* Co-routine related configuration options. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
#define portSTACK_GROWTH ( -1 )
|
||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||
|
||||
/* 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 0
|
||||
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
|
||||
|
||||
/* 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 0
|
||||
#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 )
|
||||
#define portREMOVE_STATIC_QUALIFIER 1
|
||||
|
||||
#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0
|
||||
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 GLOBAL_VARS_H
|
||||
#define GLOBAL_VARS_H
|
||||
|
||||
#include "timers.h"
|
||||
/* ====================== DEFINITIONS FROM timers.c ======================== */
|
||||
#define tmrNO_DELAY ( TickType_t ) 0U
|
||||
|
||||
#define tmrSTATUS_IS_ACTIVE ( ( uint8_t ) 0x01 )
|
||||
#define tmrSTATUS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 0x02 )
|
||||
#define tmrSTATUS_IS_AUTORELOAD ( ( uint8_t ) 0x04 )
|
||||
|
||||
#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 )
|
||||
#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 )
|
||||
#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 )
|
||||
#define tmrCOMMAND_START ( ( BaseType_t ) 1 )
|
||||
#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 )
|
||||
#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 )
|
||||
#define tmrCOMMAND_CHANGE_PERIOD ( ( BaseType_t ) 4 )
|
||||
#define tmrCOMMAND_DELETE ( ( BaseType_t ) 5 )
|
||||
|
||||
#define tmrFIRST_FROM_ISR_COMMAND ( ( BaseType_t ) 6 )
|
||||
#define tmrCOMMAND_START_FROM_ISR ( ( BaseType_t ) 6 )
|
||||
#define tmrCOMMAND_RESET_FROM_ISR ( ( BaseType_t ) 7 )
|
||||
#define tmrCOMMAND_STOP_FROM_ISR ( ( BaseType_t ) 8 )
|
||||
#define tmrCOMMAND_CHANGE_PERIOD_FROM_ISR ( ( BaseType_t ) 9 )
|
||||
|
||||
typedef struct tmrTimerControl /* The old naming convention is used to prevent breaking kernel aware debuggers. */
|
||||
{
|
||||
const char * pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
ListItem_t xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */
|
||||
TickType_t xTimerPeriodInTicks; /*<< How quickly and often the timer expires. */
|
||||
void * pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */
|
||||
TimerCallbackFunction_t pxCallbackFunction; /*<< The function that will be called when the timer expires. */
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxTimerNumber; /*<< An ID assigned by trace tools such as FreeRTOS+Trace */
|
||||
#endif
|
||||
uint8_t ucStatus; /*<< Holds bits to say if the timer was statically allocated or not, and if it is active or not. */
|
||||
} xTIMER;
|
||||
|
||||
typedef xTIMER Timer_t;
|
||||
|
||||
typedef struct tmrTimerParameters
|
||||
{
|
||||
TickType_t xMessageValue; /*<< An optional value used by a subset of commands, for example, when changing the period of a timer. */
|
||||
Timer_t * pxTimer; /*<< The timer to which the command will be applied. */
|
||||
} TimerParameter_t;
|
||||
|
||||
typedef struct tmrCallbackParameters
|
||||
{
|
||||
PendedFunction_t pxCallbackFunction; /* << The callback function to execute. */
|
||||
void * pvParameter1; /* << The value that will be used as the callback functions first parameter. */
|
||||
uint32_t ulParameter2; /* << The value that will be used as the callback functions second parameter. */
|
||||
} CallbackParameters_t;
|
||||
|
||||
typedef struct tmrTimerQueueMessage
|
||||
{
|
||||
BaseType_t xMessageID; /*<< The command being sent to the timer service task. */
|
||||
union
|
||||
{
|
||||
TimerParameter_t xTimerParameters;
|
||||
|
||||
/* Don't include xCallbackParameters if it is not going to be used as
|
||||
* it makes the structure (and therefore the timer queue) larger. */
|
||||
#if ( INCLUDE_xTimerPendFunctionCall == 1 )
|
||||
CallbackParameters_t xCallbackParameters;
|
||||
#endif /* INCLUDE_xTimerPendFunctionCall */
|
||||
} u;
|
||||
} DaemonTaskMessage_t;
|
||||
|
||||
|
||||
#define HOOK_DIAG() \
|
||||
do { \
|
||||
printf( "%s Called\n", __FUNCTION__ ); \
|
||||
} while( 0 )
|
||||
|
||||
|
||||
/*#undef HOOK_DIAG */
|
||||
/*#idefine HOOK_DIAG() */
|
||||
#endif /* ifndef GLOBAL_VARS_H */
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 LIST_MACRO_H
|
||||
#define LIST_MACRO_H
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <portmacro.h>
|
||||
#include <list.h>
|
||||
|
||||
#undef listLIST_IS_EMPTY
|
||||
BaseType_t listLIST_IS_EMPTY( const List_t * pxList );
|
||||
|
||||
#undef listGET_OWNER_OF_HEAD_ENTRY
|
||||
void * listGET_OWNER_OF_HEAD_ENTRY( const List_t * pxList );
|
||||
|
||||
#undef listIS_CONTAINED_WITHIN
|
||||
BaseType_t listIS_CONTAINED_WITHIN( List_t * list,
|
||||
const ListItem_t * listItem );
|
||||
|
||||
#undef listGET_LIST_ITEM_VALUE
|
||||
TickType_t listGET_LIST_ITEM_VALUE( ListItem_t * listItem );
|
||||
|
||||
#undef listSET_LIST_ITEM_VALUE
|
||||
void listSET_LIST_ITEM_VALUE( ListItem_t * listItem,
|
||||
TickType_t itemValue );
|
||||
|
||||
#undef listLIST_ITEM_CONTAINER
|
||||
List_t * listLIST_ITEM_CONTAINER( const ListItem_t * listItem );
|
||||
|
||||
#undef listCURRENT_LIST_LENGTH
|
||||
UBaseType_t listCURRENT_LIST_LENGTH( List_t * list );
|
||||
|
||||
#undef listGET_ITEM_VALUE_OF_HEAD_ENTRY
|
||||
TickType_t listGET_ITEM_VALUE_OF_HEAD_ENTRY( List_t * list );
|
||||
|
||||
#undef listGET_LIST_ITEM_OWNER
|
||||
void * listGET_LIST_ITEM_OWNER( ListItem_t * listItem );
|
||||
|
||||
#endif /* ifndef LIST_MACRO_H */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,482 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 timers_utest.c */
|
||||
|
||||
|
||||
/* Test includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "portmacro.h"
|
||||
#include "timers.h"
|
||||
|
||||
#include "global_vars.h"
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_memory.h"
|
||||
|
||||
/* Mock includes. */
|
||||
#include "mock_queue.h"
|
||||
#include "mock_list.h"
|
||||
#include "mock_list_macros.h"
|
||||
#include "mock_fake_assert.h"
|
||||
#include "mock_portable.h"
|
||||
#include "mock_task.h"
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
|
||||
void stopTimers();
|
||||
|
||||
/* ============================ GLOBAL VARIABLES =========================== */
|
||||
static uint16_t usMallocFreeCalls = 0;
|
||||
static uint32_t critical_section_counter;
|
||||
static bool port_yield_within_api_called = false;
|
||||
static TickType_t saved_last_time = 0;
|
||||
|
||||
/* ============================= FUNCTION HOOKS =========================== */
|
||||
void vFakePortEnterCriticalSection( void )
|
||||
{
|
||||
critical_section_counter++;
|
||||
}
|
||||
|
||||
void vFakePortExitCriticalSection( void )
|
||||
{
|
||||
critical_section_counter--;
|
||||
}
|
||||
|
||||
void vFakePortYieldWithinAPI()
|
||||
{
|
||||
HOOK_DIAG();
|
||||
port_yield_within_api_called = true;
|
||||
pthread_exit( NULL );
|
||||
}
|
||||
|
||||
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
|
||||
StackType_t ** ppxTimerTaskStackBuffer,
|
||||
uint32_t * pulTimerTaskStackSize )
|
||||
{
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
|
||||
void vApplicationDaemonTaskStartupHook( void )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
}
|
||||
/* ========================== CALLBACK FUNCTIONS =========================== */
|
||||
static void xCallback_Test( TimerHandle_t xTimer )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
}
|
||||
|
||||
static int32_t end_2_timer = 0;
|
||||
static void xCallback_Test_2_end( TimerHandle_t xTimer )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
static int i = 2;
|
||||
|
||||
if( end_2_timer - 1 <= 0 )
|
||||
{
|
||||
pthread_exit( &i );
|
||||
}
|
||||
|
||||
end_2_timer--;
|
||||
}
|
||||
|
||||
static int32_t end_4_timer = 0;
|
||||
static void pended_function_4_end( void * arg1,
|
||||
uint32_t arg2 )
|
||||
{
|
||||
HOOK_DIAG();
|
||||
static int i = 4;
|
||||
|
||||
if( end_4_timer - 1 <= 0 )
|
||||
{
|
||||
pthread_exit( &i );
|
||||
}
|
||||
|
||||
end_4_timer--;
|
||||
}
|
||||
|
||||
/* ============================ STATIC FUNCTIONS =========================== */
|
||||
static void * timer_thread_function( void * args )
|
||||
{
|
||||
void * pvParameters = NULL;
|
||||
|
||||
portTASK_FUNCTION( prvTimerTask, pvParameters );
|
||||
( void ) fool_static2; /* ignore unused variable warning */
|
||||
/* API Call */
|
||||
prvTimerTask( pvParameters );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ============================== UNITY FIXTURES ========================== */
|
||||
|
||||
void setUp( void )
|
||||
{
|
||||
vFakeAssert_Ignore();
|
||||
port_yield_within_api_called = false;
|
||||
/* Track calls to malloc / free */
|
||||
UnityMalloc_StartTest();
|
||||
critical_section_counter = 0;
|
||||
end_2_timer = 0;
|
||||
end_4_timer = 0;
|
||||
stopTimers();
|
||||
}
|
||||
|
||||
/*! called before each testcase */
|
||||
void tearDown( void )
|
||||
{
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE( 0, usMallocFreeCalls,
|
||||
"free is not called the same number of times as malloc,"
|
||||
"you might have a memory leak!!" );
|
||||
usMallocFreeCalls = 0;
|
||||
|
||||
UnityMalloc_EndTest();
|
||||
}
|
||||
|
||||
/*! called at the beginning of the whole suite */
|
||||
void suiteSetUp()
|
||||
{
|
||||
}
|
||||
|
||||
/*! called at the end of the whole suite */
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return numFailures;
|
||||
}
|
||||
|
||||
|
||||
/* ============================== TEST FUNCTIONS ========================== */
|
||||
|
||||
/**
|
||||
* @brief xTimerCreate happy path
|
||||
*
|
||||
*/
|
||||
void test_xTimerCreateTimerTask_success( void )
|
||||
{
|
||||
BaseType_t ret_xtimer;
|
||||
QueueHandle_t queue_handle = ( QueueHandle_t ) 3; /* not zero */
|
||||
|
||||
/* Setup */
|
||||
/* Expectations */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
xQueueGenericCreate_ExpectAnyArgsAndReturn( queue_handle );
|
||||
vQueueAddToRegistry_ExpectAnyArgs();
|
||||
xTaskCreate_ExpectAnyArgsAndReturn( pdTRUE );
|
||||
/* API Call */
|
||||
ret_xtimer = xTimerCreateTimerTask();
|
||||
/* Validations */
|
||||
TEST_ASSERT_TRUE( ret_xtimer );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief xTimerCreate happy path
|
||||
*
|
||||
*/
|
||||
void test_xTimerCreate_success( void )
|
||||
{
|
||||
uint32_t ulID = 0;
|
||||
TimerHandle_t xTimer = NULL;
|
||||
Timer_t pxNewTimer;
|
||||
QueueHandle_t queue_handle = ( QueueHandle_t ) 3; /* not zero */
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer );
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
xQueueGenericCreate_ExpectAnyArgsAndReturn( queue_handle );
|
||||
vQueueAddToRegistry_ExpectAnyArgs();
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdTRUE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
|
||||
TEST_ASSERT_NOT_EQUAL( NULL, xTimer );
|
||||
TEST_ASSERT_EQUAL_PTR( &pxNewTimer, xTimer );
|
||||
TEST_ASSERT_EQUAL( tmrSTATUS_IS_AUTORELOAD, pxNewTimer.ucStatus );
|
||||
TEST_ASSERT_EQUAL_STRING( "ut-timer", pxNewTimer.pcTimerName );
|
||||
TEST_ASSERT_EQUAL( pdMS_TO_TICKS( 1000 ), pxNewTimer.xTimerPeriodInTicks );
|
||||
TEST_ASSERT_EQUAL_PTR( &ulID, pxNewTimer.pvTimerID );
|
||||
TEST_ASSERT_EQUAL_PTR( xCallback_Test, pxNewTimer.pxCallbackFunction );
|
||||
}
|
||||
|
||||
void test_xTimerCreate_success_no_auto_reload( void )
|
||||
{
|
||||
uint32_t ulID = 0;
|
||||
TimerHandle_t xTimer = NULL;
|
||||
Timer_t pxNewTimer;
|
||||
QueueHandle_t queue_handle = ( QueueHandle_t ) 3; /* not zero */
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer );
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
xQueueGenericCreate_ExpectAnyArgsAndReturn( queue_handle );
|
||||
vQueueAddToRegistry_ExpectAnyArgs();
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdFALSE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR( &pxNewTimer, xTimer );
|
||||
TEST_ASSERT_EQUAL( 0, pxNewTimer.ucStatus );
|
||||
}
|
||||
|
||||
void test_xTimerCreate_success_twice( void )
|
||||
{
|
||||
uint32_t ulID = 0;
|
||||
TimerHandle_t xTimer = NULL;
|
||||
Timer_t pxNewTimer;
|
||||
QueueHandle_t queue_handle = ( QueueHandle_t ) 3; /* not zero */
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer );
|
||||
/* prvInitialiseNewTimer */
|
||||
/* prvCheckForValidListAndQueue */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
xQueueGenericCreate_ExpectAnyArgsAndReturn( queue_handle );
|
||||
vQueueAddToRegistry_ExpectAnyArgs();
|
||||
/* back prvInitialiseNewTimer */
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdTRUE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR( &pxNewTimer, xTimer );
|
||||
TEST_ASSERT_EQUAL_PTR( &pxNewTimer, xTimer );
|
||||
TEST_ASSERT_EQUAL( tmrSTATUS_IS_AUTORELOAD, pxNewTimer.ucStatus );
|
||||
TEST_ASSERT_EQUAL_STRING( "ut-timer", pxNewTimer.pcTimerName );
|
||||
TEST_ASSERT_EQUAL( pdMS_TO_TICKS( 1000 ), pxNewTimer.xTimerPeriodInTicks );
|
||||
TEST_ASSERT_EQUAL_PTR( &ulID, pxNewTimer.pvTimerID );
|
||||
TEST_ASSERT_EQUAL_PTR( xCallback_Test, pxNewTimer.pxCallbackFunction );
|
||||
|
||||
/* Second call to xTimerCreate */
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer );
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdTRUE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
TEST_ASSERT_EQUAL_PTR( &pxNewTimer, xTimer );
|
||||
}
|
||||
|
||||
void test_xTimerCreate_fail_timer_allocation( void )
|
||||
{
|
||||
uint32_t ulID = 0;
|
||||
TimerHandle_t xTimer = NULL;
|
||||
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), NULL );
|
||||
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdTRUE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
|
||||
TEST_ASSERT_EQUAL( NULL, xTimer );
|
||||
}
|
||||
void test_xTimerCreate_fail_queue_allocation( void )
|
||||
{
|
||||
uint32_t ulID = 0;
|
||||
Timer_t pxNewTimer;
|
||||
TimerHandle_t xTimer = NULL;
|
||||
|
||||
/* Expectations */
|
||||
pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer );
|
||||
/* prvInitialiseNewTimer */
|
||||
/* prvCheckForValidListAndQueue */
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
vListInitialise_ExpectAnyArgs();
|
||||
xQueueGenericCreate_ExpectAnyArgsAndReturn( NULL );
|
||||
/* Back prvInitialiseNewTimer */
|
||||
vListInitialiseItem_ExpectAnyArgs();
|
||||
|
||||
/* API Call */
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdTRUE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( &pxNewTimer, xTimer );
|
||||
}
|
||||
|
||||
void test_timer_function_success3_command_delete_dynamic( void )
|
||||
{
|
||||
Timer_t xTimer = { 0 };
|
||||
Timer_t xTimer2 = { 0 };
|
||||
pthread_t thread_id;
|
||||
int * retVal;
|
||||
|
||||
DaemonTaskMessage_t xMessage;
|
||||
DaemonTaskMessage_t xMessage2;
|
||||
CallbackParameters_t callback_param;
|
||||
|
||||
end_2_timer = 2;
|
||||
end_4_timer = 1;
|
||||
|
||||
/* Setup */
|
||||
xTimer.ucStatus |= tmrSTATUS_IS_AUTORELOAD;
|
||||
xTimer.ucStatus &= ~tmrSTATUS_IS_STATICALLY_ALLOCATED;
|
||||
xTimer.ucStatus &= ~tmrSTATUS_IS_ACTIVE;
|
||||
xTimer.pxCallbackFunction = xCallback_Test_2_end;
|
||||
xTimer.xTimerPeriodInTicks = UINT32_MAX;
|
||||
|
||||
xTimer2.ucStatus |= tmrSTATUS_IS_AUTORELOAD;
|
||||
xTimer2.pxCallbackFunction = xCallback_Test_2_end;
|
||||
xTimer2.xTimerPeriodInTicks = saved_last_time;
|
||||
|
||||
callback_param.pxCallbackFunction = &pended_function_4_end;
|
||||
callback_param.pvParameter1 = NULL;
|
||||
callback_param.ulParameter2 = 0xa9a9a9a9;
|
||||
|
||||
xMessage.xMessageID = tmrCOMMAND_DELETE;
|
||||
xMessage.u.xCallbackParameters = callback_param;
|
||||
xMessage.u.xTimerParameters.pxTimer = &xTimer;
|
||||
xMessage.u.xTimerParameters.xMessageValue = saved_last_time;
|
||||
|
||||
xMessage2.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK; /* used to end the loop */
|
||||
xMessage2.u.xCallbackParameters = callback_param;
|
||||
/* Expectations */
|
||||
/* prvGetNextExpireTime */
|
||||
listLIST_IS_EMPTY_ExpectAnyArgsAndReturn( pdFALSE );
|
||||
listGET_ITEM_VALUE_OF_HEAD_ENTRY_ExpectAnyArgsAndReturn( 3 );
|
||||
/* prvProcessTimerOrBlockTask */
|
||||
vTaskSuspendAll_Expect();
|
||||
/* prvSampleTimeNow */
|
||||
xTaskGetTickCount_ExpectAndReturn( saved_last_time ); /* time now / static last_time = 0 */
|
||||
/* back to prvProcessTimerOrBlockTask */
|
||||
vQueueWaitForMessageRestricted_ExpectAnyArgs();
|
||||
xTaskResumeAll_ExpectAndReturn( pdTRUE );
|
||||
/* prvProcessReceivedCommands */
|
||||
xQueueReceive_ExpectAndReturn( NULL, NULL, tmrNO_DELAY, pdPASS );
|
||||
xQueueReceive_IgnoreArg_xQueue();
|
||||
xQueueReceive_IgnoreArg_pvBuffer();
|
||||
xQueueReceive_ReturnMemThruPtr_pvBuffer( &xMessage, sizeof( DaemonTaskMessage_t ) );
|
||||
listIS_CONTAINED_WITHIN_ExpectAnyArgsAndReturn( pdFALSE );
|
||||
uxListRemove_ExpectAnyArgsAndReturn( pdTRUE );
|
||||
/* prvSampleTimeNow*/
|
||||
xTaskGetTickCount_ExpectAndReturn( saved_last_time ); /* time now / static last_time = 0 */
|
||||
vPortFree_Expect( &xTimer ); /* testcase is testing this clause */
|
||||
/* back to prvProcessReceivedCommands */
|
||||
xQueueReceive_ExpectAndReturn( NULL, NULL, tmrNO_DELAY, pdPASS );
|
||||
xQueueReceive_IgnoreArg_xQueue();
|
||||
xQueueReceive_IgnoreArg_pvBuffer();
|
||||
xQueueReceive_ReturnMemThruPtr_pvBuffer( &xMessage2, sizeof( DaemonTaskMessage_t ) );
|
||||
/* API Call */
|
||||
pthread_create( &thread_id, NULL, &timer_thread_function, NULL );
|
||||
pthread_join( thread_id, ( void ** ) &retVal );
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 4, *retVal );
|
||||
}
|
||||
|
||||
void test_timer_function_success3_command_delete_static( void )
|
||||
{
|
||||
Timer_t xTimer = { 0 };
|
||||
Timer_t xTimer2 = { 0 };
|
||||
pthread_t thread_id;
|
||||
int * retVal;
|
||||
|
||||
DaemonTaskMessage_t xMessage;
|
||||
DaemonTaskMessage_t xMessage2;
|
||||
CallbackParameters_t callback_param;
|
||||
|
||||
end_2_timer = 2;
|
||||
end_4_timer = 1;
|
||||
|
||||
/* Setup */
|
||||
xTimer.ucStatus |= tmrSTATUS_IS_AUTORELOAD;
|
||||
xTimer.ucStatus |= tmrSTATUS_IS_STATICALLY_ALLOCATED;
|
||||
xTimer.ucStatus &= ~tmrSTATUS_IS_ACTIVE;
|
||||
xTimer.pxCallbackFunction = xCallback_Test_2_end;
|
||||
xTimer.xTimerPeriodInTicks = UINT32_MAX;
|
||||
|
||||
xTimer2.ucStatus |= tmrSTATUS_IS_AUTORELOAD;
|
||||
xTimer2.pxCallbackFunction = xCallback_Test_2_end;
|
||||
xTimer2.xTimerPeriodInTicks = saved_last_time;
|
||||
|
||||
callback_param.pxCallbackFunction = &pended_function_4_end;
|
||||
callback_param.pvParameter1 = NULL;
|
||||
callback_param.ulParameter2 = 0xa9a9a9a9;
|
||||
|
||||
xMessage.xMessageID = tmrCOMMAND_DELETE;
|
||||
xMessage.u.xCallbackParameters = callback_param;
|
||||
xMessage.u.xTimerParameters.pxTimer = &xTimer;
|
||||
xMessage.u.xTimerParameters.xMessageValue = saved_last_time;
|
||||
|
||||
xMessage2.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK; /* used to end the loop */
|
||||
xMessage2.u.xCallbackParameters = callback_param;
|
||||
/* Expectations */
|
||||
/* prvGetNextExpireTime */
|
||||
listLIST_IS_EMPTY_ExpectAnyArgsAndReturn( pdFALSE );
|
||||
listGET_ITEM_VALUE_OF_HEAD_ENTRY_ExpectAnyArgsAndReturn( 3 );
|
||||
/* prvProcessTimerOrBlockTask */
|
||||
vTaskSuspendAll_Expect();
|
||||
/* prvSampleTimeNow */
|
||||
xTaskGetTickCount_ExpectAndReturn( saved_last_time ); /* time now / static last_time = 0 */
|
||||
/* back to prvProcessTimerOrBlockTask */
|
||||
vQueueWaitForMessageRestricted_ExpectAnyArgs();
|
||||
xTaskResumeAll_ExpectAndReturn( pdTRUE );
|
||||
/* prvProcessExpiredTimer */
|
||||
/* prvInsertTimerInActiveList */
|
||||
/* prvProcessReceivedCommands */
|
||||
xQueueReceive_ExpectAndReturn( NULL, NULL, tmrNO_DELAY, pdPASS );
|
||||
xQueueReceive_IgnoreArg_xQueue();
|
||||
xQueueReceive_IgnoreArg_pvBuffer();
|
||||
xQueueReceive_ReturnMemThruPtr_pvBuffer( &xMessage, sizeof( DaemonTaskMessage_t ) );
|
||||
listIS_CONTAINED_WITHIN_ExpectAnyArgsAndReturn( pdFALSE );
|
||||
uxListRemove_ExpectAnyArgsAndReturn( pdTRUE );
|
||||
/* prvSampleTimeNow*/
|
||||
xTaskGetTickCount_ExpectAndReturn( saved_last_time ); /* time now / static last_time = 0 */
|
||||
/* back to prvProcessReceivedCommands */
|
||||
xQueueReceive_ExpectAndReturn( NULL, NULL, tmrNO_DELAY, pdPASS );
|
||||
xQueueReceive_IgnoreArg_xQueue();
|
||||
xQueueReceive_IgnoreArg_pvBuffer();
|
||||
xQueueReceive_ReturnMemThruPtr_pvBuffer( &xMessage2, sizeof( DaemonTaskMessage_t ) );
|
||||
/* API Call */
|
||||
pthread_create( &thread_id, NULL, &timer_thread_function, NULL );
|
||||
pthread_join( thread_id, ( void ** ) &retVal );
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 4, *retVal );
|
||||
TEST_ASSERT_FALSE( xTimer.ucStatus & tmrSTATUS_IS_ACTIVE );
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* 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 timers_utest.c */
|
||||
|
||||
/* C runtime includes. */
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Test includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "timers.h"
|
||||
#include "unity.h"
|
||||
#include "unity_memory.h"
|
||||
|
||||
/* Mock includes. */
|
||||
#include "mock_queue.h"
|
||||
#include "mock_list.h"
|
||||
#include "mock_fake_assert.h"
|
||||
|
||||
|
||||
/* ============================ GLOBAL VARIABLES =========================== */
|
||||
static uint16_t usMallocFreeCalls = 0;
|
||||
|
||||
/* ========================== CALLBACK FUNCTIONS =========================== */
|
||||
|
||||
void * pvPortMalloc( size_t xSize )
|
||||
{
|
||||
return unity_malloc( xSize );
|
||||
}
|
||||
void vPortFree( void * pv )
|
||||
{
|
||||
return unity_free( pv );
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Unity fixtures
|
||||
******************************************************************************/
|
||||
void setUp( void )
|
||||
{
|
||||
vFakeAssert_Ignore();
|
||||
|
||||
/* Track calls to malloc / free */
|
||||
UnityMalloc_StartTest();
|
||||
}
|
||||
|
||||
/*! called before each testcase */
|
||||
void tearDown( void )
|
||||
{
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE( 0, usMallocFreeCalls,
|
||||
"free is not called the same number of times as malloc,"
|
||||
"you might have a memory leak!!" );
|
||||
usMallocFreeCalls = 0;
|
||||
|
||||
UnityMalloc_EndTest();
|
||||
}
|
||||
|
||||
/*! called at the beginning of the whole suite */
|
||||
void suiteSetUp()
|
||||
{
|
||||
}
|
||||
|
||||
/*! called at the end of the whole suite */
|
||||
int suiteTearDown( int numFailures )
|
||||
{
|
||||
return numFailures;
|
||||
}
|
||||
|
||||
static void xCallback_Test( TimerHandle_t xTimer )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief xTimerCreate happy path
|
||||
*
|
||||
*/
|
||||
void test_xTimerCreate_Success( void )
|
||||
{
|
||||
uint32_t ulID = 0;
|
||||
TimerHandle_t xTimer = NULL;
|
||||
|
||||
vListInitialise_Ignore();
|
||||
xQueueGenericCreateStatic_IgnoreAndReturn( ( QueueHandle_t ) 1 );
|
||||
vQueueAddToRegistry_Ignore();
|
||||
vListInitialiseItem_Ignore();
|
||||
|
||||
xTimer = xTimerCreate( "ut-timer",
|
||||
pdMS_TO_TICKS( 1000 ),
|
||||
pdTRUE,
|
||||
&ulID,
|
||||
xCallback_Test );
|
||||
|
||||
TEST_ASSERT_NOT_EQUAL( NULL, xTimer );
|
||||
|
||||
/* HACK: Free the timer directly */
|
||||
vPortFree( ( void * ) xTimer );
|
||||
}
|
||||
|
||||
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
|
||||
StackType_t ** ppxTimerTaskStackBuffer,
|
||||
uint32_t * pulTimerTaskStackSize )
|
||||
{
|
||||
static StaticTask_t xTimerTaskTCB;
|
||||
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
|
||||
|
||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
}
|
||||
|
||||
void vApplicationDaemonTaskStartupHook( void )
|
||||
{
|
||||
}
|
Loading…
Reference in New Issue