Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
670 changes: 670 additions & 0 deletions FreeRTOS/Test/Target/boards/examples/tests/FreeRTOSConfig.h

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions FreeRTOS/Test/Target/boards/examples/tests/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
*
* 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
*
*/

/*
* This is a simple main that will start the FreeRTOS-Kernel and run a periodic task
* that only delays if compiled with the template port, this project will do nothing.
* For more information on getting started please look here:
* https://www.freertos.org/Documentation/01-FreeRTOS-quick-start/01-Beginners-guide/02-Quick-start-guide
*/

/* FreeRTOS includes. */
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>
#include <timers.h>
#include <semphr.h>

/* Standard includes. */
#include <stdio.h>

/*-----------------------------------------------------------*/

static void exampleTask( void * parameters ) __attribute__( ( noreturn ) );

/*-----------------------------------------------------------*/

extern void vRunTest();

/*-----------------------------------------------------------*/

static void exampleTask( void * parameters )
{
/* Unused parameters. */
( void ) parameters;

vRunTest();

for( ; ; )
{
/* Example Task Code */
vTaskDelay( 100 ); /* delay 100 ticks */
}
}
/*-----------------------------------------------------------*/

int main( void )
{
static StaticTask_t exampleTaskTCB;
static StackType_t exampleTaskStack[ configMINIMAL_STACK_SIZE ];

( void ) printf( "Example FreeRTOS Project\n" );

( void ) xTaskCreateStatic( exampleTask,
"example",
configMINIMAL_STACK_SIZE,
NULL,
configMAX_PRIORITIES - 1U,
&( exampleTaskStack[ 0 ] ),
&( exampleTaskTCB ) );

/* Start the scheduler. */
vTaskStartScheduler();

for( ; ; )
{
/* Should not reach here. */
}

return 0;
}
/*-----------------------------------------------------------*/

#if ( configCHECK_FOR_STACK_OVERFLOW > 0 )

void vApplicationStackOverflowHook( TaskHandle_t xTask,
char * pcTaskName )
{
/* Check pcTaskName for the name of the offending task,
* or pxCurrentTCB if pcTaskName has itself been corrupted. */
( void ) xTask;
( void ) pcTaskName;
}

#endif /* #if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) */
/*-----------------------------------------------------------*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.15)
project(example)

set(FREERTOS_KERNEL_PATH "../../../../../../../Source")

set(TARGET_TEST_PATH "../../../../../tests" )

set(PLATFROM_PATH "../../")

# Add the freertos_config for FreeRTOS-Kernel
add_library(freertos_config INTERFACE)

target_include_directories(freertos_config
INTERFACE
${PLATFROM_PATH}
${TARGET_TEST_PATH}/smp/template
)

# Select the heap port. values between 1-4 will pick a heap.
set(FREERTOS_HEAP "4" CACHE STRING "" FORCE)

# Select the native compile PORT
set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE)

# Adding the FreeRTOS-Kernel subdirectory
add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel)

add_executable(${PROJECT_NAME}
${PLATFROM_PATH}/main.c
${CMAKE_CURRENT_SOURCE_DIR}/test_runner.c
${TARGET_TEST_PATH}/smp/template/test_name.c
)

target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${FREERTOS_KERNEL_PATH}/include
${FREERTOS_PORTABLE_PATH}
${TARGET_TEST_PATH}/include
)

target_link_libraries(${PROJECT_NAME} freertos_kernel freertos_config)

set_property(TARGET freertos_kernel PROPERTY C_STANDARD 90)
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2022 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 test_runner.c
* @brief The implementation of test runner task which runs the test.
*/

/* Kernel includes. */
#include "FreeRTOS.h" /* Must come first. */
#include "task.h" /* RTOS task related API prototypes. */

/*-----------------------------------------------------------*/

/**
* @brief The task that runs the test.
*/
static void prvTestRunnerTask( void * pvParameters );

