diff options
| author | Antonin Godard <antonin.godard@bootlin.com> | 2024-12-26 16:20:16 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-01-09 13:58:17 +0000 |
| commit | d720994f023f9c0bf23d6234089b21e23d837dc5 (patch) | |
| tree | f556cf36bc93f8036d60ab50d331d0810512dba8 /documentation/test-manual | |
| parent | b301c74baf33caee0ee8560fb019034ea6c9856f (diff) | |
| download | poky-d720994f023f9c0bf23d6234089b21e23d837dc5.tar.gz | |
ref-manual/packages: move ptest section to the test-manual
[ YOCTO #15106 ]
It makes more sense to document ptests in the test-manual. Since ptests
are still related to packages, keep a link to ptests from packages.rst
to the test-manual.
Reported-by: Yoann Congal <yoann.congal@smile.fr>
(From yocto-docs rev: b389c06b709e4791e1cce5e8a5b58f6b0cd03a14)
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/test-manual')
| -rw-r--r-- | documentation/test-manual/index.rst | 1 | ||||
| -rw-r--r-- | documentation/test-manual/intro.rst | 2 | ||||
| -rw-r--r-- | documentation/test-manual/ptest.rst | 114 |
3 files changed, 116 insertions, 1 deletions
diff --git a/documentation/test-manual/index.rst b/documentation/test-manual/index.rst index 86a2f436ea..ad71f37910 100644 --- a/documentation/test-manual/index.rst +++ b/documentation/test-manual/index.rst | |||
| @@ -12,6 +12,7 @@ Yocto Project Test Environment Manual | |||
| 12 | 12 | ||
| 13 | intro | 13 | intro |
| 14 | test-process | 14 | test-process |
| 15 | ptest | ||
| 15 | understand-autobuilder | 16 | understand-autobuilder |
| 16 | reproducible-builds | 17 | reproducible-builds |
| 17 | yocto-project-compatible | 18 | yocto-project-compatible |
diff --git a/documentation/test-manual/intro.rst b/documentation/test-manual/intro.rst index 882ca16486..252d3ea731 100644 --- a/documentation/test-manual/intro.rst +++ b/documentation/test-manual/intro.rst | |||
| @@ -140,7 +140,7 @@ the following types of tests: | |||
| 140 | - *Package Testing:* A Package Test (ptest) runs tests against packages | 140 | - *Package Testing:* A Package Test (ptest) runs tests against packages |
| 141 | built by the OpenEmbedded build system on the target machine. See the | 141 | built by the OpenEmbedded build system on the target machine. See the |
| 142 | :ref:`Testing Packages With | 142 | :ref:`Testing Packages With |
| 143 | ptest <dev-manual/packages:Testing Packages With ptest>` section | 143 | ptest <test-manual/ptest:Testing Packages With ptest>` section |
| 144 | in the Yocto Project Development Tasks Manual and the | 144 | in the Yocto Project Development Tasks Manual and the |
| 145 | ":yocto_wiki:`Ptest </Ptest>`" Wiki page for more | 145 | ":yocto_wiki:`Ptest </Ptest>`" Wiki page for more |
| 146 | information on Ptest. | 146 | information on Ptest. |
diff --git a/documentation/test-manual/ptest.rst b/documentation/test-manual/ptest.rst new file mode 100644 index 0000000000..dea1bad23b --- /dev/null +++ b/documentation/test-manual/ptest.rst | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | *************************** | ||
| 4 | Testing Packages With ptest | ||
| 5 | *************************** | ||
| 6 | |||
| 7 | A Package Test (ptest) runs tests against packages built by the | ||
| 8 | OpenEmbedded build system on the target machine. A ptest contains at | ||
| 9 | least two items: the actual test, and a shell script (``run-ptest``) | ||
| 10 | that starts the test. The shell script that starts the test must not | ||
| 11 | contain the actual test --- the script only starts the test. On the other | ||
| 12 | hand, the test can be anything from a simple shell script that runs a | ||
| 13 | binary and checks the output to an elaborate system of test binaries and | ||
| 14 | data files. | ||
| 15 | |||
| 16 | The test generates output in the format used by Automake:: | ||
| 17 | |||
| 18 | result: testname | ||
| 19 | |||
| 20 | where the result can be ``PASS``, ``FAIL``, or ``SKIP``, and | ||
| 21 | the testname can be any identifying string. | ||
| 22 | |||
| 23 | For a list of Yocto Project recipes that are already enabled with ptest, | ||
| 24 | see the :yocto_wiki:`Ptest </Ptest>` wiki page. | ||
| 25 | |||
| 26 | .. note:: | ||
| 27 | |||
| 28 | A recipe is "ptest-enabled" if it inherits the :ref:`ref-classes-ptest` | ||
| 29 | class. | ||
| 30 | |||
| 31 | Adding ptest to Your Build | ||
| 32 | ========================== | ||
| 33 | |||
| 34 | To add package testing to your build, add the :term:`DISTRO_FEATURES` and | ||
| 35 | :term:`EXTRA_IMAGE_FEATURES` variables to your ``local.conf`` file, which | ||
| 36 | is found in the :term:`Build Directory`:: | ||
| 37 | |||
| 38 | DISTRO_FEATURES:append = " ptest" | ||
| 39 | EXTRA_IMAGE_FEATURES += "ptest-pkgs" | ||
| 40 | |||
| 41 | Once your build is complete, the ptest files are installed into the | ||
| 42 | ``/usr/lib/package/ptest`` directory within the image, where ``package`` | ||
| 43 | is the name of the package. | ||
| 44 | |||
| 45 | Running ptest | ||
| 46 | ============= | ||
| 47 | |||
| 48 | The ``ptest-runner`` package installs a shell script that loops through | ||
| 49 | all installed ptest test suites and runs them in sequence. Consequently, | ||
| 50 | you might want to add this package to your image. | ||
| 51 | |||
| 52 | Getting Your Package Ready | ||
| 53 | ========================== | ||
| 54 | |||
| 55 | In order to enable a recipe to run installed ptests on target hardware, | ||
| 56 | you need to prepare the recipes that build the packages you want to | ||
| 57 | test. Here is what you have to do for each recipe: | ||
| 58 | |||
| 59 | - *Be sure the recipe inherits the* :ref:`ref-classes-ptest` *class:* | ||
| 60 | Include the following line in each recipe:: | ||
| 61 | |||
| 62 | inherit ptest | ||
| 63 | |||
| 64 | - *Create run-ptest:* This script starts your test. Locate the | ||
| 65 | script where you will refer to it using | ||
| 66 | :term:`SRC_URI`. Here is an | ||
| 67 | example that starts a test for ``dbus``:: | ||
| 68 | |||
| 69 | #!/bin/sh | ||
| 70 | cd test | ||
| 71 | make -k runtest-TESTS | ||
| 72 | |||
| 73 | - *Ensure dependencies are met:* If the test adds build or runtime | ||
| 74 | dependencies that normally do not exist for the package (such as | ||
| 75 | requiring "make" to run the test suite), use the | ||
| 76 | :term:`DEPENDS` and | ||
| 77 | :term:`RDEPENDS` variables in | ||
| 78 | your recipe in order for the package to meet the dependencies. Here | ||
| 79 | is an example where the package has a runtime dependency on "make":: | ||
| 80 | |||
| 81 | RDEPENDS:${PN}-ptest += "make" | ||
| 82 | |||
| 83 | - *Add a function to build the test suite:* Not many packages support | ||
| 84 | cross-compilation of their test suites. Consequently, you usually | ||
| 85 | need to add a cross-compilation function to the package. | ||
| 86 | |||
| 87 | Many packages based on Automake compile and run the test suite by | ||
| 88 | using a single command such as ``make check``. However, the host | ||
| 89 | ``make check`` builds and runs on the same computer, while | ||
| 90 | cross-compiling requires that the package is built on the host but | ||
| 91 | executed for the target architecture (though often, as in the case | ||
| 92 | for ptest, the execution occurs on the host). The built version of | ||
| 93 | Automake that ships with the Yocto Project includes a patch that | ||
| 94 | separates building and execution. Consequently, packages that use the | ||
| 95 | unaltered, patched version of ``make check`` automatically | ||
| 96 | cross-compiles. | ||
| 97 | |||
| 98 | Regardless, you still must add a ``do_compile_ptest`` function to | ||
| 99 | build the test suite. Add a function similar to the following to your | ||
| 100 | recipe:: | ||
| 101 | |||
| 102 | do_compile_ptest() { | ||
| 103 | oe_runmake buildtest-TESTS | ||
| 104 | } | ||
| 105 | |||
| 106 | - *Ensure special configurations are set:* If the package requires | ||
| 107 | special configurations prior to compiling the test code, you must | ||
| 108 | insert a ``do_configure_ptest`` function into the recipe. | ||
| 109 | |||
| 110 | - *Install the test suite:* The :ref:`ref-classes-ptest` class | ||
| 111 | automatically copies the file ``run-ptest`` to the target and then runs make | ||
| 112 | ``install-ptest`` to run the tests. If this is not enough, you need | ||
| 113 | to create a ``do_install_ptest`` function and make sure it gets | ||
| 114 | called after the "make install-ptest" completes. | ||
