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
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
}
else
{
rc = FreeRTOS_inet_pton( FREERTOS_AF_INET4, configECHO_SERVER_ADDR_STRING, ( void * ) xEchoServerAddress.sin_address.xIP_IPv6.ucBytes );
rc = FreeRTOS_inet_pton( FREERTOS_AF_INET4, configECHO_SERVER_ADDR_STRING, ( void * ) &( xEchoServerAddress.sin_address.ulIP_IPv4 ) );
configASSERT( rc == pdPASS );
xFamily = FREERTOS_AF_INET4;
}
Expand Down
3 changes: 3 additions & 0 deletions FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput,
/* The command was found, but the number of parameters with the command
* was incorrect. */
strncpy( pcWriteBuffer, "Incorrect command parameter(s). Enter \"help\" to view a list of available commands.\r\n\r\n", xWriteBufferLen );
pcWriteBuffer[ xWriteBufferLen - 1 ] = '\0';
pxCommand = NULL;
}
else if( pxCommand != NULL )
Expand All @@ -220,6 +221,7 @@ BaseType_t FreeRTOS_CLIProcessCommand( const char * const pcCommandInput,
{
/* pxCommand was NULL, the command was not found. */
strncpy( pcWriteBuffer, "Command not recognised. Enter 'help' to view a list of available commands.\r\n\r\n", xWriteBufferLen );
pcWriteBuffer[ xWriteBufferLen - 1 ] = '\0';
xReturn = pdFALSE;
}

Expand Down Expand Up @@ -340,6 +342,7 @@ static BaseType_t prvHelpCommand( char * pcWriteBuffer,
/* Return the next command help string, before moving the pointer on to
* the next command in the list. */
strncpy( pcWriteBuffer, pxCommand->pxCommandLineDefinition->pcHelpString, xWriteBufferLen );
pcWriteBuffer[ xWriteBufferLen - 1 ] = '\0';
pxCommand = pxCommand->pxNext;

if( pxCommand == NULL )
Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP
Submodule FreeRTOS-Plus-TCP updated 0 files
2 changes: 1 addition & 1 deletion FreeRTOS/Source
Submodule Source updated 182 files
8 changes: 4 additions & 4 deletions FreeRTOS/Test/CBMC/proofs/make_common_makefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import argparse

def cleanup_whitespace(string):
return re.sub('\s+', ' ', string.strip())
return re.sub(r'\s+', ' ', string.strip())

################################################################
# Operating system specific values
Expand Down Expand Up @@ -83,9 +83,9 @@ def patch_compile_output(opsys, line, key, value):

if key in ["COMPILE_ONLY", "COMPILE_LINK"] and value is not None:
if value[-1] == '/Fo':
return re.sub('/Fo\s+', '/Fo', line)
return re.sub(r'/Fo\s+', '/Fo', line)
if value[-1] == '/Fe':
return re.sub('/Fe\s+', '/Fe', line)
return re.sub(r'/Fe\s+', '/Fe', line)
return line

################################################################
Expand Down Expand Up @@ -181,7 +181,7 @@ def write_makefile(opsys, template, defines, makefile):
with open(template) as _template:
for line in _template:
line = patch_path_separator(opsys, line)
keys = re.findall('@(\w+)@', line)
keys = re.findall(r'@(\w+)@', line)
values = [find_definition(key, defines) for key in keys]
for key, value in zip(keys, values):
if value is not None:
Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS/Test/CBMC/proofs/make_proof_makefiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def prolog():

On Windows ->

H_INC = /Imy\cool\directory
H_INC = /Imy\\cool\\directory
H_DEF = /DHALF=/2

When invoked, this script walks the directory tree looking for files
Expand Down
1 change: 1 addition & 0 deletions FreeRTOS/Test/CMock/event_groups/event_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
:strippables:
- PRIVILEGED_FUNCTION
- portDONT_DISCARD
- '(?:BaseType_t\s+xTimerDelete\s*\([\s\w,\n\t]*\)[\s\w,\n\t]*\s*;\s*)'
:treat_externs: :include
71 changes: 71 additions & 0 deletions FreeRTOS/Test/CMock/queue/generic/queue_delete_dynamic_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,74 @@ void test_vQueueDelete_full( void )
vQueueDelete( xQueue );
TEST_ASSERT_EQUAL_PTR( ( void * ) xQueue, getLastFreedAddress() );
}

/**
* @brief Test vQueueDelete asserts when tasks are waiting to send and waiting to receive
* @details Verify that vQueueDelete triggers a configASSERT when both the
* xTasksWaitingToSend and xTasksWaitingToReceive lists are non-empty.
* @coverage vQueueDelete
*/
void test_vQueueDelete_assert_tasks_waiting_to_send_and_receive( void )
{
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );

/* Add a fake task to the WaitingToSend list */
td_task_addFakeTaskWaitingToSendToQueue( xQueue );

/* Expect the assert to fire due to non-empty WaitingToSend list */
EXPECT_ASSERT_BREAK( vQueueDelete( xQueue ) );

/* Clean up the fake task from the list */
td_task_removeFakeTaskFromList();

/* Now add a fake task to WaitingToReceive and verify that assert fires too */
td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );

