### Setup Proof Tools Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetPsmSettings/README.md Ensures that the necessary proof verification tools are available in the system's PATH. This step is crucial before running the 'make' command to execute the memory safety proof. ```shell export PATH="/path/to/cbmc/bin:$PATH" export PATH="/path/to/goto-cc/bin:$PATH" export PATH="/path/to/goto-instrument/bin:$PATH" export PATH="/path/to/goto-analyzer/bin:$PATH" export PATH="/path/to/cbmc-viewer/bin:$PATH" ``` -------------------------------- ### Setup Proof Tools Environment Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_GetModuleContext/README.md Ensures that the necessary proof verification tools, such as cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer, are accessible from the command line by adding them to the system's PATH environment variable. ```shell export PATH=/path/to/proof/tools:$PATH # Note: Replace /path/to/proof/tools with the actual directory containing the tools. ``` -------------------------------- ### Run Memory Safety Proof Build Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATRemoveAllWhiteSpaces/README.md Executes the build process for the memory safety proof. This command requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. The output is an HTML report. ```bash make ``` -------------------------------- ### Setup and Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonInit/README.md Instructions to prepare your environment and execute the memory safety proof. This involves adding necessary tools to your system's PATH and then running the 'make' command to initiate the proof process. The results can be viewed in an HTML report. ```shell export PATH="/path/to/cbmc/bin:$PATH" export PATH="/path/to/goto-cc/bin:$PATH" export PATH="/path/to/goto-instrument/bin:$PATH" export PATH="/path/to/goto-analyzer/bin:$PATH" export PATH="/path/to/cbmc-viewer/bin:$PATH" make # After make completes, open html/index.html in your web browser. ``` -------------------------------- ### Run _Cellular_LibCleanup Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_LibCleanup/README.md Executes the memory safety proof for _Cellular_LibCleanup using the make utility. This command initiates the verification process after necessary tools have been installed and configured. ```makefile make ``` -------------------------------- ### Run Cellular_ATHexStrToHex Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATHexStrToHex/README.md This snippet outlines the steps to execute the memory safety proof for Cellular_ATHexStrToHex. It requires specific C verification tools to be installed and accessible in the system's PATH. Running 'make' initiates the proof process, generating an HTML report for analysis. ```bash make ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetPsmSettings/README.md Executes the memory safety proof using the make utility. This command initiates the proof process, which requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. ```makefile make ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_IsValidSocket/README.md This command initiates the memory safety proof process for _Cellular_IsValidSocket. It requires specific tools like cbmc, goto-cc, and others to be installed and accessible in the system's PATH. The output is an HTML report viewable in a web browser. ```bash make ``` -------------------------------- ### Run Cellular Interface Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATRemoveLeadingWhiteSpaces/README.md This section details how to execute the memory safety proof for the Cellular_ATRemoveLeadingWhiteSpaces function. It requires specific verification tools to be installed and accessible in the system's PATH. ```APIDOC Proof Execution: To run the memory safety proof for Cellular_ATRemoveLeadingWhiteSpaces: 1. **Prerequisites**: Ensure the following tools are installed and added to your system's PATH: * cbmc * goto-cc * goto-instrument * goto-analyzer * cbmc-viewer 2. **Execution**: Navigate to the directory containing the proof files and run the command: ``` make ``` 3. **Viewing Results**: After the proof process completes, open the generated report in a web browser: ``` html/index.html ``` **Purpose**: This process verifies the memory safety properties of the Cellular_ATRemoveLeadingWhiteSpaces function using static analysis tools. ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_ConvertCsqSignalBer/README.md This command initiates the memory safety proof process for the `_Cellular_ConvertCsqSignalBer` function. It requires CBMC tools to be installed and accessible in the system's PATH. The output is an HTML report generated in the `html/` directory. ```make make ``` -------------------------------- ### Run Memory Safety Proof (Makefile) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_TranslateAtCoreStatus/README.md This command initiates the memory safety proof process for the _Cellular_TranslateAtCoreStatus function. It requires CBMC tools (cbmc, goto-cc, goto-instrument, goto-analyzer, cbmc-viewer) to be installed and accessible in the system's PATH. The proof generation and viewing are managed by a Makefile. ```shell make ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_NetworkRegistrationCallback/README.md Initiates the memory safety proof process for _Cellular_NetworkRegistrationCallback. This requires CBMC tools to be installed and accessible in the system's PATH. After execution, the results can be viewed in an HTML report. ```shell make ``` -------------------------------- ### Run Cellular Interface Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATIsPrefixPresent/README.md Instructions to execute the memory safety proof for the Cellular_ATIsPrefixPresent function and view the results. This process requires specific CBMC tools to be installed and accessible in the system's PATH. ```APIDOC Run Memory Safety Proof: 1. Prerequisites: - Ensure cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer are added to your system's PATH. 2. Execute Proof: - Navigate to the project directory. - Run the command: "make" 3. View Results: - Open the file "html/index.html" in a web browser to view the proof report. ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonUrcProcessCereg/README.md Instructions to execute the memory safety proof for the Cellular_CommonUrcProcessCereg function. This process requires specific verification tools to be installed and accessible in the system's PATH. ```shell echo "Ensure cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer are in your PATH." make echo "Open html/index.html in a web browser to view the proof results." ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_GetSocketData/README.md Executes the memory safety proof process for _Cellular_GetSocketData. This command requires the CBMC verification suite and its associated tools to be installed and accessible in the system's PATH. The output is an HTML report detailing the proof's findings. ```Shell make ``` -------------------------------- ### Run Cellular_ATStrDup Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATStrDup/README.md Instructions to execute the memory safety proof for Cellular_ATStrDup. This process requires the CBMC suite of tools to be installed and accessible in the system's PATH. Running 'make' initiates the proof generation, and the results can be viewed in a web browser. ```shell make ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_RemoveSocketData/README.md This command initiates the memory safety proof process using the Make build system. It requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. The output is typically viewed by opening an HTML report in a web browser. ```make make ``` -------------------------------- ### Run Memory Safety Proof using Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonUrcProcessCreg/README.md This command initiates the memory safety proof process for the Cellular_CommonUrcProcessCreg function. It requires CBMC, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. The output is an HTML report detailing the proof results, which can be viewed by opening 'html/index.html' in a web browser. ```makefile make ``` -------------------------------- ### Run Cellular_ATStrStartWith Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATStrStartWith/README.md Instructions to execute the memory safety proof for Cellular_ATStrStartWith. This process requires specific verification tools to be installed and accessible in the system's PATH. The proof generates an HTML report. ```Shell # Prerequisites: # Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to your PATH. # Run the memory safety proof make # Open the generated report in a web browser # For example: # open html/index.html (macOS) # xdg-open html/index.html (Linux) # start html/index.html (Windows) ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetSimCardLockStatus/README.md Initiates the memory safety proof process for the FreeRTOS cellular interface. This requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. The output is an HTML report detailing the proof results. ```make make ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_GetCurrentRat/README.md This command initiates the memory safety proof process for the _Cellular_GetCurrentRat function. It requires CBMC tools to be installed and accessible in the system's PATH. The output is an HTML report detailing the proof results, which can be viewed by opening 'html/index.html'. ```make make ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_ComputeSignalBars/README.md Executes the memory safety proof for _Cellular_ComputeSignalBars. This command requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. Upon successful execution, it generates an HTML report for analysis. ```shell make ``` -------------------------------- ### Run Memory Safety Proof using Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonATCommandRaw/README.md Executes the memory safety proof for the Cellular_CommonATCommandRaw component. Prerequisites include having CBMC, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer installed and accessible in your system's PATH. Running 'make' will generate HTML reports for analysis. ```shell make ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetNetworkTime/README.md This command initiates the memory safety proof process for the Cellular_CommonGetNetworkTime function. It requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be installed and accessible in the system's PATH. Upon successful execution, it generates an HTML report for viewing. ```shell make ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_SignalStrengthChangedCallback/README.md Executes the memory safety proof for the FreeRTOS Cellular Interface. This command requires CBMC tools (cbmc, goto-cc, goto-instrument, goto-analyzer, cbmc-viewer) to be installed and accessible in the system's PATH. Upon successful execution, it generates an HTML report viewable in a web browser. ```bash make ``` -------------------------------- ### Running the Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATcheckErrorCode/README.md Instructions to set up the environment and execute the memory safety proof for Cellular_ATcheckErrorCode. This involves adding necessary tools to the PATH and running the 'make' command. ```text To run the proof. * Add cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to your path. * Run "make". * Open html/index.html in a web browser. ``` -------------------------------- ### Coverity Analysis Workflow Source: https://github.com/freertos/freertos-cellular-interface/blob/main/tools/coverity/README.md A comprehensive sequence of shell commands to configure Coverity, build the project with analysis enabled, and execute the static analysis. It covers setting up the compiler, generating build files with CMake, running the build, and analyzing the output. ```bash cov-configure --force --compiler cc --comptype gcc cmake -B build -S test -DCOV_ANALYSIS=ON cd build/ cov-build --emit-complementary-info --dir cov-out make coverity_analysis cd cov-out/ cov-analyze --dir . --coding-standard-config ../../tools/coverity/misra.config --tu-pattern "file('.*/source/.*')" cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/)' --html-output html-out; cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/)' --json-output-v2 defects.json; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Below-------------------------\n" jq '.issues[] | .events[] | .eventTag ' defects.json | sort | uniq -c | sort -nr; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Above-------------------------\n"; cd ../../ ``` -------------------------------- ### Run Cellular_CommonSetPdnConfig Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonSetPdnConfig/README.md Instructions to set up the environment and execute the memory safety proof for Cellular_CommonSetPdnConfig. Requires specific tools to be in the system's PATH. ```shell PATH="/path/to/tools:$PATH" make ``` ```shell open html/index.html ``` -------------------------------- ### Run Cellular_CommonSetEidrxSettings Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonSetEidrxSettings/README.md Instructions to execute the memory safety proof for Cellular_CommonSetEidrxSettings. This involves setting up the environment with specific verification tools and running the build process. ```APIDOC Cellular_CommonSetEidrxSettings Proof Execution: This section details the steps required to run the memory safety proof for the Cellular_CommonSetEidrxSettings function. Prerequisites: - Ensure the following tools are installed and accessible in your system's PATH: - cbmc - goto-cc - goto-instrument - goto-analyzer - cbmc-viewer Steps: 1. Setup Environment: Add the necessary verification tools to your system's PATH. Example (Linux/macOS): export PATH=/path/to/cbmc/bin:$PATH Example (Windows): set PATH=C:\path\to\cbmc\bin;%PATH% 2. Run Build Process: Navigate to the project directory containing the proof files. Execute the 'make' command to compile and run the proof. Command: make 3. View Results: After the 'make' command completes, open the generated HTML report in a web browser. File: html/index.html Expected Outcome: - The 'make' command will invoke the CBMC tools to perform static analysis and generate a proof report. - The 'cbmc-viewer' or manual opening of 'html/index.html' will display the results of the memory safety proof. ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonRegisterUrcPdnEventCallback/README.md Instructions to set up the environment and run the memory safety proof using the provided Makefile. This involves ensuring necessary tools are in the PATH and executing the 'make' command. ```shell PATH="/path/to/cbmc/bin:$PATH" PATH="/path/to/goto-cc/bin:$PATH" PATH="/path/to/goto-instrument/bin:$PATH" PATH="/path/to/goto-analyzer/bin:$PATH" PATH="/path/to/cbmc-viewer/bin:$PATH" make ``` -------------------------------- ### Prerequisites for Coverity Analysis Source: https://github.com/freertos/freertos-cellular-interface/blob/main/tools/coverity/README.md Lists the essential software and tools required before performing static code analysis with Coverity. This includes specific versions of CMake and the GCC compiler, along with instructions for cloning the repository and updating submodules. ```bash git clone --recurse-submodules git@github.com:FreeRTOS/FreeRTOS-Cellular-Interface.git ./FreeRTOS-Cellular-Interface cd ./FreeRTOS-Cellular-Interface git submodule update --checkout --init --recursive ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonRegisterUrcGenericCallback/README.md Instructions to set up the environment and execute the memory safety proof for Cellular_CommonRegisterUrcGenericCallback. This involves adding verification tools to the PATH and running the 'make' command. ```shell export PATH="/path/to/cbmc/bin:$PATH" export PATH="/path/to/goto-cc/bin:$PATH" export PATH="/path/to/goto-instrument/bin:$PATH" export PATH="/path/to/goto-analyzer/bin:$PATH" export PATH="/path/to/cbmc-viewer/bin:$PATH" make ``` -------------------------------- ### Coverity Analysis Commands (Copy-Paste Friendly) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/tools/coverity/README.md A consolidated block of shell commands for executing the Coverity static analysis workflow, suitable for direct copy-pasting into a UNIX-like terminal. This includes configuration, building, analysis, and error formatting. ```bash cov-configure --force --compiler cc --comptype gcc; cmake -B build -S test -DCOV_ANALYSIS=ON; cd build/; cov-build --emit-complementary-info --dir cov-out make coverity_analysis; cd cov-out/ cov-analyze --dir . --coding-standard-config ../../tools/coverity/misra.config --tu-pattern "file('.*/source/.*')"; cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/)' --html-output html-out; cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/)' --json-output-v2 defects.json; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Below-------------------------\n"; jq '.issues[] | .events[] | .eventTag ' defects.json | sort | uniq -c | sort -nr; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Above-------------------------\n"; cd ../../; ``` -------------------------------- ### Makefile.common: CBMC Proof Workflow Commands Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/README.md Defines the standard workflow for building and running CBMC proofs. It includes targets for building the goto binary, performing property and coverage checking, and generating reports. ```makefile make Description: Builds the goto binary, performs CBMC property checking and coverage checking, and builds the final report. make goto Description: Builds the goto binary. make result Description: Performs CBMC property checking. make coverage Description: Performs CBMC coverage checking. make report Description: Builds the final report. ``` -------------------------------- ### View Proof Results Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_ConvertCsqSignalBer/README.md After running the proof, open the generated HTML index file in a web browser to view the detailed results of the memory safety analysis. ```shell open html/index.html ``` -------------------------------- ### Create Real Library (CMake) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/unit-test/CMakeLists.txt Defines the source files and include directories for the main library under test. It also links the generated mocks to this library. ```CMake list(APPEND real_source_files ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_at_core.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_pktio.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_pkthandler.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_common_api.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_3gpp_urc_handler.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_3gpp_api.c ) list(APPEND real_include_directories . ${CMAKE_CURRENT_LIST_DIR}/logging ${CELLULAR_INCLUDE_DIRS} ${CELLULAR_INTERFACE_INCLUDE_DIRS} ${CELLULAR_COMMON_INCLUDE_DIRS} ${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS} ) set(mock_name "${project_name}_mock") set(real_name "${project_name}_real") create_mock_list(${mock_name} "${mock_list}" "${MODULE_ROOT_DIR}/tools/cmock/project.yml" "${mock_include_list}" "${mock_define_list}" ) create_real_library(${real_name} "${real_source_files}" "${real_include_directories}" "${mock_name}" ) ``` -------------------------------- ### View Proof Results Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetPsmSettings/README.md Opens the generated HTML report in a web browser to view the results of the memory safety proof. This allows for detailed analysis of the proof's outcome and any identified issues. ```shell open html/index.html ``` -------------------------------- ### View Proof Results Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATGetSpecificNextTok/README.md After running the 'make' command, this step involves opening the generated HTML report in a web browser to view the results of the memory safety proof. ```shell open html/index.html ``` -------------------------------- ### Run Cellular_ATRemovePrefix Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATRemovePrefix/README.md This snippet describes the process to run the memory safety proof for Cellular_ATRemovePrefix. It requires specific tools to be in the system's PATH and uses a 'make' command to generate an HTML report. ```bash make ``` -------------------------------- ### View Proof Results Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonRegisterUrcGenericCallback/README.md Command to open the generated proof results in a web browser. ```shell open html/index.html ``` -------------------------------- ### Run Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_GetModuleContext/README.md Executes the memory safety proof process using the 'make' command. This command orchestrates the compilation, instrumentation, and analysis steps required for the proof. ```make make ``` -------------------------------- ### View Proof Results Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/_Cellular_GetModuleContext/README.md Opens the generated proof results in a web browser. The results are typically found in an 'index.html' file within an 'html' directory, allowing for interactive exploration of the proof's findings. ```shell open html/index.html ``` -------------------------------- ### Create Unit Tests (CMake) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/unit-test/CMakeLists.txt Defines and creates individual unit test targets. Each test specifies its source file, linked libraries (including the real library and mocks), and include directories. ```CMake list(APPEND utest_link_list -l${mock_name} lib${real_name}.a ) list(APPEND utest_dep_list ${real_name} ) set(utest_name "${project_name}_pkthandler_utest") set(utest_source "${project_name}_pkthandler_utest.c") create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) set(utest_name "${project_name}_common_api_utest") set(utest_source "${project_name}_common_api_utest.c") create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) set(utest_name "${project_name}_3gpp_api_utest") set(utest_source "${project_name}_3gpp_api_utest.c") create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) set(utest_name "${project_name}_3gpp_urc_handler_utest") set(utest_source "${project_name}_3gpp_urc_handler_utest.c") create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) ``` ```CMake # The following unit test don't need mock module. set(utest_name "${project_name}_at_core_utest") set(utest_source "${project_name}_at_core_utest.c") # need to redefine because the tests below don't use any mocks set(utest_link_list "") list(APPEND utest_link_list lib${real_name}.a ) create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) # cellular_pktio_utest set(utest_name "${project_name}_pktio_utest") set(utest_source "${project_name}_pktio_utest.c") # need to redefine because the tests below don't use any mocks set(utest_link_list "") list(APPEND utest_link_list lib${real_name}.a ) create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) ``` -------------------------------- ### Build Library and Unit Tests with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/README.md Command to compile the FreeRTOS Cellular Interface library and its associated unit tests using the Make build tool. This command assumes the CMake configuration step has been completed. ```bash make -C build all ``` -------------------------------- ### Configure Coverity Analysis Target Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/CMakeLists.txt Sets up a CMake target named 'coverity_analysis' for static code analysis. It includes source files, defines necessary include directories, and specifies compile options like NDEBUG for the analysis build. ```cmake if( COV_ANALYSIS ) # Target for Coverity analysis that builds the library. add_library( coverity_analysis ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_at_core.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_common.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_common_api.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_3gpp_urc_handler.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_3gpp_api.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_pkthandler.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_pktio.c ) # Build Cellular library target without custom config dependency. target_compile_definitions( coverity_analysis PUBLIC CELLULAR_DO_NOT_USE_CUSTOM_CONFIG=1 ) # Cellular include path. target_include_directories( coverity_analysis PUBLIC ${CELLULAR_COMMON_INCLUDE_DIRS} ${CELLULAR_INCLUDE_DIRS} ${CELLULAR_INTERFACE_INCLUDE_DIRS} ${CELLULAR_TEST_DIRS} ) # Cellular private include path. target_include_directories( coverity_analysis PRIVATE ${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS} ) # Build without debug enabled when performing static analysis target_compile_options( coverity_analysis PUBLIC -DNDEBUG ) endif() ``` -------------------------------- ### Configure Mocks (CMake) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/unit-test/CMakeLists.txt Lists header files to be mocked and include directories required for the mock generation process. It also defines preprocessor macros for the mocks. ```CMake list(APPEND mock_list "${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS}/cellular_pktio_internal.h" "${CELLULAR_COMMON_INCLUDE_DIRS}/cellular_common.h" "${CELLULAR_COMMON_INCLUDE_DIRS}/cellular_at_core.h" "${CELLULAR_COMMON_INCLUDE_DIRS}/cellular_common_portable.h" ) list(APPEND mock_include_list . ${CMAKE_CURRENT_LIST_DIR}/logging ${CELLULAR_COMMON_INCLUDE_DIRS} ${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS} ${CELLULAR_INTERFACE_INCLUDE_DIRS} ${CELLULAR_INCLUDE_DIRS} ) list(APPEND mock_define_list "MOCK_LIB_TEST=1" ) ``` -------------------------------- ### CMake: Configure CMock and Unit Tests Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/CMakeLists.txt Sets up the CMock testing framework and unit test environment. It defines the CMock directory, includes build configurations, and enables testing utilities. The script also includes logic to clone the CMock submodule if it's missing and the build option is enabled. ```cmake if( UNITTEST ) # Define a CMock resource path. set( CMOCK_DIR ${MODULE_ROOT_DIR}/test/unit-test/CMock CACHE INTERNAL "CMock library source directory." ) # Include CMock build configuration. include( unit-test/cmock_build.cmake ) # Check if the CMock source directory exists, and if not present, clone the submodule # if BUILD_CLONE_SUBMODULES configuration is enabled. if( NOT EXISTS ${CMOCK_DIR}/src ) # Attempt to clone CMock. if( ${BUILD_CLONE_SUBMODULES} ) clone_cmock() else() message( FATAL_ERROR "The required submodule CMock does not exist. Either clone it manually, or set BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." ) endif() endif() # Add unit test and coverage configuration. # Use CTest utility for managing test runs. This has to be added BEFORE # defining test targets with add_test() enable_testing() # Add build targets for CMock and Unit, required for unit testing. add_cmock_targets() # Add function to enable CMock based tests and coverage. include( ${MODULE_ROOT_DIR}/tools/cmock/create_test.cmake ) # Include build configuration for unit tests. add_subdirectory( unit-test ) endif() ``` -------------------------------- ### Run Cellular_CommonGetServiceStatus Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetServiceStatus/README.md Executes the memory safety proof for Cellular_CommonGetServiceStatus. Ensure all required CBMC tools (cbmc, goto-cc, goto-instrument, goto-analyzer, cbmc-viewer) are in your system's PATH before running this command. The output will be an HTML report. ```shell make ``` -------------------------------- ### Run Memory Safety Proof with Make Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATGetSpecificNextTok/README.md This command initiates the memory safety proof process for Cellular_ATGetSpecificNextTok. It requires specific tools like cbmc, goto-cc, goto-instrument, goto-analyzer, and cbmc-viewer to be in the system's PATH. Upon successful execution, it generates HTML reports for analysis. ```shell make ``` -------------------------------- ### Checkout CMock Submodule for Unit Tests Source: https://github.com/freertos/freertos-cellular-interface/blob/main/README.md Command to update and initialize CMock submodules required for building unit tests. This ensures that the necessary testing framework dependencies are available. ```bash git submodule update --checkout --init --recursive test/unit-test/CMock ``` -------------------------------- ### Configure Unit Tests with CMake Source: https://github.com/freertos/freertos-cellular-interface/blob/main/README.md Command to configure the build system for unit tests using CMake. It specifies the source directory ('test') and the build output directory ('build'). ```bash cmake -S test -B build ``` -------------------------------- ### CMake Configuration for FreeRTOS Cellular Common Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/unit-test/CMakeLists.txt This CMake script configures the build process for the FreeRTOS cellular common module. It defines lists of header files for mocking, source files for the real library, and sets up targets for creating mock lists, real libraries, and unit tests. ```cmake # Create another custom mock list # list the files to mock here list(APPEND cellular_common_mock_list "${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS}/cellular_pktio_internal.h" "${CELLULAR_COMMON_INCLUDE_PRIVATE_DIRS}/cellular_pkthandler_internal.h" "${CELLULAR_COMMON_INCLUDE_DIRS}/cellular_at_core.h" ) # list the files you would like to test here list(APPEND cellular_common_real_source_files ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_common.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_3gpp_urc_handler.c ${CELLULAR_COMMON_SOURCE_DIRS}/cellular_3gpp_api.c ) set(cellular_common_mock_name "${project_name}_common_mock") set(cellular_common_real_name "${project_name}_common_real") create_mock_list(${cellular_common_mock_name} "${cellular_common_mock_list}" "${MODULE_ROOT_DIR}/tools/cmock/project.yml" "${mock_include_list}" "${mock_define_list}" ) create_real_library(${cellular_common_real_name} "${cellular_common_real_source_files}" "${real_include_directories}" "${cellular_common_mock_name}" ) set(utest_link_list "") list(APPEND utest_link_list -l${cellular_common_mock_name} lib${cellular_common_real_name}.a ) set(utest_dep_list "") list(APPEND utest_dep_list ${cellular_common_real_name} ) set(utest_name "${project_name}_common_utest") set(utest_source "${project_name}_common_utest.c") create_test(${utest_name} ${utest_source} "${utest_link_list}" "${utest_dep_list}" "${test_include_directories}" ) ``` -------------------------------- ### Execute Unit Tests with CTest Source: https://github.com/freertos/freertos-cellular-interface/blob/main/README.md Command to execute all configured tests and display a summary of the test run. It requires navigating into the build directory and invoking the CTest executable. ```bash cd build && ctest ``` -------------------------------- ### View Proof Results Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATRemoveOutermostDoubleQuote/README.md Opens the generated memory safety proof report in a web browser. This report details the findings of the proof execution. ```shell open html/index.html ``` -------------------------------- ### Run Cellular_CommonCleanup Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonCleanup/README.md Instructions to execute the memory safety proof for Cellular_CommonCleanup. This involves ensuring necessary verification tools are in the system's PATH and then running the 'make' command. The results can be viewed in a web browser. ```shell make ``` ```shell Open html/index.html in a web browser. ``` -------------------------------- ### Define Project Name (CMake) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/unit-test/CMakeLists.txt Sets the main project name for the FreeRTOS Cellular Interface build. This name is used to prefix generated library and mock targets. ```CMake set(project_name "cellular") ``` -------------------------------- ### Run Cellular_ATRemoveOutermostDoubleQuote Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_ATRemoveOutermostDoubleQuote/README.md Executes the memory safety proof for the Cellular_ATRemoveOutermostDoubleQuote function. Ensure the necessary proof tools (cbmc, goto-cc, etc.) are in your PATH before running. The proof generates an HTML report. ```makefile make ``` -------------------------------- ### Download FreeRTOS Cellular Interface Source Code Source: https://github.com/freertos/freertos-cellular-interface/blob/main/README.md Provides commands to clone the FreeRTOS Cellular Interface repository using Git, supporting both HTTPS and SSH protocols. ```Git git clone https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git ``` ```Git git clone git@github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git ``` -------------------------------- ### Run Cellular_CommonGetIPAddress Memory Safety Proof Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/cbmc/proofs/Cellular_CommonGetIPAddress/README.md Instructions for setting up and running the memory safety proof for the Cellular_CommonGetIPAddress function using CBMC tools. This involves adding necessary tools to the PATH, executing a make command, and viewing the generated HTML report. ```APIDOC Proof Execution Steps: 1. **Prerequisites**: Ensure the following tools are installed and accessible in your system's PATH: * cbmc * goto-cc * goto-instrument * goto-analyzer * cbmc-viewer 2. **Execution**: Navigate to the directory containing the proof files and run the following command: ```shell make ``` This command compiles the proof and generates the necessary output. 3. **Viewing Results**: After the make command completes, open the generated HTML report in a web browser: ```shell open html/index.html ``` (Replace 'open' with the appropriate command for your operating system, e.g., 'xdg-open' on Linux or 'start' on Windows). ``` -------------------------------- ### Generate Doxygen Documentation Source: https://github.com/freertos/freertos-cellular-interface/blob/main/README.md Command to generate Doxygen API reference pages from the repository root. This process requires Doxygen version 1.9.6. ```shell doxygen docs/doxygen/config.doxyfile ``` -------------------------------- ### Search for MISRA Violations Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Command to search for specific MISRA C:2012 violation references within the source code. This helps locate justifications for suppressed warnings. ```shell grep 'MISRA Ref 10.4.1' . -rI ``` -------------------------------- ### Cellular Interface File Size Report Source: https://github.com/freertos/freertos-cellular-interface/blob/main/docs/doxygen/include/size_table.md This report details the estimated code size in kilobytes (K) for individual C files and the total library size of the FreeRTOS cellular interface. It compares the sizes achieved with GCC compiler optimization levels -O1 (optimization for speed) and -Os (optimization for size). ```text File: cellular_3gpp_api.c -O1: 6.4K -Os: 5.9K File: cellular_3gpp_urc_handler.c -O1: 1.1K -Os: 1.0K File: cellular_at_core.c -O1: 1.4K -Os: 1.2K File: cellular_common_api.c -O1: 0.7K -Os: 0.7K File: cellular_common.c -O1: 1.7K -Os: 1.5K File: cellular_pkthandler.c -O1: 1.7K -Os: 1.6K File: cellular_pktio.c -O1: 2.3K -Os: 2.0K Total estimates: -O1: 15.3K -Os: 13.9K ``` -------------------------------- ### CMake: Custom Target for Coverage Analysis Source: https://github.com/freertos/freertos-cellular-interface/blob/main/test/CMakeLists.txt Defines a custom CMake target named 'coverage' to execute coverage analysis. This target depends on several unit test targets and uses a CMake script to perform the analysis, typically leveraging CMock and other testing tools. ```cmake add_custom_target( coverage COMMAND ${CMAKE_COMMAND} -DCMOCK_DIR=${CMOCK_DIR} -P ${MODULE_ROOT_DIR}/tools/cmock/coverage.cmake DEPENDS cmock unity cellular_at_core_utest cellular_pktio_utest cellular_pkthandler_utest cellular_common_api_utest cellular_common_utest cellular_3gpp_api_utest cellular_3gpp_urc_handler_utest WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### MISRA C:2012 Rule 21.9 Deviation (bsearch) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for using bsearch, which can have unspecified behavior with equal elements, violating Rule 21.9. This is mitigated by ensuring the comparison function never returns 0 for non-identical elements. ```c /* MISRA C-2012 Rule 21.9 does not allow the use of bsearch. This is because of unspecified behavior, which relates to the treatment of elements that compare as equal, can be avoided by ensuring that the comparison function never returns 0. When two elements are otherwise equal, the comparison function could return a value that indicates their relative order in the initial array. This the token table must be checked without duplicated string. The return value is 0 only if the string is exactly the same. */ ``` -------------------------------- ### strtol Conversion Check in FreeRTOS Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Demonstrates how to ensure a valid conversion with strtol in FreeRTOS by checking the end pointer, bypassing errno for thread-safety. ```c /* * MISRA C 2012 Rule 22.9 requires that errno must be tested after strtol * function is called. This violation is justified because error checking by * "errno" for any POSIX API is not thread safe in FreeRTOS unless * "configUSE_POSIX_ERRNO" is enabled. In order to avoid the dependency on this * feature, errno variable is not used. * * The function strtol returns LONG_MIN and LONG_MAX in case of underflow and * overflow respectively and sets the errno to ERANGE. It is not possible to * distinguish between valid LONG_MIN and LONG_MAX return values and underflow * and overflow scenarios without checking errno. * * Therefore, we cannot check return value of strtol for errors. * We ensure that strtol performed a valid conversion by checking that *pEndPtr * is '\0'. strtol stores the address of the first invalid character in *pEndPtr * and therefore, '\0' value of *pEndPtr means that the complete pToken string * passed for conversion was valid and a valid conversion was performed. */ // Example usage context (hypothetical): // char *pToken = "12345"; // char *pEndPtr; // long convertedValue = strtol(pToken, &pEndPtr, 10); // // if (*pEndPtr == '\0') { // // Conversion was successful and complete // // Use convertedValue // } else { // // Conversion failed or was incomplete // } ``` -------------------------------- ### MISRA C:2012 Rule 21.6 Deviation (I/O Functions) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for using standard library input/output functions, which might have implementation-defined behavior, violating Rule 21.6. String lengths are fixed and checked offline. ```c /* MISRA C-2012 Rule 21.6 warns about the use of standard library input/output functions as they might have implementation defined or undefined behaviour. The max length of the strings are fixed and checked offline. */ ``` -------------------------------- ### MISRA C:2012 Directive 4.6 Deviation (Type Information) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for using standard library functions like isalpha, isdigit, and isspace, which use base types without explicit size and sign information, violating Directive 4.6. ```c /* MISRA C-2012 Directive 4.6 warns against using types that do not contain size and sign information. The use of isalpha, isdigit, and isspace set this directive off since they use base types that don't contain this information. We do not have control over these functions so we are suppressing these violations. */ /* MISRA C-2012 Directive 4.6 warns against using types that do not contain size and sign information. However, in this case, the search function requires a comparison function pointer that returns a value of type int. To maintain compatibility with the search function's expected prototype, the comparison function must return an int type value despite the MISRA guidance. */ ``` -------------------------------- ### MISRA C:2012 Rule 10.4 Deviation (Type Operations) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for using standard library functions like isalpha, isdigit, and isspace, which may involve operations between different types, flagged by Rule 10.4. ```c /* MISRA C-2012 Rule 10.4 warns about using different types in an operation. This rule is being flagged because of use of the standard library functions isalpha, isdigit, and isspace. We do not have control over these functions so we are suppressing these violations. */ ``` -------------------------------- ### MISRA C:2012 Rule 10.8 Deviation (Unsigned to Signed Cast) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for casting from unsigned to signed types, flagged by Rule 10.8, specifically when using standard library functions like isalpha and isdigit. ```c /* MISRA C-2012 Rule 10.8 warns about casting from unsigned to signed types. This rule is being flagged because of use of the standard library functions isalpha and isdigit. We do not have control over these so we are suppressing these violations. */ ``` -------------------------------- ### MISRA C:2012 Rule 22.8 Deviation (strtol errno) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for not ensuring the 'errno' variable is zero before calling strtol, violating Rule 22.8. This is due to thread-safety issues with 'errno' in FreeRTOS, and conversion validity is checked by examining the end pointer. ```c /* MISRA C 2012 Rule 22.8 Requires the errno variable must be "zero" before calling strtol function. This violation is justified because error checking by "errno" for any POSIX API is not thread safe in FreeRTOS unless "configUSE_POSIX_ERRNO" is enabled. In order to avoid the dependency on this feature, errno variable is not used. The function strtol returns LONG_MIN and LONG_MAX in case of underflow and overflow respectively and sets the errno to ERANGE. It is not possible to distinguish between valid LONG_MIN and LONG_MAX return values and underflow and overflow scenarios without checking errno. Therefore, we cannot check return value of strtol for errors. We ensure that strtol performed a valid conversion by checking that *pEndPtr is '\0'. strtol stores the address of the first invalid character in *pEndPtr and therefore, '\0' value of *pEndPtr means that the complete pToken string passed for conversion was valid and a valid conversion wasperformed. */ ``` -------------------------------- ### MISRA C:2012 Directive 4.7 Deviation (Error Information) Source: https://github.com/freertos/freertos-cellular-interface/blob/main/MISRA.md Justification for not checking the return value of strtol() for errors, violating Directive 4.7. This is due to thread-safety concerns with 'errno' in FreeRTOS. ```c /* MISRA C 2012 Directive 4.7 requires that when a function returns error information, that error information shall be tested. The following line violates MISRA rule 4.7 because return value of strtol() is not checked for error. This violation is justified because error checking by "errno" for any POSIX API is not thread safe in FreeRTOS unless "configUSE_POSIX_ERRNO" is enabled. In order to avoid the dependency on this feature, errno variable is not used. */ ```