1# OP-TEE sanity testsuite 2The optee_test git contains the source code for the TEE sanity 3testsuite in Linux using the ARM(R) TrustZone(R) technology. 4It is distributed under the GPLv2 and BSD 2-clause open-source 5licenses. 6For a general overview of OP-TEE, please see the 7[Notice.md](Notice.md) file. 8 9## License 10The client applications (`optee_test/host/*`) are provided under the 11[GPL-2.0](http://opensource.org/licenses/GPL-2.0) license. 12The user TAs (`optee_test/ta/*`) are provided under the 13[BSD 2-Clause](http://opensource.org/licenses/BSD-2-Clause) license. 14 15 16## Get and build the software 17 18### HOWTO build the testsuite 19#### Standard tests 20xtest test suite comes with a standard test suite, 21freely available. When installing OP-TEE through the 22[manifest](https://github.com/OP-TEE/optee_os/blob/master/README.md#6-repo-manifests), 23the [build](https://github.com/OP-TEE/build) 24component provides the `xtest` target which builds optee_test. 25It makes use of the following environment variables: 26* `CROSS_COMPILE_HOST`: the cross compiler used to compile the 27 Non-Secure Client Application (`host/xtest`) 28* `CROSS_COMPILE_TA`: the cross compiler used to compile the 29 Trusted Applications (`ta`) 30* `TA_DEV_KIT_DIR`: the path to the Trusted Application Dev Kit. 31 It can be found in optee_os repository, once optee_os has been compiled. 32* `O`: the output repository 33* When the application is compiled in 32bits mode, 34 `CFG_ARM32=y` must be set. 35 36 37#### Extended test (Global Platform tests) 38Developers can purchase the 39[Global Platform Compliance Test suite](https://www.globalplatform.org/store.asp). 40This test suite comes with .xml files describing the tests and 41the Trusted Applications. 42 43Standard tests can be extended with the Global Platform test suite. 44The user must only: 45* Install the Global Platform `xml` files in `$CFG_GP_PACKAGE_PATH` 46* Run `make patch` (or call make `xtest-patch` from the `build` repository) 47 before compiling xtest. This must be run a single time after the installation 48 of OP-TEE. 49 50This will: 51* Create new Trusted Applications, that can be found in `ta/GP_xxx` 52* Create new tests in `host/xtest`, as for example `xtest_9000.c` 53* Patches `xtest_7000.c`, adding new tests. 54 55Then the tests must be compiled with `CFG_GP_PACKAGE_PATH=<path>`. 56 57 58### HOWTO run xtest 59 60 # all xtest 61 boot and execute on your target 62 $ modprobe optee_armtz 63 $ tee-supplicant & 64 $ xtest 65 66 # single xtest 67 boot and execute on your target 68 $ modprobe optee_armtz 69 $ tee-supplicant & 70 $ xtest <testnumber> (i.e.: xtest 1001) 71 72 # family xtest (i.e.: Family 1000) 73 boot and execute on your target 74 $ modprobe optee_armtz 75 $ tee-supplicant & 76 $ xtest _<family> (i.e.: xtest _1) 77 78#### Compiler flags 79To be able to see the full command when building you could build using following 80flag: 81 82`$ make V=1` 83 84To state where build files are stored use the `O` flag. 85 86`$ make O=$HOME/foo` 87 88By default `optee_test` expects that `optee_client` is located at the same 89folder level. However if you build optee_client in another location, then you 90also would need to use (or export) the following flag: 91 92`$ make OPTEE_CLIENT_PATH=$HOME/my_new_location` 93 94## Coding standards 95In this project we are trying to adhere to the same coding convention as used in 96the Linux kernel (see 97[CodingStyle](https://www.kernel.org/doc/Documentation/CodingStyle)). We achieve this by running 98[checkpatch](http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl) from Linux kernel. 99However there are a few exceptions that we had to make since the code also 100follows GlobalPlatform standards. The exceptions are as follows: 101 102- CamelCase for GlobalPlatform types are allowed. 103- And we also exclude checking third party code that we might use in this 104 project, such as LibTomCrypt, MPA, newlib (not in this particular git, but 105 those are also part of the complete TEE solution). The reason for excluding 106 and not fixing third party code is because we would probably deviate too much 107 from upstream and therefore it would be hard to rebase against those projects 108 later on (and we don't expect that it is easy to convince other software 109 projects to change coding style). 110 111### checkpatch 112Since checkpatch is licensed under the terms of GNU GPL License Version 2, we 113cannot include this script directly into this project. Therefore we have 114written the Makefile so you need to explicitly point to the script by exporting 115an environment variable, namely CHECKPATCH. So, suppose that the source code for 116the Linux kernel is at `$HOME/devel/linux`, then you have to export like follows: 117 118 $ export CHECKPATCH=$HOME/devel/linux/scripts/checkpatch.pl 119thereafter it should be possible to use one of the different checkpatch targets 120in the [Makefile](Makefile). There are targets for checking all files, checking 121against latest commit, against a certain base-commit etc. For the details, read 122the [Makefile](Makefile). 123