FuzzTest#

Pigweed AI summary: The FuzzTest module provides build files for including upstream FuzzTest. To use FuzzTest, you need to add it to your workspace as a submodule. You also need to set certain variables in your build files depending on the build system you are using (GN, CMake, or Bazel). The GN build files are generated from the third-party Bazel build files using a script, which should be re-run whenever the submodule is updated or the JSON file is modified. The script uses

The $dir_pw_third_party/fuzztest/ module provides build files to allow optionally including upstream FuzzTest.

Using upstream FuzzTest#

Pigweed AI summary: To use FuzzTest, you need to follow these steps: 1. Add FuzzTest to your workspace by running the command: `git submodule add https://github.com/google/fuzztest.git third_party/fuzztest`. 2. Set the GN build arguments, including the location of the FuzzTest source, Abseil C++ source, GoogleTest source, and RE2 source. This can be done in your `args.gn` or `.gn` file. 3.

If you want to use FuzzTest, you must do the following:

Submodule#

Pigweed AI summary: The Submodule section provides instructions for adding FuzzTest to a workspace using Git submodule. It also includes instructions for setting GN, CMake, and Bazel variables to locate the FuzzTest source and other dependencies. The instructions are provided in a tabbed format for each build system.

Add FuzzTest to your workspace with the following command.

git submodule add https://github.com/google/fuzztest.git \
  third_party/fuzztest

Set the GN following GN bauild args:

  • Set dir_pw_third_party_fuzztest to the location of the FuzzTest source. If you used the command above, this will be //third_party/fuzztest.

  • Set dir_pw_third_party_abseil_cpp to the location of the Abseil C++ source.

  • Set dir_pw_third_party_googletest to the location of the GoogleTest source.

  • Set dir_pw_third_party_re2 to the location of the RE2 source.

This can be set in your args.gn or .gn file. For example:

# Set build arguments here. See `gn help buildargs`.
dir_pw_third_party_abseil_cpp="//third_party/abseil-cpp"
dir_pw_third_party_fuzztest="//third_party/fuzztest"
dir_pw_third_party_googletest="//third_party/googletest"
dir_pw_third_party_re2="//third_party/re2"

Set the following CMake variables:

  • Set dir_pw_third_party_fuzztest to the location of the FuzzTest source.

  • Set dir_pw_third_party_googletest to the location of the GoogleTest source.

  • Set pw_unit_test_GOOGLETEST_BACKEND to pw_third_party.fuzztest.

Set the following label flags, either in your target config or on the command line:

  • pw_fuzzer_fuzztest_backend to @com_google_fuzztest//fuzztest.

For example:

bazel test //... \
   --@pigweed_config//:pw_fuzzer_fuzztest_backend=@com_google_fuzztest//fuzztest

Updating#

Pigweed AI summary: The GN build files are generated from the third-party Bazel build files using a script called generate_3p_gn.py. This script uses data from a JSON file called repo.json. The script should be re-run whenever the submodule is updated or the JSON file is modified. The location of the Bazel repository can be specified using the -w option in the command.

The GN build files are generated from the third-party Bazel build files using $dir_pw_build/py/pw_build/generate_3p_gn.py.

The script uses data taken from $dir_pw_third_party/fuzztest/repo.json.

The script should be re-run whenever the submodule is updated or the JSON file is modified. Specify the location of the Bazel repository can be specified using the -w option, e.g.

python pw_build/py/pw_build/generate_3p_gn.py \
  -w third_party/fuzztest/src

Version#

Pigweed AI summary: The update script was last run for revision 3c77f971. You can find more information about this revision at https://github.com/google/fuzztes/tree/3c77f97183a1270796d25db1a8956706a25af238.

The update script was last run for revision 3c77f971.