EXPECT_ASSERT_BREAK( vQueueDelete( xQueue ) );

/* Clean up and delete */
td_task_removeFakeTaskFromList();
vQueueDelete( xQueue );
}

/**
* @brief Test vQueueDelete asserts when tasks are waiting to send only
* @details Verify that vQueueDelete triggers a configASSERT when the
* xTasksWaitingToSend list is non-empty.
* @coverage vQueueDelete
*/
void test_vQueueDelete_assert_tasks_waiting_to_send( void )
{
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );

/* Add a fake task to the WaitingToSend list */
td_task_addFakeTaskWaitingToSendToQueue( xQueue );

/* Expect the assert to fire due to non-empty WaitingToSend list */
EXPECT_ASSERT_BREAK( vQueueDelete( xQueue ) );

/* Clean up and delete */
td_task_removeFakeTaskFromList();
vQueueDelete( xQueue );
}

/**
* @brief Test vQueueDelete asserts when tasks are waiting to receive only
* @details Verify that vQueueDelete triggers a configASSERT when the
* xTasksWaitingToReceive list is non-empty.
* @coverage vQueueDelete
*/
void test_vQueueDelete_assert_tasks_waiting_to_receive( void )
{
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );

/* Add a fake task to the WaitingToReceive list */
td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );

/* Expect the assert to fire due to non-empty WaitingToReceive list */
EXPECT_ASSERT_BREAK( vQueueDelete( xQueue ) );

/* Clean up and delete */
td_task_removeFakeTaskFromList();
vQueueDelete( xQueue );
}
7 changes: 7 additions & 0 deletions FreeRTOS/Test/CMock/queue/queue_utest_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ void td_task_addFakeTaskWaitingToSendToQueue( QueueHandle_t xQueue );
*/
void td_task_addFakeTaskWaitingToReceiveFromQueue( QueueHandle_t xQueue );

/**
* @brief Remove the fake task from whatever waiting list it is currently in.
* @details This should be called before deleting a queue that has a fake task
* in one of its waiting lists (xTasksWaitingToSend or xTasksWaitingToReceive).
*/
void td_task_removeFakeTaskFromList( void );

/**
* @brief Test double for xTaskCheckForTimeOut
*/
Expand Down
3 changes: 3 additions & 0 deletions FreeRTOS/Test/CMock/queue/semaphore/mutex_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ void test_macro_xSemaphoreTake_blocking_mutex_inherit_timeout_high_prio_waiting(

TEST_ASSERT_EQUAL( TICKS_TO_WAIT + 1, td_task_getCount_YieldFromTaskResumeAll() );

/* Remove the fake task from the waiting list before deleting the semaphore */
td_task_removeFakeTaskFromList();

vSemaphoreDelete( xSemaphore );
}

Expand Down
8 changes: 8 additions & 0 deletions FreeRTOS/Test/CMock/queue/td_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ void td_task_addFakeTaskWaitingToReceiveFromQueue( QueueHandle_t xQueue )
vListInsert( pxTasksWaitingToReceive, &fakeTaskListItem );
}

void td_task_removeFakeTaskFromList( void )
{
if( listLIST_ITEM_CONTAINER( &fakeTaskListItem ) != NULL )
{
uxListRemove( &fakeTaskListItem );
}
}

