FreeRTOS-Kernel/FreeRTOS/Test/CBMC
ActoryOu c5c41ef3af
Update result section in README under CBMC folder. (#1196)
* Update result section in README under CBMC folder

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

* Update proofs result path

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2024-03-22 10:43:47 +08:00
..
cmake Copying CBMC proofs from aws/amazon-freertos repo ./tools/cbmc to this repo ./FreeRTOS/Test/CBMC as is. 2020-03-31 14:21:53 -07:00
include Use CI-CD-Github-Actions for spelling and formatting, add in the bot formatting action, update the CI-CD workflow files. Fix incorrect spelling and formatting on files. (#1083) 2023-09-06 12:35:37 -07:00
patches Remove deprecated ipconfigRAND32 (#1108) 2023-11-01 12:33:25 +05:30
proofs Update for kernel idle task unit test (#1096) 2023-10-12 12:53:52 +08:00
windows Add uncrustify github workflow (#659) 2021-07-22 14:23:48 -07:00
.gitignore Copying CBMC proofs from aws/amazon-freertos repo ./tools/cbmc to this repo ./FreeRTOS/Test/CBMC as is. 2020-03-31 14:21:53 -07:00
README.md Update result section in README under CBMC folder. (#1196) 2024-03-22 10:43:47 +08:00

CBMC Proof Infrastructure

This directory contains automated proofs of the memory safety of various parts of the FreeRTOS codebase. A continuous integration system validates every pull request posted to the repository against these proofs, and developers can also run the proofs on their local machines.

The proofs are checked using the C Bounded Model Checker, an open-source static analysis tool (GitHub repository). This README describes how to run the proofs on your local clone of FreeRTOS.

Building and running proofs

Currently, only python based builds are supported for the CBMC proofs. The proofs can be run on Linux and MacOS. Windows users can use WSL. The below section outlines the instructions for the Python based build.

Prerequisites

On Windows, you can install WSL using these simple instructions.

You will need Python version >= 3.7. And you will need Make to build and run the proofs.

If you are running on a 64-bit machine, please install the 32-bit version of gcc libraires. For example, on linux, one would run the following command to install the libraries: sudo apt-get install gcc-multilib

Installing CBMC

  • The latest installation instructions can be found on the releases page of the CBMC repository.

  • Please follow all the installation instructions given for your platform.

  • Ensure that you can run the programs cbmc, goto-cc (or goto-cl on Windows), and goto-instrument from the command line. If you cannot run these commands, please refer to the above instructions to install CBMC.

Installing CBMC-viewer (to generate the report)

  • The latest installation instructions can be found on the releases page of the CBMC-viewer repository.

  • Please follow all the installation instructions given for your platform.

  • Ensure that you can run the programs cbmc-viewer. If not, please verify that all instructions above have been followed.

Setting up the proofs

Make sure that all the submodules of the FreeRTOS repository have been cloned. To clone all the submodules, go to the root of the FreeRTOS repository and run this command: git submodule update --init --recursive --checkout.

Change into the proofs directory and run

python3 prepare.py

If you are on a Windows machine but want to generate Linux Makefiles (or vice versa), you can pass the --system linux or --system windows options to those programs.

Running the proofs

Each of the leaf directories under proofs is a proof of the memory safety of a single entry point in FreeRTOS. The scripts that you ran in the previous step will have left a Makefile in each of those directories. To run a proof, change into the directory for that proof and run make. The proofs may take some time to run.

Proof results

The make command above generates a report in HTML and JSON format. Taking TaskCreate as an example:

  • HTML report is generated at ./proofs/Task/TaskCreate/html/html.
  • JSON report is generated at ./proofs/Task/TaskCreate/html/json.

You can open ./proofs/Task/TaskCreate/html/html/index.html in any browser to view the HTML report. You should see None under the Errors section in case of a successful run.

Proof directory structure

This directory contains the following subdirectories:

  • proofs contains the proofs run against each pull request
  • patches contains a set of patches that get applied to the codebase prior to running the proofs. The patches are used to remove static and volatile qualifiers from the source.
  • include and windows contain header files used by the proofs.