xref: /aosp_15_r20/external/pigweed/third_party/fuzztest/docs.rst (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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 :ref:`label flags <docs-build_system-bazel_flags>`,
69      either in your :ref:`target config
70      <docs-build_system-bazel_configuration>` or on the command line:
71
72      * ``pw_fuzzer_fuzztest_backend`` to ``@com_google_fuzztest//fuzztest``.
73
74      For example:
75
76      .. code-block:: sh
77
78         bazel test //... \
79            --@pigweed//targets:pw_fuzzer_fuzztest_backend=@com_google_fuzztest//fuzztest
80
81Updating
82========
83The GN build files are generated from the third-party Bazel build files using
84$dir_pw_build/py/pw_build/bazel_to_gn.py.
85
86The script uses data taken from a ``bazel_to_gn.json`` file for this module and
87for each third party module that this module depends on, e.g.
88``$PW_ROOT/third_party/fuzztest/bazel_to_gn.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 using ``gn args``,
92then run:
93
94.. code-block:: sh
95
96   python pw_build/py/pw_build/bazel_to_gn.py fuzztest
97
98Additionally, the ``fuzztest.bazelrc`` file should regenerated. From this
99directory, run:
100
101.. code-block:: sh
102
103   bazel run @com_google_fuzztest//bazel:setup_configs > fuzztest.bazelrc
104
105.. DO NOT EDIT BELOW THIS LINE. Generated section.
106
107Version
108=======
109The update script was last run for revision `b7257a64`_.
110
111.. _b7257a64: https://github.com/google/fuzztes/tree/b7257a64c701fc30265eb91179bf9310549bf440
112