Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 1 | # Testing |
| 2 | |
| 3 | Testing of Hafnium is currently evolving. There are basic tests running on QEMU |
| 4 | but we want more and more kinds of tests e.g. unit tests. |
| 5 | |
| 6 | ## Presubmit |
| 7 | |
| 8 | Presubmit builds everything, runs all tests and checks the source for |
| 9 | formatting and lint errors. This can be run locally with: |
| 10 | |
| 11 | ``` shell |
| 12 | ./kokoro/ubuntu/build.sh |
| 13 | ``` |
| 14 | |
| 15 | Or to just run the tests after having built everything manually run: |
| 16 | |
| 17 | ``` shell |
| 18 | ./kokoro/ubuntu/test.sh |
| 19 | ``` |
| 20 | |
| 21 | ## QEMU tests |
| 22 | |
| 23 | These tests boot Hafnium on QEMU and the VMs make calls to Hafnium to test its |
| 24 | behaviour. |
| 25 | |
| 26 | ### `hftest` |
| 27 | |
Andrew Walbran | 01cdc73 | 2018-09-10 16:29:50 +0100 | [diff] [blame] | 28 | Having a framework for tests makes them easier to read and write. `hftest` is a |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 29 | framework to meet the needs of VM based tests for Hafnium. It consists of: |
| 30 | |
| 31 | * assertions |
| 32 | * test declarations |
| 33 | * base VM image |
| 34 | * driver script |
| 35 | |
| 36 | Assertions should be familiar from other testing libraries. They make use of |
| 37 | C11's `_Generic` expressions for type genericity. |
| 38 | |
| 39 | Test declarations name the test and the suite that the test is part of. |
| 40 | Declarations are converted into descriptors stored in the `.hftest` section of |
| 41 | the VM image which allows the image to inspect the structure of the tests it |
| 42 | contains. The linker sorts the descriptors by their symbol name which is how |
| 43 | descriptors from the same suite are grouped together for easier parsing. |
| 44 | |
| 45 | The base VM image offers a command line interface, via the bootargs, to query |
| 46 | the tests in the image and to run specific tests. The driver script uses this |
| 47 | interface to execute tests, each with a fresh QEMU boot to give a fresh |
| 48 | environment. |