xref: /openbmc/openbmc/meta-arm/documentation/oeqa-fvp.md (revision 220dafdb7243da3683b8a972c80a3719c2d137ef)
1# OEQA on Arm FVPs
2
3OE-Core's [oeqa][OEQA] framework provides a method of performing runtime tests on machines using the `testimage` Yocto task. meta-arm has good support for writing test cases against [Arm FVPs][FVP], meaning the [runfvp][RUNFVP] boot configuration can be re-used.
4
5Tests can be configured to run automatically post-build by setting the variable `TESTIMAGE_AUTO="1"`, e.g. in your Kas file or local.conf.
6
7meta-arm provides the OEFVPTarget which must be set up in the machine configuration:
8```
9TEST_TARGET = "OEFVPTarget"
10TEST_SERVER_IP = "127.0.0.1"
11TEST_TARGET_IP = "127.0.0.1:2222"
12IMAGE_FEATURES:append = " ssh-server-dropbear"
13FVP_CONFIG[bp.virtio_net.hostbridge.userNetPorts] ?= "2222=22"
14FVP_CONSOLES[default] = "terminal_0"
15FVP_CONSOLES[tf-a] = "s_terminal_0"
16```
17
18The test target also generates a log file with the prefix 'fvp_log' in the image recipe's `${WORKDIR}/testimage` containing the FVP's stdout.
19
20OEFVPTarget supports two different test interfaces - SSH and pexpect.
21
22## SSH
23
24As in OEQA in OE-core, tests cases can run commands on the machine using SSH. It therefore requires that an SSH server is installed in the image.
25
26This uses the `run` method on the target, e.g:
27```
28(status, output) = self.target.run('uname -a')
29```
30which executes a single command on the target (using `ssh -c`) and returns the status code and the output. It is therefore useful for running tests in a Linux environment.
31
32For examples of test cases, see meta/lib/oeqa/runtime/cases in OE-Core. The majority of test cases depend on `ssh.SSHTest.test_ssh`, which first validates that the SSH connection is functioning.
33
34## pexpect
35
36To support firmware and baremetal testing, OEFVPTarget also allows test cases to make assertions against one or more consoles using the pexpect library.
37
38Internally, this test target launches a [Pexpect][PEXPECT] instance for each entry in FVP_CONSOLES which can be used with the provided alias. The whole Pexpect API is exposed on the target, where the alias is always passed as the first argument, e.g.:
39```
40self.target.expect('default', r'root@.*\:~#', timeout=30)
41self.assertNotIn(b'ERROR:', self.target.before('tf-a'))
42```
43
44For an example of a full test case, see meta-arm/lib/oeqa/runtime/cases/linuxboot.py This test case can be used to minimally verify that a machine boots to a Linux shell. The default timeout is 10 minutes, but this can be configured with the variable TEST_FVP_LINUX_BOOT_TIMEOUT, which expects a value in seconds.
45
46[OEQA]: https://docs.yoctoproject.org/test-manual/intro.html
47[FVP]: https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms
48[RUNFVP]: runfvp.md
49[PEXPECT]: https://pexpect.readthedocs.io/en/stable/overview.html
50