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