In order to enable a recipe to run installed ptests on target hardware, you need to prepare the recipes that build the packages you want to test. Here is what you have to do for each recipe:
Be sure the recipe
inherits the
ptest
class:
Include the following line in each recipe:
inherit ptest
Create run-ptest
:
This script starts your test.
Locate the script where you will refer to it
using
SRC_URI
.
Here is an example that starts a test for
dbus
:
#!/bin/sh cd test make -k runtest-TESTS
Ensure dependencies are
met:
If the test adds build or runtime dependencies
that normally do not exist for the package
(such as requiring "make" to run the test suite),
use the
DEPENDS
and
RDEPENDS
variables in your recipe in order for the package
to meet the dependencies.
Here is an example where the package has a runtime
dependency on "make":
RDEPENDS_${PN}-ptest += "make"
Add a function to build the test suite: Not many packages support cross-compilation of their test suites. Consequently, you usually need to add a cross-compilation function to the package.
Many packages based on Automake compile and
run the test suite by using a single command
such as make check
.
However, the host make check
builds and runs on the same computer, while
cross-compiling requires that the package is built
on the host but executed for the target
architecture (though often, as in the case for
ptest, the execution occurs on the host).
The built version of Automake that ships with the
Yocto Project includes a patch that separates
building and execution.
Consequently, packages that use the unaltered,
patched version of make check
automatically cross-compiles.
Regardless, you still must add a
do_compile_ptest
function to
build the test suite.
Add a function similar to the following to your
recipe:
do_compile_ptest() { oe_runmake buildtest-TESTS }
Ensure special configurations
are set:
If the package requires special configurations
prior to compiling the test code, you must
insert a do_configure_ptest
function into the recipe.
Install the test
suite:
The ptest
class
automatically copies the file
run-ptest
to the target and
then runs make install-ptest
to run the tests.
If this is not enough, you need to create a
do_install_ptest
function and
make sure it gets called after the
"make install-ptest" completes.