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