You can start the tests automatically or manually:
Automatically Running Tests:
To run the tests automatically after the
OpenEmbedded build system successfully creates an image,
first set the
TEST_IMAGE
variable to "1" in your local.conf
file in the
Build Directory:
TEST_IMAGE = "1"
Next, simply build your image. If the image successfully builds, the tests will be run:
bitbake core-image-sato
Manually Running Tests:
To manually run the tests, first globally inherit
testimage.class
by editing your local.conf
file:
INHERIT += "testimage"
Next, use BitBake to run the tests:
bitbake -c testimage <image>
Regardless of how you run the tests, once they start, the following happens:
A copy of the root filesystem is written
to ${WORKDIR}/testimage
.
The image is booted under QEMU using the
standard runqemu
script.
A default timeout of 500 seconds occurs
to allow for the boot process to reach the login prompt.
You can change the timeout period by setting
TEST_QEMUBOOT_TIMEOUT
in the local.conf
file.
Once the boot process is reached and the
login prompt appears, the tests run.
The full boot log is written to
${WORKDIR}/testimage/qemu_boot_log
.
Each test module loads in the order found
in TEST_SUITES
.
You can find the full output of the commands run over
ssh
in
${WORKDIR}/testimgage/ssh_target_log
.
If no failures occur, the task running the
tests ends successfully.
You can find the output from the
unittest
in the task log at
${WORKDIR}/temp/log.do_testimage
.
All test files reside in
meta/lib/oeqa/runtime
in the
Source Directory.
A test name maps directly to a Python module.
Each test module may contain a number of individual tests.
Tests are usually grouped together by the area
tested (e.g tests for systemd
reside in
meta/lib/oeqa/runtime/systemd.py
).
You can add tests to any layer provided you place them in the
proper area and you extend
BBPATH
in the local.conf
file as normal.
Be sure that tests reside in
<layer>/lib/oeqa/runtime
.
meta/lib/oeqa/runtime
.
You can change the set of tests run by appending or overriding
TEST_SUITES
variable in local.conf
.
Each name in TEST_SUITES
represents a
required test for the image.
Test modules named within TEST_SUITES
cannot be skipped even if a test is not suitable for an image
(e.g. running the rpm tests on an image without
rpm
).
Appending "auto" to TEST_SUITES
causes the
build system to try to run all tests that are suitable for the
image (i.e. each test module may elect to skip itself).
The order you list tests in TEST_SUITES
is important.
The order influences test dependencies.
Consequently, tests that depend on other tests should be added
after the test on which they depend.
For example, since ssh
depends on the
ping
test, ssh
needs to come after ping
in the list.
The test class provides no re-ordering or dependency handling.
unittest
rules apply.
Here are some things to keep in mind when running tests:
The default tests for the image are defined as:
DEFAULT_TEST_SUITES_pn-<image> = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg"
Add your own test to the list of the by using the following:
TEST_SUITES_append = " mytest"
Run a specific list of tests as follows:
TEST_SUITES = "test1 test2 test3"
Remember, order is important. Be sure to place a test that is dependent on another test later in the order.