Description

Example program integrating Mayhem and Parasoft Cpp.

Important files

  • CMakeLists.txt Cmake build definition. This is leading, the Makefile is generated from this
  • Makefile although generated from CMake, checked into SCM for CppTest to work okay.
  • Dockerfile specifies the Docker container with the program Mayhem needs to generate test cases
  • Mayhemfile specifies the parameters for the Mayhem job so Mayhem can generate test cases
  • mayhemit.c the program we're fuzzing

Generate unit case input (no dependency on CppTest)

build-container-run-mayhem-and-wait-for-testsuites.sh this builds the container and kicks off a job in Mayhem. Note that parameters are needed, invoke the script to found out which.

It append the test cases to the tests/autogenerated/test_mayhemit_mayhem.csv file.

Run coverage report (depends on CppTest)

Run in order:

  • build-instrumented-mayhemit.sh builds a mayhemit binary that output coverage information via the CppTest CMake integration
  • run-mayhem-testcases-manually.sh executes the files in the testsuites directory
  • coverage-report.sh generates a coverage report from the MayhemIt.clog file that is appended to as the test cases in the previous step run

Coverage with and without Mayhem:

Screenshot 2023-02-17 at 3 30 10 PM

Screenshot 2023-02-17 at 3 32 22 PM

Manual steps done to create this repository (depends on CppTest)

  • Install Parasoft CppTest (google) in /home/ubuntu/cpptest
  • Activate license
  • Create new project, import code, create build files
  • Use CppTest to generate unit tests (follow Parasoft guides)
  • Go to TestSuite_mayhemit_c.c in CppTest, right click, Parasoft > Add unit test using using Wizard.

image

  • Follow this guide to add data source which will appear in tests/autogenerated/test_mayhemit_mayhem.csv