blob: d99196de194db0f4e232549fe697261a5b02bf3d [file] [log] [blame]
Karl Zhang3de5ab12021-05-31 11:45:48 +08001#######################################
2TF-Fuzz (Trusted-Firmware Fuzzer) guide
3#######################################
4
5************
6Introduction
7************
8
9TF-Fuzz is a TF-M fuzzing tool, at the PSA-call level. At the time of writing
10this at least, presentations available at:
11
12- https://www.trustedfirmware.org/docs/TF-M_Fuzzing_Tool_TFOrg.pdf
13- https://zoom.us/rec/share/1dxZcZit111IadadyFqFU7IoP5X5aaa8gXUdr_UInxmMbyLzEqEmXQdx79-IWQ9p
14
15(These presentation materials may not all be viewable by all parties.)
16
Nik Dewally3a98fe32024-07-09 16:30:17 +010017A suite generator tool is also provided to make tests output by TF-Fuzz
18runnable as a test suite in the regression tester.
Nik Dewally6fd2f992024-07-01 13:53:23 +010019
Nik Dewally3a98fe32024-07-09 16:30:17 +010020
21*******************************
22Building and Installing TF-Fuzz
23*******************************
24
25.. Note::
Nik Dewally6fd2f992024-07-01 13:53:23 +010026
27 These instructions assume the use of Ubuntu Linux.
28
29
30The following dependencies are required to build TF-Fuzz:
31
Nik Dewally6fd2f992024-07-01 13:53:23 +010032.. code-block:: bash
33
34 sudo apt-get update
35 sudo apt-get install build-essential bison flex
36
37
Karl Zhang3de5ab12021-05-31 11:45:48 +080038To build TF-Fuzz, simply type ``make`` in this directory. The executable,
Nik Dewally3a98fe32024-07-09 16:30:17 +010039called ``tfz``, is placed in the ``bin/`` directory.
Karl Zhang3de5ab12021-05-31 11:45:48 +080040
Nik Dewally3a98fe32024-07-09 16:30:17 +010041======================================
42Installing the TF-Fuzz suite generator
43======================================
Nik Dewally6fd2f992024-07-01 13:53:23 +010044
Nik Dewally3a98fe32024-07-09 16:30:17 +010045**Requirements:** Python 3.8 or later; a built ``tfz`` binary.
46
47
48The suite generator is installable as a Python package through ``pip``:
Karl Zhang3de5ab12021-05-31 11:45:48 +080049
50.. code-block:: bash
51
Nik Dewally3a98fe32024-07-09 16:30:17 +010052 cd <path/to/tf-tools>/tf_fuzz
53 pip3 install tfz-suitegen
54
55Once installed, ``tfz-suitegen`` can be ran by typing ``python3 -m tfz-suitegen``.
Karl Zhang3de5ab12021-05-31 11:45:48 +080056
Nik Dewally6fd2f992024-07-01 13:53:23 +010057
Nik Dewally3a98fe32024-07-09 16:30:17 +010058******************************************
59Generating and running tests using TF-Fuzz
60******************************************
Nik Dewally6fd2f992024-07-01 13:53:23 +010061
Nik Dewally3a98fe32024-07-09 16:30:17 +010062**Full usage information can be found by running** ``./bin/tfz`` **and** ``python3 -m tfz-suitegen --help`` **.**
Nik Dewally6fd2f992024-07-01 13:53:23 +010063
Nik Dewally3a98fe32024-07-09 16:30:17 +010064The ``demo`` folder contains some example test specifications. The below steps
65describe how to build and run these with the TF-M regression tester.
Nik Dewally6fd2f992024-07-01 13:53:23 +010066
Nik Dewally3a98fe32024-07-09 16:30:17 +010067#. Turn the test specifications into a test suite:
Nik Dewally6fd2f992024-07-01 13:53:23 +010068
Nik Dewally3a98fe32024-07-09 16:30:17 +010069 .. code-block:: bash
Nik Dewally6fd2f992024-07-01 13:53:23 +010070
Nik Dewally3a98fe32024-07-09 16:30:17 +010071 python3 -m tfz-suitegen <path/to/tf_fuzz> <path/to/tf_fuzz>/demo build_suite
Nik Dewally6fd2f992024-07-01 13:53:23 +010072
Nik Dewally3a98fe32024-07-09 16:30:17 +010073 This creates an :external:ref:`out-of-tree test suite
74 <tfm_test_suites_addition:out-of-tree regression test suites>` containing
75 all the tests in the ``demo`` folder.
Nik Dewally6fd2f992024-07-01 13:53:23 +010076
Nik Dewally3a98fe32024-07-09 16:30:17 +010077 .. note::
78 Only files with the ``.test`` extension are included in the test suite.
Nik Dewally6fd2f992024-07-01 13:53:23 +010079
Nik Dewally3a98fe32024-07-09 16:30:17 +010080#. Build the regression tests as normal, adding the following CMake flag to the SPE build:
Nik Dewally6fd2f992024-07-01 13:53:23 +010081
Nik Dewally3a98fe32024-07-09 16:30:17 +010082 .. code-block:: bash
Karl Zhang3de5ab12021-05-31 11:45:48 +080083
Nik Dewally3a98fe32024-07-09 16:30:17 +010084 -DEXTRA_NS_TEST_SUITE_PATH=<absolute_path_to>/build_suite
Karl Zhang3de5ab12021-05-31 11:45:48 +080085
Nik Dewally3a98fe32024-07-09 16:30:17 +010086 For full instructions on how to build and run tests see
87 :external:doc:`building/tests_build_instruction` and
88 :external:ref:`building/run_tfm_examples_on_arm_platforms:run tf-m tests and
89 applications on arm platforms`.
Karl Zhang3de5ab12021-05-31 11:45:48 +080090
Nik Dewally3db11f72024-07-19 10:23:30 +010091.. warning::
92
93 Some of the provided demos are expected to fail.
94
95
Nik Dewallyfc87b062024-07-16 14:05:17 +010096************************************
97Running the TF-Fuzz regression tests
98************************************
99
100To run the regression test suite:
101
102.. code-block:: bash
103
104 cd <path/to/tf-tools>/tf_fuzz/tfz-cpp
105 make
106 cd regression
107 bash regress
108
109
110For more details, see :doc:`source_structure/regression_dir`.
111
112
Nik Dewally6fd2f992024-07-01 13:53:23 +0100113.. toctree::
114 :caption: Table of Contents
115 :maxdepth: 1
116
117 Source Structure <source_structure/index>
118
Karl Zhang3de5ab12021-05-31 11:45:48 +0800119--------------
120
Nik Dewally6fd2f992024-07-01 13:53:23 +0100121*Copyright (c) 2020-2024, Arm Limited. All rights reserved.*