diff options
| author | Antonin Godard <antonin.godard@bootlin.com> | 2024-12-26 16:20:16 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-01-09 08:41:04 -0800 |
| commit | 2497f29afd1ff66964b84dc79a7cd1126bbc94fa (patch) | |
| tree | 494d2d1a6b358c3796d870e1e060a949addf37b9 /documentation/dev-manual | |
| parent | 1418534d2215890723c281f852b6a6fd08acdbcf (diff) | |
| download | poky-2497f29afd1ff66964b84dc79a7cd1126bbc94fa.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: 8b6ada020d595d86c7bbe78a27b7a6301715b039)
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
(cherry picked from commit b389c06b709e4791e1cce5e8a5b58f6b0cd03a14)
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'documentation/dev-manual')
| -rw-r--r-- | documentation/dev-manual/packages.rst | 112 |
1 files changed, 3 insertions, 109 deletions
diff --git a/documentation/dev-manual/packages.rst b/documentation/dev-manual/packages.rst index e5028fffdc..0c948cdaef 100644 --- a/documentation/dev-manual/packages.rst +++ b/documentation/dev-manual/packages.rst | |||
| @@ -16,7 +16,7 @@ This section describes a few tasks that involve packages: | |||
| 16 | - :ref:`dev-manual/packages:generating and using signed packages` | 16 | - :ref:`dev-manual/packages:generating and using signed packages` |
| 17 | 17 | ||
| 18 | - :ref:`Setting up and running package test | 18 | - :ref:`Setting up and running package test |
| 19 | (ptest) <dev-manual/packages:testing packages with ptest>` | 19 | (ptest) <test-manual/ptest:testing packages with ptest>` |
| 20 | 20 | ||
| 21 | - :ref:`dev-manual/packages:creating node package manager (npm) packages` | 21 | - :ref:`dev-manual/packages:creating node package manager (npm) packages` |
| 22 | 22 | ||
| @@ -887,114 +887,8 @@ related to signed package feeds are available: | |||
| 887 | Testing Packages With ptest | 887 | Testing Packages With ptest |
| 888 | =========================== | 888 | =========================== |
| 889 | 889 | ||
| 890 | A Package Test (ptest) runs tests against packages built by the | 890 | See the :ref:`test-manual/ptest:Testing Packages With ptest` section of the |
| 891 | OpenEmbedded build system on the target machine. A ptest contains at | 891 | Yocto Project Test Environment Manual. |
| 892 | least two items: the actual test, and a shell script (``run-ptest``) | ||
| 893 | that starts the test. The shell script that starts the test must not | ||
| 894 | contain the actual test --- the script only starts the test. On the other | ||
| 895 | hand, the test can be anything from a simple shell script that runs a | ||
| 896 | binary and checks the output to an elaborate system of test binaries and | ||
| 897 | data files. | ||
| 898 | |||
| 899 | The test generates output in the format used by Automake:: | ||
| 900 | |||
| 901 | result: testname | ||
| 902 | |||
| 903 | where the result can be ``PASS``, ``FAIL``, or ``SKIP``, and | ||
| 904 | the testname can be any identifying string. | ||
| 905 | |||
| 906 | For a list of Yocto Project recipes that are already enabled with ptest, | ||
| 907 | see the :yocto_wiki:`Ptest </Ptest>` wiki page. | ||
| 908 | |||
| 909 | .. note:: | ||
| 910 | |||
| 911 | A recipe is "ptest-enabled" if it inherits the :ref:`ref-classes-ptest` | ||
| 912 | class. | ||
| 913 | |||
| 914 | Adding ptest to Your Build | ||
| 915 | -------------------------- | ||
| 916 | |||
| 917 | To add package testing to your build, add the :term:`DISTRO_FEATURES` and | ||
| 918 | :term:`EXTRA_IMAGE_FEATURES` variables to your ``local.conf`` file, which | ||
| 919 | is found in the :term:`Build Directory`:: | ||
| 920 | |||
| 921 | DISTRO_FEATURES:append = " ptest" | ||
| 922 | EXTRA_IMAGE_FEATURES += "ptest-pkgs" | ||
| 923 | |||
| 924 | Once your build is complete, the ptest files are installed into the | ||
| 925 | ``/usr/lib/package/ptest`` directory within the image, where ``package`` | ||
| 926 | is the name of the package. | ||
| 927 | |||
| 928 | Running ptest | ||
| 929 | ------------- | ||
| 930 | |||
| 931 | The ``ptest-runner`` package installs a shell script that loops through | ||
| 932 | all installed ptest test suites and runs them in sequence. Consequently, | ||
| 933 | you might want to add this package to your image. | ||
| 934 | |||
| 935 | Getting Your Package Ready | ||
| 936 | -------------------------- | ||
| 937 | |||
| 938 | In order to enable a recipe to run installed ptests on target hardware, | ||
| 939 | you need to prepare the recipes that build the packages you want to | ||
| 940 | test. Here is what you have to do for each recipe: | ||
| 941 | |||
| 942 | - *Be sure the recipe inherits the* :ref:`ref-classes-ptest` *class:* | ||
| 943 | Include the following line in each recipe:: | ||
| 944 | |||
| 945 | inherit ptest | ||
| 946 | |||
| 947 | - *Create run-ptest:* This script starts your test. Locate the | ||
| 948 | script where you will refer to it using | ||
| 949 | :term:`SRC_URI`. Here is an | ||
| 950 | example that starts a test for ``dbus``:: | ||
| 951 | |||
| 952 | #!/bin/sh | ||
| 953 | cd test | ||
| 954 | make -k runtest-TESTS | ||
| 955 | |||
| 956 | - *Ensure dependencies are met:* If the test adds build or runtime | ||
| 957 | dependencies that normally do not exist for the package (such as | ||
| 958 | requiring "make" to run the test suite), use the | ||
| 959 | :term:`DEPENDS` and | ||
| 960 | :term:`RDEPENDS` variables in | ||
| 961 | your recipe in order for the package to meet the dependencies. Here | ||
| 962 | is an example where the package has a runtime dependency on "make":: | ||
| 963 | |||
| 964 | RDEPENDS:${PN}-ptest += "make" | ||
| 965 | |||
| 966 | - *Add a function to build the test suite:* Not many packages support | ||
| 967 | cross-compilation of their test suites. Consequently, you usually | ||
| 968 | need to add a cross-compilation function to the package. | ||
| 969 | |||
| 970 | Many packages based on Automake compile and run the test suite by | ||
| 971 | using a single command such as ``make check``. However, the host | ||
| 972 | ``make check`` builds and runs on the same computer, while | ||
| 973 | cross-compiling requires that the package is built on the host but | ||
| 974 | executed for the target architecture (though often, as in the case | ||
| 975 | for ptest, the execution occurs on the host). The built version of | ||
| 976 | Automake that ships with the Yocto Project includes a patch that | ||
| 977 | separates building and execution. Consequently, packages that use the | ||
| 978 | unaltered, patched version of ``make check`` automatically | ||
| 979 | cross-compiles. | ||
| 980 | |||
| 981 | Regardless, you still must add a ``do_compile_ptest`` function to | ||
| 982 | build the test suite. Add a function similar to the following to your | ||
| 983 | recipe:: | ||
| 984 | |||
| 985 | do_compile_ptest() { | ||
| 986 | oe_runmake buildtest-TESTS | ||
| 987 | } | ||
| 988 | |||
| 989 | - *Ensure special configurations are set:* If the package requires | ||
| 990 | special configurations prior to compiling the test code, you must | ||
| 991 | insert a ``do_configure_ptest`` function into the recipe. | ||
| 992 | |||
| 993 | - *Install the test suite:* The :ref:`ref-classes-ptest` class | ||
| 994 | automatically copies the file ``run-ptest`` to the target and then runs make | ||
| 995 | ``install-ptest`` to run the tests. If this is not enough, you need | ||
| 996 | to create a ``do_install_ptest`` function and make sure it gets | ||
| 997 | called after the "make install-ptest" completes. | ||
| 998 | 892 | ||
| 999 | Creating Node Package Manager (NPM) Packages | 893 | Creating Node Package Manager (NPM) Packages |
| 1000 | ============================================ | 894 | ============================================ |