/**
* @brief The test case to run.
*/
extern void vRunTestCaseName( void );
/*-----------------------------------------------------------*/

UBaseType_t uxTestGetTime( void )
{
return 0U;
}

static void prvTestRunnerTask( void * pvParameters )
{
( void ) pvParameters;

/* Run test case. */
vRunTestCaseName();

vTaskDelete( NULL );
}
/*-----------------------------------------------------------*/

void vRunTest( void )
{
xTaskCreate( prvTestRunnerTask,
"testRunner",
configMINIMAL_STACK_SIZE,
NULL,
configMAX_PRIORITIES - 1,
NULL );
}
/*-----------------------------------------------------------*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2022 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 TEST_SETTING_CONFIG_H
#define TEST_SETTING_CONFIG_H

#define testNOT_USING_UNITY

#define testRUN_TEST_CASE_FUNCTION( fxn ) fxn()

#define testBEGIN_FUNCTION() do{} while( 0 )

#define testEND_FUNCTION() do{} while( 0 )

extern UBaseType_t uxTestGetTime( void );
#define testGET_TIME_FUNCTION uxTestGetTime

#endif /* TEST_SETTING_CONFIG_H */
58 changes: 58 additions & 0 deletions FreeRTOS/Test/Target/tests/include/test_default_setting_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2022 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 TEST_DEFAULT_SETTING_CONFIG_H
#define TEST_DEFAULT_SETTING_CONFIG_H

#ifndef testNOT_USING_UNITY
#include "unity.h"
#endif

#ifndef testRUN_TEST_CASE_FUNCTION
#define testRUN_TEST_CASE_FUNCTION RUN_TEST
#endif

#ifndef testBEGIN_FUNCTION
#define testBEGIN_FUNCTION UNITY_BEGIN
#endif

#ifndef testEND_FUNCTION
#define testEND_FUNCTION UNITY_END
#endif

#ifndef testSETUP_FUNCTION_PROTOTYPE
#define testSETUP_FUNCTION_PROTOTYPE( fxn ) void fxn( void )
#endif

#ifndef testTEARDOWN_FUNCTION_PROTOTYPE
#define testTEARDOWN_FUNCTION_PROTOTYPE( fxn ) void fxn( void )
#endif

#ifndef testENTRY_FUNCTION_PROTOTYPE
#define testENTRY_FUNCTION_PROTOTYPE( fxn ) void fxn( void )
#endif

#endif /* TEST_DEFAULT_SETTING_CONFIG_H */
10 changes: 8 additions & 2 deletions FreeRTOS/Test/Target/tests/smp/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@

1. Create a directory in the target's directory which will contain
the test. For example: `FreeRTOS/Test/Target/boards/pico/tests/smp/multiple_tasks_running`.
1. Create a C file and invoke the test case from a task. The invocation
2. ( optional ) If your platform uses a test framework other than Unity, set `configTARGET_TEST_USE_CUSTOM_SETTING`
to 1 in FreeRTOSConfig.h and create a `test_setting_config.h` header file to
adapt the test framework to your device's requirements.
3. Create a C file and invoke the test case from a task. The invocation
usually looks like the following:
```c
void prvTestRunnerTask( void * pvParameters )
Expand All @@ -33,5 +36,8 @@
vRunTestCaseName();
}
```
1. Add the file created above and the test case file to the build system used
4. Add the file created above and the test case file to the build system used
for the target.

The [example target](../../../boards/examples/tests/smp/template) provides a ready-to-compile
FreeRTOS project template, designed to help newcomers create their own target test projects.
3 changes: 3 additions & 0 deletions FreeRTOS/Test/Target/tests/smp/template/test_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
#undef configUSE_PREEMPTION
#endif /* ifdef configUSE_PREEMPTION */

/* Test case configure depends on test case requirements. */
#define configUSE_PREEMPTION 1

#endif /* ifndef TEST_CONFIG_H */
Loading
Loading