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