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