diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml index 3eb1cd3b6..21b4a1db4 100644 --- a/.github/workflows/codeql-build.yml +++ b/.github/workflows/codeql-build.yml @@ -3,115 +3,11 @@ name: "CodeQL Analysis" on: push: pull_request: - -env: - SIMULATION: native - ENABLE_UNIT_TESTS: true - OMIT_DEPRECATED: true - BUILDTYPE: release - + jobs: - #Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action. - check-for-duplicates: - runs-on: ubuntu-latest - # Map a step output to a job output - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@master - with: - concurrent_skipping: 'same_content' - skip_after_successful_duplicate: 'true' - do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' - - CodeQL-Security-Build: - needs: check-for-duplicates - if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }} - runs-on: ubuntu-18.04 - timeout-minutes: 15 - - steps: - # Checks out a copy of your repository on the ubuntu-latest machine - - name: Checkout bundle - uses: actions/checkout@v2 - with: - repository: nasa/cFS - submodules: true - - - name: Checkout submodule - uses: actions/checkout@v2 - with: - path: cfe - - - name: Check versions - run: git submodule - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: c - config-file: nasa/cFS/.github/codeql/codeql-security.yml@main - - # Setup the build system - - name: Set up for build - run: | - cp ./cfe/cmake/Makefile.sample Makefile - cp -r ./cfe/cmake/sample_defs sample_defs - make prep - - # Build the code - - name: Build - run: | - make -C build/native/default_cpu1 core_api core_private es evs fs msg resourceid sb sbr tbl time - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 - - CodeQL-Coding-Standard-Build: - needs: check-for-duplicates - if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }} - runs-on: ubuntu-18.04 - timeout-minutes: 15 - - steps: - # Checks out a copy of your repository on the ubuntu-latest machine - - name: Checkout bundle - uses: actions/checkout@v2 - with: - repository: nasa/cFS - submodules: true - - - name: Checkout submodule - uses: actions/checkout@v2 - with: - path: cfe - - - name: Check versions - run: git submodule - - - name: Checkout codeql code - uses: actions/checkout@v2 - with: - repository: github/codeql - submodules: true - path: codeql - - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: c - config-file: nasa/cFS/.github/codeql/codeql-coding-standard.yml@main - - # Setup the build system - - name: Set up for build - run: | - cp ./cfe/cmake/Makefile.sample Makefile - cp -r ./cfe/cmake/sample_defs sample_defs - make prep - - # Build the code - - name: Build - run: | - make -C build/native/default_cpu1 core_api core_private es evs fs msg resourceid sb sbr tbl time - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 \ No newline at end of file + codeql: + name: CodeQL Analysis + uses: nasa/cFS/.github/workflows/codeql-build.yml@main + with: + make-prep: 'make prep' + make: 'make -C build/native/default_cpu1 core_api core_private es evs fs msg resourceid sb sbr tbl time' \ No newline at end of file diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index ec48a19f0..bf12f09e2 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -1,51 +1,11 @@ name: Format Check -# Run on main push and pull requests +# Run on all push and pull requests on: push: pull_request: jobs: - - static-analysis: + format-check: name: Run format check - runs-on: ubuntu-18.04 - timeout-minutes: 15 - - steps: - - - name: Install format checker - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' - sudo apt-get update && sudo apt-get install clang-format-10 - - - name: Checkout bundle - uses: actions/checkout@v2 - with: - repository: nasa/cFS - - - name: Checkout - uses: actions/checkout@v2 - with: - path: repo - - - name: Generate format differences - run: | - cd repo - find . -name "*.[ch]" -exec clang-format-10 -i -style=file {} + - git diff > $GITHUB_WORKSPACE/style_differences.txt - - - name: Archive Static Analysis Artifacts - uses: actions/upload-artifact@v2 - with: - name: style_differences - path: style_differences.txt - - - name: Error on differences - run: | - if [[ -s style_differences.txt ]]; - then - cat style_differences.txt - exit -1 - fi + uses: nasa/cFS/.github/workflows/format-check.yml@main \ No newline at end of file diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9baebd176..017f54bb8 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,56 +1,13 @@ name: Static Analysis -# Run this workflow every time a new commit pushed to your repository +# Run on all push and pull requests on: push: - branches: - - main pull_request: jobs: - static-analysis: name: Run cppcheck - runs-on: ubuntu-18.04 - timeout-minutes: 15 - - strategy: - fail-fast: false - matrix: - cppcheck: [all, cfe] - - steps: - - - name: Install cppcheck - run: sudo apt-get install cppcheck -y - - # Checks out a copy of the cfs bundle - - name: Checkout code - uses: actions/checkout@v2 - with: - submodules: true - - - name: Run bundle cppcheck - if: ${{matrix.cppcheck =='all'}} - run: cppcheck --force --inline-suppr . 2> ${{matrix.cppcheck}}_cppcheck_err.txt - - # Run strict static analysis for embedded portions of cfe - - name: cfe strict cppcheck - if: ${{matrix.cppcheck =='cfe'}} - run: | - all_fsw_modules="core_api core_private es evs fs msg resourceid sb sbr tbl time" - /bin/bash ./.github/workflows/run_fsw_cppcheck.sh ${all_fsw_modules} 2> ${{matrix.cppcheck}}_cppcheck_err.txt - - - name: Archive Static Analysis Artifacts - uses: actions/upload-artifact@v2 - with: - name: ${{matrix.cppcheck}}-cppcheck-err - path: ./*cppcheck_err.txt - - - name: Check for errors - run: | - if [[ -s ${{matrix.cppcheck}}_cppcheck_err.txt ]]; - then - cat ${{matrix.cppcheck}}_cppcheck_err.txt - exit -1 - fi + uses: nasa/cFS/.github/workflows/static-analysis.yml@main + with: + strict-dir-list: './modules/core_api/fsw ./modules/core_private/fsw ./modules/es/fsw ./modules/evs/fsw ./modules/fs/fsw ./modules/msg/fsw ./modules/resourceid/fsw ./modules/sb/fsw ./modules/sbr/fsw ./modules/tbl/fsw ./modules/time/fsw -UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER' \ No newline at end of file diff --git a/README.md b/README.md index 42d420523..a96f9e56a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,20 @@ This is a collection of services and associated framework to be located in the ` The detailed cFE user's guide can be viewed at . -## Version History +## Changelog + +### Development Build: v7.0.0-rc4+dev60 + +- Add CFE_ES_AppInfo_t element documentation +- Add FS Functional test +- Fix mismatched foreach in cmake function +- Improved code highlighting in cFE Application Developers Guide +- CFE_FS_ParseInputFileNameEx avoid uninit var +- Fix array length calculation for perf structs +- Limit SBR UT loops +- Initialize BlockData in ES UT +- Fix `osal_id_t` type conversion in `es_UT.c` +- See and ### Development Build: v7.0.0-rc4+dev39 diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 98bf76b2a..4edf379e1 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -359,7 +359,7 @@ function(prepare) ) foreach(APP ${MISSION_DEPS}) list(APPEND VARLIST "${APP}_MISSION_DIR") - endforeach(APP ${MISSION_APPS}) + endforeach() foreach(SYSVAR ${TGTSYS_LIST}) list(APPEND VARLIST "BUILD_CONFIG_${SYSVAR}") diff --git a/docs/cFE Application Developers Guide.md b/docs/cFE Application Developers Guide.md index 9cee9706e..ba31cc0c8 100644 --- a/docs/cFE Application Developers Guide.md +++ b/docs/cFE Application Developers Guide.md @@ -501,7 +501,7 @@ headers, while files listed in the second table (without suffix) should be used Finally, to simplify application headers, a single "all-inclusive" cFE header is also provided: -``` +```c #include "cfe.h" /* Define cFE API prototypes and data types */ ``` @@ -779,7 +779,7 @@ clock tick. This can also be used to calculate the appropriate number of system clock ticks for a specific delta time. An example can be seen below: -``` +```c uint32 ConvertSecs2Ticks(uint32 Seconds) { uint32 NumOfTicks,TickDurationInMicroSec; @@ -839,20 +839,20 @@ success, the OS_BinSemCreate function sets the sem_id parameter to the ID of the newly-created resource. This ID is used in all other functions that use the binary semaphore. -``` +```c int32 OS_BinSemCreate(uint32 *xxx_SEM_ID, const char *xxx_SEM_NAME, uint32 sem_initial_value, uint32 options); ``` There are two options for pending on a binary semaphore: -``` +```c int32 OS_BinSemTake( uint32 xxx_SEM_ID ); ``` which waits indefinitely for a semaphore to become available, and -``` +```c int32 OS_BinSemTimedWait( uint32 xxx_SEM_ID , uint32 timeout_in_milliseconds ); ``` @@ -861,7 +861,7 @@ has not become available. A binary semaphore is given by using this function: -``` +```c int32 OS_BinSemGive( uint32 xxx_SEM_ID ); ``` @@ -886,25 +886,26 @@ Upon success, the OS_CountSemCreate function sets the sem_id parameter to the ID of the newly-created resource. This ID is used in all other functions that use the binary semaphore. -``` +```c int32 OS_CountSemCreate(uint32 *xxx_SEM_ID, const char *xxx_SEM_NAME, uint32 sem_initial_value, uint32 options); ``` There are two options for pending on a counting semaphore: -``` +```c int32 OS_CountSemTake( uint32 xxx_SEM_ID ); ``` which waits indefinitely for a semaphore to become available, and -``` +```c int32 OS_CountSemTimedWait( uint32 xxx_SEM_ID , uint32 timeout_in_milliseconds ); ``` + A counting semaphore is given by using this function: -``` +```c int32 OS_CountSemGive( uint32 xxx_SEM_ID ); ``` @@ -940,7 +941,7 @@ being done in the protected region. The Take and Give functions should have the same level of indentation, and there should be exactly one entry point and one exit point to the protected region. -``` +```c int32 OS_MutSemTake( uint32 xxx_MUT_ID ); /* protected region */ @@ -965,25 +966,25 @@ of the entire system. An application creates a mutex by calling: -``` +```c int32 OS_MutSemCreate (uint32 *sem_id, const char *sem_name, uint32 options); ``` and deletes it by calling: -``` +```c int32 OS_MutSemDelete (uint32 sem_id); ``` An application takes a mutex by calling: -``` +```c int32 OS_MutSemTake( uint32 xxx_MUT_ID ); ``` and gives it by calling: -``` +```c int32 OS_MutSemGive( uint32 xxx_MUT_ID ); ``` @@ -1009,7 +1010,7 @@ Similar to interrupt service routines, handlers can be associated with specific exceptions. The following function specifies a handler for an exception: -``` +```c OS_ExcAttachHandler( uint32 ExceptionNumber, void *ExceptionHandler, int32 Param ); ``` @@ -1017,14 +1018,14 @@ The ExceptionHandler is a function that will be called when the exception is detected and should have a prototype that looks like the following: -``` +```c void ExceptionHandler( int32 Param ); ``` There are addition functions for enabling/masking and disabling/unmasking specific exceptions. These are as follows: -``` +```c OS_ExcEnable( uint32 ExceptionNumber ); OS_ExcDisable( uint32 ExceptionNumber ); ``` @@ -1035,7 +1036,7 @@ In addition to the exception handlers identified above, a similar paradigm exists for handling floating point processor exceptions. The following function specifies a handler for an FPU exception: -``` +```c OS_FPUExcAttachHandler( uint32 ExceptionNumber, void *ExceptionHandler, int32 Param ); ``` @@ -1043,14 +1044,14 @@ The ExceptionHandler is a function that will be called when the exception is detected and should have a prototype that looks like the following: -``` +```c void ExceptionHandler( int32 Param ); ``` There are addition functions for enabling/masking and disabling/unmasking specific exceptions. These are as follows: -``` +```c OS_FPUExcEnable( uint32 ExceptionNumber ); OS_FPUExcDisable( uint32 ExceptionNumber ); ``` @@ -1367,7 +1368,7 @@ significant Event that cannot be recorded using the CFE_EVS_SendEvent function, then the Developer can use the CFE_ES_WriteToSysLog function. This function has the following prototype: -``` +```c int32 CFE_ES_WriteToSysLog(const char *pSpecString, ...); ``` @@ -2313,7 +2314,7 @@ used to uniquely identify an application event. The Event ID is defined and supplied to the EVS by the application requesting services. The hexadecimal bit mask represents the filtering frequency for the event. -``` +```c typedef struct { uint16 EventID, @@ -2342,7 +2343,7 @@ section 7.4) regardless of whether the message was sent. An example of an Application registering with Event Services and specifying its binary filters is shown below: -``` +```c FILE: sample_app.h ... @@ -2415,7 +2416,7 @@ reset the filter counter for a specified Event ID. The latter function resets all event filter counters for the Application. An example of resetting a specific Event ID filter counter is shown below: -``` +```c FILE: sample_app.c { @@ -2434,7 +2435,7 @@ or the CFE_EVS_SendTimedEvent() function, which are both analogous to the C printf() function in how strings are formatted. An example of each function call is shown below: -``` +```c CFE_EVS_SendEvent(EventID, EventType, "Unknown stream on cmd pipe: 0x%04X", sid); ``` @@ -2451,7 +2452,7 @@ sent. The other function that can be called to send an event message is shown below: -``` +```c CFE_EVS_SendTimedEvent(PktTime, EventID, EventType, "CSS Data Bad: 0x%04X", CssData); ``` @@ -2644,7 +2645,7 @@ it should use the CFE_TBL_Share API instead. The CFE_TBL_Share API will locate the specified Table by name and return a Table Handle to the calling Application. An example of Table sharing is shown below: -``` +```c FILE: SAMPLE_app.c CFE_TBL_Handle_t MyTableHandle; /* Handle to MyTable */ @@ -2679,7 +2680,7 @@ Application can obtain a pointer to the start of the data within the Table using the CFE_TBL_GetAddress or CFE_TBL_GetAddresses APIs. An example of this is shown in Section 8.5.1. -``` +```c { int32 Status = CFE_SUCCESS; SAMPLE_MyTable_t *MyTblPtr; @@ -2772,7 +2773,7 @@ assigning and creating a validation function is a fairly simple process. To use the function, the Application should periodically identify when a Table Validation Request has been made as shown below: -``` +```c { int32 Status = CFE_SUCCESS; boolean FinishedManaging = FALSE; @@ -2821,7 +2822,7 @@ the Table with default values or when the Application is changing modes and wishes to use a different parameter set. An example of this can be seen below: -``` +```c FILE: sample_app.c CFE_TBL_Handle_t MyTableHandle /* Handle to MyTable */ @@ -2847,7 +2848,7 @@ SAMPLE_MyTable_t MyTblInitData = { 0x1234, 0x5678, { 2, 3, 4, ... }, ...}; If a developer wishes to load the table from a file rather than from a memory image, the code would look something like the following: -``` +```c { int32 Status; @@ -2898,6 +2899,7 @@ A typical layout of table-related files within an application (xx) is shown below. Note that this does not show all of an application's files, just those related to tables. +``` xx |----fsw |----src @@ -2910,27 +2912,28 @@ xx | |----platform_inc |----xx_platform_cfg.h +``` -The xx_app.h file is included in this layout only because table handles are -typically stored in an application's AppData_t structure. +The `xx_app.h` file is included in this layout only because table handles are +typically stored in an application's `AppData_t` structure. -The file xx_tbldefs.h (sometimes just named xx_tbl.h) typically contains the +The file `xx_tbldefs.h` (sometimes just named `xx_tbl.h`) typically contains the structure definition of a single table entry. This file is included in the -xx_table1.c file where the table itself is defined. It may also contain +`xx_table1.c` file where the table itself is defined. It may also contain declarations for table-related utility functions. -The xx_tbl.c file typically contains table-related utility functions. For +The `xx_tbl.c` file typically contains table-related utility functions. For instance, many applications define table initialization and validation functions in this file. -The xx_table1.c file is the source code for a table itself. +The `xx_table1.c` file is the source code for a table itself. -The xx_platform_cfg.h file contains configuration parameters for applications, +The `xx_platform_cfg.h` file contains configuration parameters for applications, and there are typically several configuration parameters associated with tables. ### 8.5.1 Table Files Example -``` +```c FILE: xx_app.h ... @@ -2945,7 +2948,7 @@ XX_AppData_t XX_AppData; ... ``` -``` +```c FILE: xx_tbldefs.h ... @@ -2968,7 +2971,7 @@ int32 XX_ValidateTable(void *TableData); ... ``` -``` +```c FILE: xx_tbl.c #include xx_tbldefs.h @@ -3028,7 +3031,7 @@ int32 XX_ValidateTable(void *TableData) } ``` -``` +```c FILE: xx_table1.c #include "cfe.h" @@ -3054,7 +3057,7 @@ XX_MyTable_t XX_MyTable = }; ``` -``` +```c FILE: xx_platform_cfg.h #define XX_APP_NAME "XX" @@ -3071,7 +3074,7 @@ In order to build application tables with the CMake build system, the application is structured with a "Tables" directory, another "aux_source_directory" may need to be added as well. -``` +```cmake aux_source_directory(fsw/tables APP_TABLE_FILES) # Create the app module @@ -3106,7 +3109,7 @@ standard file header. The structure of the standard file header is as follows: -``` +```c typedef struct { uint32 ContentType; /* Identifies the content type (magic #=’cFE1’) */ @@ -3215,7 +3218,7 @@ integer represents the number of seconds and the second integer represents the number of `2^-32` seconds. The data structure for this representation of time is as follows: -``` +```c typedef struct { uint32 Seconds; /* Number of seconds */ uint32 Subseconds; /* Number of 2^(-32) subseconds */ @@ -3420,7 +3423,7 @@ the first time in the subtraction. Otherwise, as shown above, the delta time between two absolute times could either be 5 hours or 7 hours. An example of a delta time computation function is shown below: -``` +```c CFE_TIME_SysTime_t ComputeDeltaTime(CFE_TIME_SysTime_t TimeA, CFE_TIME_SysTime_t TimeB) { diff --git a/modules/cfe_testcase/src/fs_util_test.c b/modules/cfe_testcase/src/fs_util_test.c index e378fc862..2435078d7 100644 --- a/modules/cfe_testcase/src/fs_util_test.c +++ b/modules/cfe_testcase/src/fs_util_test.c @@ -37,8 +37,26 @@ void TestFileCategory(void) { UtPrintf("Testing: CFE_FS_GetDefaultMountPoint, CFE_FS_GetDefaultExtension"); - UtAssert_NULL(CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_UNKNOWN)); - UtAssert_NULL(CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_UNKNOWN)); + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_UNKNOWN); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_UNKNOWN); + + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_DYNAMIC_MODULE); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_DYNAMIC_MODULE); + + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_BINARY_DATA_DUMP); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_BINARY_DATA_DUMP); + + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_TEXT_LOG); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_TEXT_LOG); + + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_SCRIPT); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_SCRIPT); + + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_TEMP); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_TEMP); + + CFE_FS_GetDefaultMountPoint(CFE_FS_FileCategory_MAX); + CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_MAX); } void TestInputFile(void) diff --git a/modules/core_api/fsw/inc/cfe_es_extern_typedefs.h b/modules/core_api/fsw/inc/cfe_es_extern_typedefs.h index ed0043c96..2233f5f79 100644 --- a/modules/core_api/fsw/inc/cfe_es_extern_typedefs.h +++ b/modules/core_api/fsw/inc/cfe_es_extern_typedefs.h @@ -434,10 +434,8 @@ typedef uint32 CFE_ES_MemAddress_t; */ typedef struct CFE_ES_MemAddOff { - CFE_ES_MemAddress_t Address; - - CFE_ES_MemOffset_t Size; - + CFE_ES_MemAddress_t Address; /**< \brief Code section address */ + CFE_ES_MemOffset_t Size; /**< \brief Code section size */ } CFE_ES_MemAddOff_t; /* @@ -468,16 +466,13 @@ typedef struct CFE_ES_AppInfo char FileName[CFE_MISSION_MAX_PATH_LEN]; /**< \cfetlmmnemonic \ES_APPFILENAME \brief The Filename of the file containing the Application */ - CFE_ES_MemOffset_t StackSize; /**< \cfetlmmnemonic \ES_STACKSIZE - \brief The Stack Size of the Application */ - uint32 AddressesAreValid; /**< \cfetlmmnemonic \ES_ADDRVALID - \brief Indicates that the Code, Data, and BSS addresses/sizes are valid */ - CFE_ES_MemAddOff_t Code; - - CFE_ES_MemAddOff_t Data; - - CFE_ES_MemAddOff_t BSS; - + CFE_ES_MemOffset_t StackSize; /**< \cfetlmmnemonic \ES_STACKSIZE + \brief The Stack Size of the Application */ + uint32 AddressesAreValid; /**< \cfetlmmnemonic \ES_ADDRVALID + \brief Indicates that the Code, Data, and BSS addresses/sizes are valid */ + CFE_ES_MemAddOff_t Code; /**< \brief code section address/size structure */ + CFE_ES_MemAddOff_t Data; /**< \brief Data section address/size structure */ + CFE_ES_MemAddOff_t BSS; /**< \brief BSS section address/size structure */ CFE_ES_MemAddress_t StartAddress; /**< \cfetlmmnemonic \ES_STARTADDR \brief The Start Address of the Application */ CFE_ES_ExceptionAction_Enum_t ExceptionAction; /**< \cfetlmmnemonic \ES_EXCEPTNACTN diff --git a/modules/core_api/fsw/inc/cfe_version.h b/modules/core_api/fsw/inc/cfe_version.h index 81bd120a9..d6322dde2 100644 --- a/modules/core_api/fsw/inc/cfe_version.h +++ b/modules/core_api/fsw/inc/cfe_version.h @@ -28,7 +28,7 @@ #define CFE_VERSION_H /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 39 /**< @brief Development: Number of development commits since baseline */ +#define CFE_BUILD_NUMBER 60 /**< @brief Development: Number of development commits since baseline */ #define CFE_BUILD_BASELINE "v7.0.0-rc4" /**< @brief Development: Reference git tag for build number */ /* Version Macro Definitions updated for official releases only */ diff --git a/modules/core_api/ut-stubs/src/cfe_fs_handlers.c b/modules/core_api/ut-stubs/src/cfe_fs_handlers.c index 86e18fec9..b27763125 100644 --- a/modules/core_api/ut-stubs/src/cfe_fs_handlers.c +++ b/modules/core_api/ut-stubs/src/cfe_fs_handlers.c @@ -161,6 +161,7 @@ void UT_DefaultHandler_CFE_FS_ParseInputFileNameEx(void *UserObj, UT_EntryKey_t { char * OutputBuffer = UT_Hook_GetArgValueByName(Context, "OutputBuffer", char *); size_t OutputBufSize = UT_Hook_GetArgValueByName(Context, "OutputBufSize", size_t); + const char *InputBuffer = UT_Hook_GetArgValueByName(Context, "InputBuffer", const char *); const char *DefaultInput = UT_Hook_GetArgValueByName(Context, "DefaultInput", const char *); int32 status; @@ -169,10 +170,18 @@ void UT_DefaultHandler_CFE_FS_ParseInputFileNameEx(void *UserObj, UT_EntryKey_t /* Copy any specific output supplied by test case */ if (status >= 0 && UT_Stub_CopyToLocal(UT_KEY(CFE_FS_ParseInputFileNameEx), OutputBuffer, OutputBufSize) == 0 && - OutputBufSize > 0 && DefaultInput != NULL) + OutputBufSize > 0) { - /* Otherwise fall back to simple copy */ - strncpy(OutputBuffer, DefaultInput, OutputBufSize); + if (DefaultInput != NULL) + { + /* Use default if set */ + strncpy(OutputBuffer, DefaultInput, OutputBufSize); + } + else + { + /* Fall back to copy input to avoid uninitialized output */ + strncpy(OutputBuffer, InputBuffer, OutputBufSize); + } } } diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index 4703763f1..4298a76c7 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -48,13 +48,16 @@ /* ** Defines */ +#define CFE_ES_PERF_MASK_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) + #define CFE_ES_PERF_TRIGGERMASK_INT_SIZE \ - (sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask) / sizeof(uint32)) + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.ResetDataPtr->Perf.MetaData.TriggerMask) #define CFE_ES_PERF_TRIGGERMASK_EXT_SIZE \ - (sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask) / sizeof(uint32)) -#define CFE_ES_PERF_FILTERMASK_INT_SIZE (sizeof(CFE_ES_Global.ResetDataPtr->Perf.MetaData.FilterMask) / sizeof(uint32)) + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.TaskData.HkPacket.Payload.PerfTriggerMask) +#define CFE_ES_PERF_FILTERMASK_INT_SIZE \ + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.ResetDataPtr->Perf.MetaData.FilterMask) #define CFE_ES_PERF_FILTERMASK_EXT_SIZE \ - (sizeof(CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask) / sizeof(uint32)) + CFE_ES_PERF_MASK_ARRAY_SIZE(CFE_ES_Global.TaskData.HkPacket.Payload.PerfFilterMask) /* ** This define should be put in the OS API headers -- Right now it matches what the OS API uses diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index 245487995..3efea3c8f 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -4519,7 +4519,7 @@ void TestAPI(void) /* Hit error case for NULL TaskRecPtr */ ES_ResetUnitTest(); - UT_SetDeferredRetcode(UT_KEY(OS_TaskGetId), 1, OS_OBJECT_ID_UNDEFINED); + UT_SetDeferredRetcode(UT_KEY(OS_TaskGetId), 1, OS_ObjectIdToInteger(OS_OBJECT_ID_UNDEFINED)); UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_ES_ERR_RESOURCEID_NOT_VALID); } @@ -4670,6 +4670,8 @@ void TestCDS() UtPrintf("Begin Test CDS"); + memset(BlockData, 0, sizeof(BlockData)); + /* Test init with a mutex create failure */ UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERROR); UtAssert_INT32_EQ(CFE_ES_CDS_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); diff --git a/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c b/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c index 0cc2f8fbb..b5349ac9d 100644 --- a/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c @@ -31,10 +31,17 @@ #include "cfe_sbr_priv.h" #include +/* + * Reasonable limit on loops in case CFE_PLATFORM_SB_HIGHEST_VALID_MSGID is large + * Can be set equal to the configured highest if user requires it + */ +#define CFE_SBR_UT_LIMIT_HIGHEST_MSGID 0x1FFF + void Test_SBR_Map_Direct(void) { CFE_SB_MsgId_Atom_t msgidx; + CFE_SB_MsgId_Atom_t msgid_limit; CFE_SBR_RouteId_t routeid; CFE_SB_MsgId_t msgid; uint32 count; @@ -50,16 +57,29 @@ void Test_SBR_Map_Direct(void) /* Force valid msgid responses */ UT_SetDefaultReturnValue(UT_KEY(CFE_SB_IsValidMsgId), true); - UtPrintf("Check that all entries are set invalid"); + /* Limit message id loops */ + if (CFE_PLATFORM_SB_HIGHEST_VALID_MSGID > CFE_SBR_UT_LIMIT_HIGHEST_MSGID) + { + msgid_limit = CFE_SBR_UT_LIMIT_HIGHEST_MSGID; + UtPrintf("Limiting msgid ut loops to 0x%08X of 0x%08X", (unsigned int)msgid_limit, + (unsigned int)CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); + } + else + { + msgid_limit = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; + UtPrintf("Testing full msgid range in ut up to 0x%08X", (unsigned int)msgid_limit); + } + + UtPrintf("Check that entries are set invalid"); count = 0; - for (msgidx = 0; msgidx <= CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; msgidx++) + for (msgidx = 0; msgidx <= msgid_limit; msgidx++) { if (!CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(msgidx)))) { count++; } } - UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); + UtAssert_INT32_EQ(count, msgid_limit + 1); UtPrintf("Set/Get a range of ids "); routeid = CFE_SBR_ValueToRouteId(CFE_PLATFORM_SB_MAX_MSG_IDS + 1); @@ -72,16 +92,29 @@ void Test_SBR_Map_Direct(void) UtAssert_INT32_EQ(CFE_SBR_SetRouteId(msgid, routeid), 0); UtAssert_INT32_EQ(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId); - UtPrintf("Check there is now 1 valid entry in map"); + /* Get number of valid routes in range */ count = 0; - for (msgidx = 0; msgidx <= CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; msgidx++) + for (msgidx = 0; msgidx <= msgid_limit; msgidx++) { - if (!CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(msgidx)))) + if (CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(msgidx)))) { count++; } } - UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); + + /* Check result based on range checked */ + if (msgid_limit == CFE_PLATFORM_SB_HIGHEST_VALID_MSGID) + { + /* Full range, 1 valid */ + UtPrintf("Check there is 1 valid entry in map"); + UtAssert_INT32_EQ(count, 1); + } + else + { + /* Limited range, up to 1 valid */ + UtPrintf("Up to 1 valid entry in limited range check"); + UtAssert_INT32_LTEQ(count, 1); + } UtPrintf("Set back to invalid and check again"); routeid = CFE_SBR_INVALID_ROUTE_ID; diff --git a/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c b/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c index dd8d4e3ed..16e4b50ea 100644 --- a/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c +++ b/modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c @@ -37,6 +37,12 @@ /* Unhash magic number */ #define CFE_SBR_UNHASH_MAGIC (0x119de1f3) +/* + * Reasonable limit on loops in case CFE_PLATFORM_SB_HIGHEST_VALID_MSGID is large + * Can be set equal to the configured highest if user requires it + */ +#define CFE_SBR_UT_LIMIT_HIGHEST_MSGID 0x1FFF + /****************************************************************************** * Local helper to unhash */ @@ -54,6 +60,7 @@ void Test_SBR_Map_Hash(void) { CFE_SB_MsgId_Atom_t msgidx; + CFE_SB_MsgId_Atom_t msgid_limit; CFE_SBR_RouteId_t routeid[3]; CFE_SB_MsgId_t msgid[3]; uint32 count; @@ -69,16 +76,29 @@ void Test_SBR_Map_Hash(void) /* Force valid msgid responses */ UT_SetDefaultReturnValue(UT_KEY(CFE_SB_IsValidMsgId), true); - UtPrintf("Check that all entries are set invalid"); + /* Limit message id loops */ + if (CFE_PLATFORM_SB_HIGHEST_VALID_MSGID > CFE_SBR_UT_LIMIT_HIGHEST_MSGID) + { + msgid_limit = CFE_SBR_UT_LIMIT_HIGHEST_MSGID; + UtPrintf("Limiting msgid ut loops to 0x%08X of 0x%08X", (unsigned int)msgid_limit, + (unsigned int)CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); + } + else + { + msgid_limit = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; + UtPrintf("Testing full msgid range in ut up to 0x%08X", (unsigned int)msgid_limit); + } + + UtPrintf("Check that entries are set invalid"); count = 0; - for (msgidx = 0; msgidx <= CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; msgidx++) + for (msgidx = 0; msgidx <= msgid_limit; msgidx++) { if (!CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(msgidx)))) { count++; } } - UtAssert_INT32_EQ(count, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); + UtAssert_INT32_EQ(count, msgid_limit + 1); /* Note AddRoute required for hash logic to work since it depends on MsgId in routing table */ UtPrintf("Add routes and check with a rollover and a skip");