blob: f31fba330037ddba0e4b18e2d0841914ad67733f [file] [log] [blame]
Kevin Peng304e2682023-11-06 14:10:50 +08001###########
2Build Tests
3###########
4
5The tests is a TF-M application which verifies TF-M functionality on both SPE and NSPE sides.
6Thus, tests require an extension of SPE side with test code and extra functionality
7for some Non-Secure test cases. To inject that test code into SPE the
8``CONFIG_TFM_TEST_DIR`` option is used. When SPE build system sees this option
9it adds the corresponding folder via ``add_subdirectory(${CONFIG_TFM_TEST_DIR} tf-m-test)``
10and includes it to SPE binary.
11Also, test configurations should be passed to SPE build to include building Secure Tests.
12
13To hide these complexities to developers, TF-M implements a wrapper CMake in **tf-m-tests**
14repository to build the SPE for testing rather than building it from the TF-M repository.
15
16The recommended tf-m-tests repo commit to verify TF-M can be found at
17``<TF-M source dir>/lib/ext/tf-m-tests/version.txt``.
18It does not support auto-downloading as builds start from it.
19You need to download it manually before building any tests.
20
21Regression Tests
22================
23For instructions on configuring, building and executing the regression tests
24please refer to the documentation in **tf-m-tests** repository (to be added).
25The regression test application is located under **/tests_reg** folder.
26It is recommended to build both SPE and NSPE from that folder.
27
28The basic commands for building the regression tests will be:
29
30.. code-block:: bash
31
32 cd </tf-m-tests/tests_reg>
Kevin Peng1872b5d2023-11-10 15:13:11 +080033 cmake -S spe -B build_spe -DTFM_PLATFORM=arm/mps2/an521 \
34 -DCONFIG_TFM_SOURCE_PATH=<TF-M source dir> \
35 -DTFM_TOOLCHAIN_FILE=<Absolute path to>/toolchain_ARMCLANG.cmake \
Kevin Peng304e2682023-11-06 14:10:50 +080036 -DTEST_S=ON -DTEST_NS=ON
37 cmake --build build_spe -- install
38
39 cmake -S . -B build_test -DCONFIG_SPE_PATH=<Absolute path to>/build_spe/api_ns
40 cmake --build build_test
41
Kevin Peng1872b5d2023-11-10 15:13:11 +080042Instead of enable all the supported Secure (``TEST_S``) and NS (``TEST_NS``) tests, you can also
Kevin Peng304e2682023-11-06 14:10:50 +080043enable individual test suites by using ``-DTEST_S_<SUITE>=ON`` or ``-DTEST_NS_<SUITE>=ON``.
44For the available test suites, refer to the ``default_s_test_config.cmake`` and
45``default_ns_test_config.cmake`` files in tf-m-tests repo.
46
Kevin Peng1872b5d2023-11-10 15:13:11 +080047.. Note::
48 All the test suite config options should be passed to the SPE build command, including NS ones.
49 The SPE building command also accepts all the other config options used to build a single TF-M.
50 All options passing to SPE build does not have to be duplicated in NSPE build, including NS test
51 suite config options.
52 And this also applies to the below `PSA API tests`_.
53
Kevin Peng304e2682023-11-06 14:10:50 +080054PSA API tests
55=============
56PSA API tests from https://github.com/ARM-software/psa-arch-tests use the same
57mechanism for SPE extension as the regression tests above utilising ``CONFIG_TFM_TEST_DIR`` option.
58PSA API tests are selected by the TEST_PSA_API variable. Enabling both regression tests and
59PSA API tests simultaneously is **not** supported.
60
61TF-M implements a wrapper CMake for PSA API tests as well.
62The PSA API test codes are located under **/tests_psa_arch** folder.
63
64Here is a brief description of the basic flow:
65There are 5 different TEST_PSA_API test suites to be run.
66
67.. code-block:: bash
68
69 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
70 -DTEST_PSA_API=PROTECTED_STORAGE
71 -DTEST_PSA_API=STORAGE
72 -DTEST_PSA_API=CRYPTO
73 -DTEST_PSA_API=INITIAL_ATTESTATION
74
75Respectively for the corresponding service. For example, to enable the PSA API
76tests for the Crypto service:
77
78.. code-block:: bash
79
80 cd </tf-m-tests/tests_psa_arch folder>
81 cmake -S spe -B build_spe -DTFM_PLATFORM=arm/mps2/an521 -DCONFIG_TFM_SOURCE_PATH=<TF-M source dir>
82 -DTEST_PSA_API=CRYPTO
83 cmake --build build_spe -- install
84
85 cmake -S . -B build_test -DCONFIG_SPE_PATH=<Absolute path to>/build_spe/api_ns
86 cmake --build build_test
87
88--------------
89
90*Copyright (c) 2017-2023, Arm Limited. All rights reserved.*
91*Copyright (c) 2022, Cypress Semiconductor Corporation. All rights reserved.*