• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. _module-pw_third_party_fuzztest:
2
3========
4FuzzTest
5========
6The ``$dir_pw_third_party/fuzztest/`` module provides build files to allow
7optionally including upstream FuzzTest.
8
9.. _module-pw_third_party_fuzztest-using_upstream:
10
11-----------------------
12Using upstream FuzzTest
13-----------------------
14If you want to use FuzzTest, you must do the following:
15
16Submodule
17=========
18Add FuzzTest to your workspace with the following command.
19
20.. code-block:: sh
21
22   git submodule add https://github.com/google/fuzztest.git \
23     third_party/fuzztest
24
25.. tab-set::
26
27   .. tab-item:: GN
28
29      Set the GN following GN bauild args:
30
31      * Set ``dir_pw_third_party_fuzztest`` to the location of the FuzzTest
32        source. If you used the command above, this will be
33        ``//third_party/fuzztest``.
34
35      * Set ``dir_pw_third_party_abseil_cpp`` to the location of the
36        :ref:`module-pw_third_party_abseil_cpp` source.
37
38      * Set ``dir_pw_third_party_googletest`` to the location of the
39        :ref:`module-pw_third_party_googletest` source.
40
41      * Set ``dir_pw_third_party_re2`` to the location of the
42        :ref:`module-pw_third_party_re2` source.
43
44      This can be set in your ``args.gn`` or ``.gn`` file. For example:
45
46      .. code-block::
47
48         # Set build arguments here. See `gn help buildargs`.
49         dir_pw_third_party_abseil_cpp="//third_party/abseil-cpp"
50         dir_pw_third_party_fuzztest="//third_party/fuzztest"
51         dir_pw_third_party_googletest="//third_party/googletest"
52         dir_pw_third_party_re2="//third_party/re2"
53
54   .. tab-item:: CMake
55
56      Set the following CMake variables:
57
58      * Set ``dir_pw_third_party_fuzztest`` to the location of the
59        FuzzTest source.
60
61      * Set ``dir_pw_third_party_googletest`` to the location of the
62        :ref:`module-pw_third_party_googletest` source.
63
64      * Set ``pw_unit_test_BACKEND`` to ``pw_third_party.fuzztest``.
65
66   .. tab-item:: Bazel
67
68      Set the following `label flags`_, either in your `target config`_ or on
69      the command line:
70
71      * ``pw_fuzzer_fuzztest_backend`` to ``@com_google_fuzztest//fuzztest``.
72
73      For example:
74
75      .. code-block:: sh
76
77         bazel test //... \
78            --@pigweed//targets:pw_fuzzer_fuzztest_backend=@com_google_fuzztest//fuzztest
79
80.. _target config: :ref:`_docs-build_system-bazel_configuration`
81.. _label flags: :ref:`_docs-build_system-bazel_flags`
82
83Updating
84========
85The GN build files are generated from the third-party Bazel build files using
86$dir_pw_build/py/pw_build/generate_3p_gn.py.
87
88The script uses data taken from ``$dir_pw_third_party/fuzztest/repo.json``.
89
90The script should be re-run whenever the submodule is updated or the JSON file
91is modified. Specify the location of the Bazel repository can be specified using
92the ``-w`` option, e.g.
93
94.. code-block:: sh
95
96   python pw_build/py/pw_build/generate_3p_gn.py \
97     -w third_party/fuzztest/src
98
99Additionally, the ``fuzztest.bazelrc`` file should regenerated. From this
100directory, run:
101
102.. code-block:: sh
103
104   bazel run @com_google_fuzztest//bazel:setup_configs > fuzztest.bazelrc
105
106.. DO NOT EDIT BELOW THIS LINE. Generated section.
107
108Version
109=======
110The update script was last run for revision `6eb010c7`_.
111
112.. _6eb010c7: https://github.com/google/fuzztes/tree/6eb010c7223a6aa609b94d49bfc06ac88f922961
113