dev-manual: Completed first draft of the new Ptest section.

(From yocto-docs rev: 90fbbc2eb6bc6292432060fbd3e806b809f70148)

Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Scott Rifenbark 2013-04-11 17:34:24 -07:00 committed by Richard Purdie
parent b52a9cba0a
commit af06402571
1 changed files with 47 additions and 26 deletions

View File

@ -3476,11 +3476,32 @@
</para> </para>
</section> </section>
<section id='setting-up-and-running-package-test-ptest'> <section id='testing-packages-with-ptest'>
<title>Setting Up and Running Package Test (Ptest)</title> <title>Testing Packages with Ptest</title>
<para> <para>
Intro shit A Packate Test (Ptest) runs tests against packages built
by the OpenEmbedded build system.
Minimaly, a Ptest contains two things: a shell script that
starts the test, and the actual test.
The shell that starts the test must not contain
the actual test, the script only starts it.
On the other hand, the test can be anything from a simple
schell script that runs a binary and checks the output to
an elaborate system of test binaries and data files.
</para>
<para>
The test formats the output into the single, common
format used by Automake:
<literallayout class='monospaced'>
&lt;result&gt;: &lt;testname&gr;
</literallayout>
The <filename>&lt;result&gt;</filename> can be
<filename>PASS</filename>, <filename>FAIL</filename>, or
<filename>SKIP</filename>.
The <filename>&lt;testname&gt;</filename> can be any
identifying string.
</para> </para>
<section id='getting-your-package-ready'> <section id='getting-your-package-ready'>
@ -3488,13 +3509,13 @@
<para> <para>
In order to run installed Ptests on target hardware, In order to run installed Ptests on target hardware,
you need to prepare each recipe so that it can run you need to prepare the recipes that build the packages
its test. you want to test.
Here is what you have to do: Here is what you have to do for each recipe:
<itemizedlist> <itemizedlist>
<listitem><para><emphasis>Be sure the package recipe <listitem><para><emphasis>Be sure the package recipe
inherits Ptest:</emphasis> inherits Ptest:</emphasis>
Include the following line in your recipe: Include the following line in your recipes:
<literallayout class='monospaced'> <literallayout class='monospaced'>
inherit ptest inherit ptest
</literallayout> </literallayout>
@ -3506,8 +3527,9 @@
(such as requiring "make" to run the test suite), (such as requiring "make" to run the test suite),
use the use the
<ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
variable in your package to meet the dependency. variable in your recipe so the package meets the
Here is an example where the recipe has a build dependency.
Here is an example where the package has a build
dependency on "make": dependency on "make":
<literallayout class='monospaced'> <literallayout class='monospaced'>
RDEPENDS_${PN}-ptest += "make" RDEPENDS_${PN}-ptest += "make"
@ -3517,8 +3539,8 @@
test suite:</emphasis> test suite:</emphasis>
Few packages support cross-compiling their test Few packages support cross-compiling their test
suites. suites.
Consequently, you usually need to add a function Consequently, you usually need to add that function.
to do that.</para> </para>
<para>Many packages based on Automake compile and <para>Many packages based on Automake compile and
run the test suite by using a single command run the test suite by using a single command
such as <filename>make check</filename>. such as <filename>make check</filename>.
@ -3528,11 +3550,11 @@
Thus, compilation needs to occur separately on Thus, compilation needs to occur separately on
the host. the host.
The built version of Automake that ships with The built version of Automake that ships with
the Yocto Project does this automatically through the Yocto Project separates these actions
a patch. automatically through a patch.
Consequently, packages that use Consequently, packages that use
<filename>make check</filename> automatically <filename>make check</filename> automatically
are deal with the cross-compile situation.</para> cross-compile.</para>
<para>However, you still must add a <para>However, you still must add a
<filename>do_compile_ptest</filename> function to <filename>do_compile_ptest</filename> function to
build the test suite. build the test suite.
@ -3546,8 +3568,8 @@
</para></listitem> </para></listitem>
<listitem><para><emphasis>Ensure special configurations <listitem><para><emphasis>Ensure special configurations
are set:</emphasis> are set:</emphasis>
If the package requires special configuration If the package requires special configurations
actions prior to compiling the test code, you must prior to compiling the test code, you must
insert a <filename>do_configure_ptest</filename> insert a <filename>do_configure_ptest</filename>
function into the recipe. function into the recipe.
</para></listitem> </para></listitem>
@ -3555,13 +3577,12 @@
suite:</emphasis> suite:</emphasis>
The <filename>ptest.bbclass</filename> class The <filename>ptest.bbclass</filename> class
automatically copies the required files that both automatically copies the required files that both
"make" and run the tests assuming there is a "make" (assuming there is a make target in the
make target in the top-level top-level <filename>Makefile</filename>) and run
<filename>Makefile</filename>. the tests.
If this is not the case, you need to create a If this is not the case, you need to create a
<filename>do_install_ptest</filename> in the <filename>do_install_ptest</filename> that gets
package recipe that is called after the called after the "make install-ptest" completes.
"make install-ptest" has completed.
</para></listitem> </para></listitem>
</itemizedlist> </itemizedlist>
</para> </para>
@ -3571,8 +3592,8 @@
<title>Adding Ptest to Your Build</title> <title>Adding Ptest to Your Build</title>
<para> <para>
To add Ptest to your build, add the following To add package testing to your build, add the following
into your <filename>local.conf</filename> file, two statements to your <filename>local.conf</filename> file,
which is found in the which is found in the
<link linkend='build-directory'>Build Directory</link>: <link linkend='build-directory'>Build Directory</link>:
<literallayout class='monospaced'> <literallayout class='monospaced'>
@ -3581,8 +3602,8 @@
</literallayout> </literallayout>
Once your build is complete, the Ptest files are installed Once your build is complete, the Ptest files are installed
into the <filename>/usr/lib/&lt;package&gt;/ptest</filename> into the <filename>/usr/lib/&lt;package&gt;/ptest</filename>
directory, where &lt;package&gt; is the name of the directory, where <filename>&lt;package&gt;</filename>
package. is the name of the package.
</para> </para>
</section> </section>