TickType_t td_task_getFakeTaskPriority( void )
{
return( configMAX_PRIORITIES - fakeTaskListItem.xItemValue );
Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS/Test/CMock/smp/smp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
:strippables:
- PRIVILEGED_FUNCTION
- portDONT_DISCARD

- '(?:BaseType_t\s+xTimerDelete\s*\([\s\w,\n\t]*\)[\s\w,\n\t]*\s*;\s*)'
78 changes: 78 additions & 0 deletions FreeRTOS/Test/Target/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Test framework

Every test file is written against a small set of `test*` macros instead of
calling Unity APIs directly. This lets each target choose its own test
framework without changing any test source file:

| Macro | Default (Unity) | Purpose |
| --- | --- | --- |
| `testSETUP_FUNCTION_PROTOTYPE( fxn )` | `void fxn( void )` | Declares the `setUp` function run before each test case. |
| `testTEARDOWN_FUNCTION_PROTOTYPE( fxn )` | `void fxn( void )` | Declares the `tearDown` function run after each test case. |
| `testENTRY_FUNCTION_PROTOTYPE( fxn )` | `void fxn( void )` | Declares the function a test runner task calls to run the test. |
| `testBEGIN_FUNCTION()` | `UNITY_BEGIN()` | Called at the start of the entry function. |
| `testRUN_TEST_CASE_FUNCTION( fxn )` | `RUN_TEST( fxn )` | Runs a single test case. |
| `testEND_FUNCTION()` | `UNITY_END()` | Called at the end of the entry function. |

These macros are defined in `tests/include/test_default_setting_config.h`,
which every test file includes (see `tests/smp/template/test_name.c` for the
required include order). If a macro is already defined - for example by a
target-specific `test_setting_config.h` - the default in
`test_default_setting_config.h` is skipped, so targets only need to override
the macros that differ from the Unity-based default.

If a target needs a test framework other than Unity, or otherwise needs to
override any of the macros above:

1. Create a `test_setting_config.h` header for the target with `#define`s for
the macros that need to be overridden. Define `testNOT_USING_UNITY` in it
if the target does not use Unity at all, since `test_default_setting_config.h`
otherwise includes `unity.h` unconditionally.
1. Set `configTARGET_TEST_USE_CUSTOM_SETTING` to `1` in the target's
`FreeRTOSConfig.h` so that the test files pick up `test_setting_config.h`.

# How to add a new test?

1. Create a directory in the `tests` directory which will contain the test.
For example: `tests/smp/multiple_tasks_running`.
1. Copy the `test_name.c` and `test_config.h` files from `tests/smp/template`
to the newly created directory above.
1. Rename the `test_name.c` according to the test name.
1. Implement the test in the above test file, using the `test*` macros
described above (`testSETUP_FUNCTION_PROTOTYPE`, `testTEARDOWN_FUNCTION_PROTOTYPE`,
`testENTRY_FUNCTION_PROTOTYPE`, `testBEGIN_FUNCTION`,
`testRUN_TEST_CASE_FUNCTION`, `testEND_FUNCTION`) instead of calling Unity
APIs directly, so the test can run under any target's test framework.
1. Add any FreeRTOS specific configuration required for the test to `test_config.h`.

# How to add a new target?

1. Create a target specific directory in the `boards` directory.
1. Create required build files.
- Include `test_config.h` in `FreeRTOSConfig.h` at the end.
- Ensure that the following configurations are not defined in `FreeRTOSConfig.h` as those are defined in `test_config.h`:
- `configRUN_MULTIPLE_PRIORITIES`
- `configUSE_CORE_AFFINITY`
- `configUSE_MINIMAL_IDLE_HOOK`
- `configUSE_TASK_PREEMPTION_DISABLE`
- `configUSE_TIME_SLICING`
- `configUSE_PREEMPTION`
- If the target uses the default Unity-based test framework, no further
action is required. If it needs to customize the test framework, add a
`test_setting_config.h` and set `configTARGET_TEST_USE_CUSTOM_SETTING`
to `1`, as described in [Test framework](#test-framework) above.

# How to add a test to a target

1. Create a directory in the target's directory which will contain
the test. For example: `boards/pico/tests/smp/multiple_tasks_running`.
1. Create a C file and invoke the test case from a task. The invocation
usually looks like the following:
```c
void prvTestRunnerTask( void * pvParameters )
{
/* Invoke the test case. */
vRunTestCaseName();
}
```
1. Add the file created above and the test case file to the build system used
for the target.
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) 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 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 */
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@
#include "FreeRTOS.h"
#include "task.h"

/* Unit testing support functions. */
#include "unity.h"
#ifndef TEST_CONFIG_H
#error test_config.h must be included at the end of FreeRTOSConfig.h.
#endif

#if ( configTARGET_TEST_USE_CUSTOM_SETTING == 1 )
#include "test_setting_config.h"
#endif

#include "test_default_setting_config.h"
/*-----------------------------------------------------------*/

/**
Expand Down Expand Up @@ -200,7 +207,7 @@ void Test_DisableMultiplePriorities( void )
/*-----------------------------------------------------------*/

/* Runs before every test, put init calls here. */
void setUp( void )
testSETUP_FUNCTION_PROTOTYPE( setUp )
{
uint32_t i;

Expand All @@ -214,7 +221,7 @@ void setUp( void )
/*-----------------------------------------------------------*/

/* Runs after every test, put clean-up calls here. */
void tearDown( void )
testTEARDOWN_FUNCTION_PROTOTYPE( tearDown )
{
uint32_t i;

Expand All @@ -233,12 +240,12 @@ void tearDown( void )
/**
* @brief Entry point for test runner to run disable multiple priorities test.
*/
void vRunDisableMultiplePrioritiesTest( void )
testENTRY_FUNCTION_PROTOTYPE( vRunDisableMultiplePrioritiesTest )
{
UNITY_BEGIN();
testBEGIN_FUNCTION();

RUN_TEST( Test_DisableMultiplePriorities );
testRUN_TEST_CASE_FUNCTION( Test_DisableMultiplePriorities );

UNITY_END();
testEND_FUNCTION();
}
/*-----------------------------------------------------------*/
Loading
Loading