blob: 1ec23c0923d40710e3ec3866097962d23c406022 [file] [log] [blame]
Patrick Williams213cb262021-08-07 19:21:33 -05001SUMMARY:${PN}-ptest ?= "${SUMMARY} - Package test files"
2DESCRIPTION:${PN}-ptest ?= "${DESCRIPTION} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003This package contains a test directory ${PTEST_PATH} for package test purposes."
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005PTEST_PATH ?= "${libdir}/${BPN}/ptest"
Brad Bishop19323692019-04-05 15:28:33 -04006PTEST_BUILD_HOST_FILES ?= "Makefile"
7PTEST_BUILD_HOST_PATTERN ?= ""
8
Patrick Williams213cb262021-08-07 19:21:33 -05009FILES:${PN}-ptest += "${PTEST_PATH}"
10SECTION:${PN}-ptest = "devel"
11ALLOW_EMPTY:${PN}-ptest = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012PTEST_ENABLED = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '1', '0', d)}"
Patrick Williams213cb262021-08-07 19:21:33 -050013PTEST_ENABLED:class-native = ""
14PTEST_ENABLED:class-nativesdk = ""
15PTEST_ENABLED:class-cross-canadian = ""
16RDEPENDS:${PN}-ptest += "${PN}"
17RDEPENDS:${PN}-ptest:class-native = ""
18RDEPENDS:${PN}-ptest:class-nativesdk = ""
19RRECOMMENDS:${PN}-ptest += "ptest-runner"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020
21PACKAGES =+ "${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)}"
22
William A. Kennington IIIac69b482021-06-02 12:28:27 -070023require conf/distro/include/ptest-packagelists.inc
24
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025do_configure_ptest() {
26 :
27}
28
29do_configure_ptest_base() {
30 do_configure_ptest
31}
32
33do_compile_ptest() {
34 :
35}
36
37do_compile_ptest_base() {
38 do_compile_ptest
39}
40
41do_install_ptest() {
42 :
43}
44
45do_install_ptest_base() {
46 if [ -f ${WORKDIR}/run-ptest ]; then
47 install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 fi
Patrick Williamsf1e5d692016-03-30 15:21:19 -050049 if grep -q install-ptest: Makefile; then
50 oe_runmake DESTDIR=${D}${PTEST_PATH} install-ptest
51 fi
52 do_install_ptest
53 chown -R root:root ${D}${PTEST_PATH}
Brad Bishop19323692019-04-05 15:28:33 -040054
55 # Strip build host paths from any installed Makefile
56 for filename in ${PTEST_BUILD_HOST_FILES}; do
57 for installed_ptest_file in $(find ${D}${PTEST_PATH} -type f -name $filename); do
58 bbnote "Stripping host paths from: $installed_ptest_file"
59 sed -e 's#${HOSTTOOLS_DIR}/*##g' \
60 -e 's#${WORKDIR}/*=#.=#g' \
61 -e 's#${WORKDIR}/*##g' \
62 -i $installed_ptest_file
63 if [ -n "${PTEST_BUILD_HOST_PATTERN}" ]; then
64 sed -E '/${PTEST_BUILD_HOST_PATTERN}/d' \
65 -i $installed_ptest_file
66 fi
67 done
68 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069}
70
Brad Bishopc342db32019-05-15 21:57:59 -040071PTEST_BINDIR_PKGD_PATH = "${PKGD}${PTEST_PATH}/bin"
72
73# This function needs to run after apply_update_alternative_renames because the
74# aforementioned function will update the ALTERNATIVE_LINK_NAME flag. Append is
75# used here to make this function to run as late as possible.
Patrick Williams213cb262021-08-07 19:21:33 -050076PACKAGE_PREPROCESS_FUNCS:append = "${@bb.utils.contains('PTEST_BINDIR', '1', \
Brad Bishopc342db32019-05-15 21:57:59 -040077 bb.utils.contains('PTEST_ENABLED', '1', ' ptest_update_alternatives', '', d), '', d)}"
78
79python ptest_update_alternatives() {
80 """
81 This function will generate the symlinks in the PTEST_BINDIR_PKGD_PATH
82 to match the renamed binaries by update-alternatives.
83 """
84
85 if not bb.data.inherits_class('update-alternatives', d) \
86 or not update_alternatives_enabled(d):
87 return
88
89 bb.note("Generating symlinks for ptest")
90 bin_paths = { d.getVar("bindir"), d.getVar("base_bindir"),
91 d.getVar("sbindir"), d.getVar("base_sbindir") }
92 ptest_bindir = d.getVar("PTEST_BINDIR_PKGD_PATH")
93 os.mkdir(ptest_bindir)
94 for pkg in (d.getVar('PACKAGES') or "").split():
95 alternatives = update_alternatives_alt_targets(d, pkg)
96 for alt_name, alt_link, alt_target, _ in alternatives:
97 # Some alternatives are for man pages,
98 # check if the alternative is in PATH
99 if os.path.dirname(alt_link) in bin_paths:
100 os.symlink(alt_target, os.path.join(ptest_bindir, alt_name))
101}
102
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103do_configure_ptest_base[dirs] = "${B}"
104do_compile_ptest_base[dirs] = "${B}"
105do_install_ptest_base[dirs] = "${B}"
106do_install_ptest_base[cleandirs] = "${D}${PTEST_PATH}"
107
108addtask configure_ptest_base after do_configure before do_compile
109addtask compile_ptest_base after do_compile before do_install
110addtask install_ptest_base after do_install before do_package do_populate_sysroot
111
112python () {
113 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500114 d.setVarFlag('do_install_ptest_base', 'fakeroot', '1')
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300115 d.setVarFlag('do_install_ptest_base', 'umask', '022')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116
117 # Remove all '*ptest_base' tasks when ptest is not enabled
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500118 if not(d.getVar('PTEST_ENABLED') == "1"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119 for i in ['do_configure_ptest_base', 'do_compile_ptest_base', 'do_install_ptest_base']:
120 bb.build.deltask(i, d)
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500121}
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700122
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500123QARECIPETEST[missing-ptest] = "package_qa_check_missing_ptest"
124def package_qa_check_missing_ptest(pn, d, messages):
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700125 # This checks that ptest package is actually included
126 # in standard oe-core ptest images - only for oe-core recipes
127 if not 'meta/recipes' in d.getVar('FILE') or not(d.getVar('PTEST_ENABLED') == "1"):
128 return
129
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500130 enabled_ptests = " ".join([d.getVar('PTESTS_FAST'), d.getVar('PTESTS_SLOW'), d.getVar('PTESTS_PROBLEMS')]).split()
131 if (pn + "-ptest").replace(d.getVar('MLPREFIX'), '') not in enabled_ptests:
Andrew Geisslereff27472021-10-29 15:35:00 -0500132 oe.qa.handle_error("missing-ptest", "supports ptests but is not included in oe-core's ptest-packagelists.inc", d)