Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _optee_test: |
| 2 | |
| 3 | ########## |
| 4 | optee_test |
| 5 | ########## |
| 6 | The optee_test.git contains the source code for the TEE sanity test suite in |
| 7 | Linux using the ARM(R) TrustZone(R) technology. It is typically referred to as |
| 8 | `xtest`. By default there are several thousands of tests when running the code |
| 9 | that is in the git only. However, it is also possible to incorporate tests |
| 10 | coming from GlobalPlatform (see :ref:`globalplatform_tests`). We typically refer |
| 11 | to these to as: |
| 12 | |
| 13 | - **Standard tests**: These are the test that are included in optee_test. |
| 14 | They are free and open source. |
| 15 | |
| 16 | - **Extended tests**: Those are the tests that are written directly by |
| 17 | GlobalPlatform. They are **not** open source and they are **not** freely |
| 18 | available (it's free to members of GlobalPlatform and can otherwise be |
| 19 | purchased directly from GlobalPlatform). |
| 20 | |
| 21 | git location |
| 22 | ************ |
| 23 | https://github.com/OP-TEE/optee_test |
| 24 | |
| 25 | License |
| 26 | ******* |
| 27 | .. todo:: |
| 28 | |
| 29 | Joakim: Necessary to state that here? Changing the "License headers" page to |
| 30 | instead become a "License" page and add addtional sections. |
| 31 | |
| 32 | The client applications (``optee_test/host/*``) are provided under the |
| 33 | `GPL-2.0`_ license and the user Trusted Applications (``optee_test/ta/*``) are |
| 34 | provided under the `BSD 2-Clause`_. |
| 35 | |
| 36 | Build instructions |
| 37 | ****************** |
| 38 | At the moment you can **only** build the code in this git as part of the entire |
| 39 | system, i.e. as a part of a full OP-TEE developer setup. So, please refer to |
| 40 | the instructions at the :ref:`build` page to learn how to build a full OP-TEE |
| 41 | developer setup. Building purely standalone is **not** possible (*) because: |
| 42 | |
| 43 | - the host code (``xtest``) have dependencies to the :ref:`optee_client` (it |
| 44 | links against ``libteec``, ``openssl`` and uses various headers) |
| 45 | |
| 46 | - the Trusted Applications have dependencies to the TA-devkit built by |
| 47 | :ref:`optee_os`. |
| 48 | |
| 49 | .. note:: |
| 50 | |
| 51 | (*) It is of course possible to build this without a full OP-TEE |
| 52 | developer setup, but it will require a lot of tweaking with paths, flags |
| 53 | etc. I.e., one would need to do exactly the same as the full OP-TEE |
| 54 | developer setup does under the hood. |
| 55 | |
| 56 | .. _globalplatform_tests: |
| 57 | |
| 58 | Extended test (GlobalPlatform tests) |
| 59 | ************************************ |
| 60 | One can purchase the `GlobalPlatform Compliance Test suite`_ which comes with |
| 61 | .xml files describing the tests and the Trusted Applications. The standard tests |
| 62 | (xtest + TA's) that are free and open source can be extended to also include the |
| 63 | GlobalPlatform test suite. This is done by: |
| 64 | |
| 65 | - Install the GlobalPlatform ``xml`` files in ``$CFG_GP_PACKAGE_PATH``. |
| 66 | |
| 67 | - Run ``make patch`` (or call make ``xtest-patch`` from the ``build`` |
| 68 | repository) before compiling xtest. This must be run a single time after the |
| 69 | installation of OP-TEE. |
| 70 | |
| 71 | This will: |
| 72 | |
| 73 | - Create new Trusted Applications, that can be found in ``ta/GP_xxx`` |
| 74 | - Create new tests in ``host/xtest``, as for example ``xtest_9000.c`` |
| 75 | - Patches ``xtest_7000.c``, adding new tests. |
| 76 | |
| 77 | Then the tests must be compiled with ``CFG_GP_PACKAGE_PATH=<path>``. |
| 78 | |
| 79 | It makes use of the following environment variable: |
| 80 | |
| 81 | - ``COMPILE_NS_USER``: ``32`` or ``64`` if application shall be compiled in |
| 82 | 32 bits mode on in 64 bits mode. If ``COMPILE_NS_USER`` is not specified, |
| 83 | build relies on ``CFG_ARM32_core=y`` from OP-TEE core build to assume |
| 84 | applications are in 32 bits mode, Otherwise, 64 bits mode is assumed. |
| 85 | |
| 86 | .. _optee_test_run_xtest: |
| 87 | |
| 88 | Run xtest |
| 89 | ********* |
| 90 | It's important to understand that you run ``xtest`` on the device itself, i.e., |
| 91 | this is nothing that you run on the host machine. |
| 92 | |
| 93 | xtest - default |
| 94 | =============== |
| 95 | The most simple case is to run the default configuration: |
| 96 | |
| 97 | .. code-block:: bash |
| 98 | |
| 99 | $ xtest |
| 100 | |
| 101 | xtest - all |
| 102 | =========== |
| 103 | This runs all tests within the standard xtest. Using the ``-l`` parameter you |
| 104 | can tweak the amount of tests you will run. ``15`` is the most and ``0`` is the |
| 105 | least. |
| 106 | |
| 107 | .. code-block:: bash |
| 108 | |
| 109 | $ xtest -l 15 |
| 110 | |
| 111 | xtest - single |
| 112 | ============== |
| 113 | To run a single test case, just specify its numbers, for example: |
| 114 | |
| 115 | .. code-block:: bash |
| 116 | |
| 117 | $ xtest 1001 |
| 118 | |
| 119 | xtest - family |
| 120 | ============== |
| 121 | To run a family (``1xxx``, ``2xxx`` and so on), just specify its number prefixed |
| 122 | with an underscore. This for example will run the 1xxx family. |
| 123 | |
| 124 | .. code-block:: bash |
| 125 | |
| 126 | $ xtest _1 |
| 127 | |
| 128 | xtest - benchmark |
| 129 | ================= |
| 130 | To run the benchmark tests, run xtest like this: |
| 131 | |
| 132 | .. code-block:: bash |
| 133 | |
| 134 | $ xtest -t benchmark |
| 135 | |
| 136 | Here it is also possible to state a number for a certain benchmark test, for |
| 137 | example: |
| 138 | |
| 139 | .. code-block:: bash |
| 140 | |
| 141 | $ xtest -t benchmark 2001 |
| 142 | |
| 143 | xtest - regression |
| 144 | ================== |
| 145 | To run the regression tests, run xtest like this: |
| 146 | |
| 147 | .. code-block:: bash |
| 148 | |
| 149 | $ xtest -t regression |
| 150 | |
| 151 | Here it is also possible to state a number for a certain regression test, for |
| 152 | example: |
| 153 | |
| 154 | .. code-block:: bash |
| 155 | |
| 156 | $ xtest -t regression 2004 |
| 157 | |
| 158 | xtest - aes-perf |
| 159 | ================ |
| 160 | This is benchmark test for AES and you run it like this: |
| 161 | |
| 162 | .. code-block:: bash |
| 163 | |
| 164 | $ xtest --aes-perf |
| 165 | |
| 166 | .. note:: |
| 167 | |
| 168 | There is an individual help for ``--aes-perf``, i.e. |
| 169 | |
| 170 | ``$ xtest --aes-perf -h`` |
| 171 | |
| 172 | xtest - sha-perf |
| 173 | ================ |
| 174 | This is benchmark test for SHA-xxx and you run it like this: |
| 175 | |
| 176 | .. code-block:: bash |
| 177 | |
| 178 | $ xtest --sha-perf |
| 179 | |
| 180 | .. note:: |
| 181 | |
| 182 | There is an individual help for ``--sha-perf``, i.e. |
| 183 | |
| 184 | ``$ xtest --sha-perf -h`` |
| 185 | |
| 186 | There you can select other SHA algorithms etc. |
| 187 | |
| 188 | .. todo:: |
| 189 | |
| 190 | Joakim: Should have a section about --install-ta also. |
| 191 | |
| 192 | Coding standards |
| 193 | **************** |
| 194 | See :ref:`coding_standards`. |
| 195 | |
| 196 | .. _BSD 2-Clause: http://opensource.org/licenses/BSD-2-Clause |
| 197 | .. _GlobalPlatform Compliance Test suite: https://store.globalplatform.org/product/tee-initial-configuration-test-suite-with-excluded-tests-list-2/ |
| 198 | .. _GPL-2.0: http://opensource.org/licenses/GPL-2.0 |