Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 1 | SUMMARY:${PN}-ptest ?= "${SUMMARY} - Package test files" |
| 2 | DESCRIPTION:${PN}-ptest ?= "${DESCRIPTION} \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | This package contains a test directory ${PTEST_PATH} for package test purposes." |
| 4 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | PTEST_PATH ?= "${libdir}/${BPN}/ptest" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 6 | PTEST_BUILD_HOST_FILES ?= "Makefile" |
| 7 | PTEST_BUILD_HOST_PATTERN ?= "" |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 8 | PTEST_PARALLEL_MAKE ?= "${PARALLEL_MAKE}" |
| 9 | PTEST_PARALLEL_MAKEINST ?= "${PARALLEL_MAKEINST}" |
| 10 | EXTRA_OEMAKE:prepend:task-compile-ptest-base = "${PTEST_PARALLEL_MAKE} " |
| 11 | EXTRA_OEMAKE:prepend:task-install-ptest-base = "${PTEST_PARALLEL_MAKEINST} " |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 12 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 13 | FILES:${PN}-ptest += "${PTEST_PATH}" |
| 14 | SECTION:${PN}-ptest = "devel" |
| 15 | ALLOW_EMPTY:${PN}-ptest = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | PTEST_ENABLED = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '1', '0', d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 17 | PTEST_ENABLED:class-native = "" |
| 18 | PTEST_ENABLED:class-nativesdk = "" |
| 19 | PTEST_ENABLED:class-cross-canadian = "" |
| 20 | RDEPENDS:${PN}-ptest += "${PN}" |
| 21 | RDEPENDS:${PN}-ptest:class-native = "" |
| 22 | RDEPENDS:${PN}-ptest:class-nativesdk = "" |
| 23 | RRECOMMENDS:${PN}-ptest += "ptest-runner" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | |
| 25 | PACKAGES =+ "${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)}" |
| 26 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 27 | require conf/distro/include/ptest-packagelists.inc |
| 28 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | do_configure_ptest() { |
| 30 | : |
| 31 | } |
| 32 | |
| 33 | do_configure_ptest_base() { |
| 34 | do_configure_ptest |
| 35 | } |
| 36 | |
| 37 | do_compile_ptest() { |
| 38 | : |
| 39 | } |
| 40 | |
| 41 | do_compile_ptest_base() { |
| 42 | do_compile_ptest |
| 43 | } |
| 44 | |
| 45 | do_install_ptest() { |
| 46 | : |
| 47 | } |
| 48 | |
| 49 | do_install_ptest_base() { |
| 50 | if [ -f ${WORKDIR}/run-ptest ]; then |
| 51 | install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | fi |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 53 | if grep -q install-ptest: Makefile; then |
| 54 | oe_runmake DESTDIR=${D}${PTEST_PATH} install-ptest |
| 55 | fi |
| 56 | do_install_ptest |
| 57 | chown -R root:root ${D}${PTEST_PATH} |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | |
| 59 | # Strip build host paths from any installed Makefile |
| 60 | for filename in ${PTEST_BUILD_HOST_FILES}; do |
| 61 | for installed_ptest_file in $(find ${D}${PTEST_PATH} -type f -name $filename); do |
| 62 | bbnote "Stripping host paths from: $installed_ptest_file" |
| 63 | sed -e 's#${HOSTTOOLS_DIR}/*##g' \ |
| 64 | -e 's#${WORKDIR}/*=#.=#g' \ |
| 65 | -e 's#${WORKDIR}/*##g' \ |
| 66 | -i $installed_ptest_file |
| 67 | if [ -n "${PTEST_BUILD_HOST_PATTERN}" ]; then |
| 68 | sed -E '/${PTEST_BUILD_HOST_PATTERN}/d' \ |
| 69 | -i $installed_ptest_file |
| 70 | fi |
| 71 | done |
| 72 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | } |
| 74 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 75 | PTEST_BINDIR_PKGD_PATH = "${PKGD}${PTEST_PATH}/bin" |
| 76 | |
| 77 | # This function needs to run after apply_update_alternative_renames because the |
| 78 | # aforementioned function will update the ALTERNATIVE_LINK_NAME flag. Append is |
| 79 | # used here to make this function to run as late as possible. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 80 | PACKAGE_PREPROCESS_FUNCS:append = "${@bb.utils.contains('PTEST_BINDIR', '1', \ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 81 | bb.utils.contains('PTEST_ENABLED', '1', ' ptest_update_alternatives', '', d), '', d)}" |
| 82 | |
| 83 | python ptest_update_alternatives() { |
| 84 | """ |
| 85 | This function will generate the symlinks in the PTEST_BINDIR_PKGD_PATH |
| 86 | to match the renamed binaries by update-alternatives. |
| 87 | """ |
| 88 | |
| 89 | if not bb.data.inherits_class('update-alternatives', d) \ |
| 90 | or not update_alternatives_enabled(d): |
| 91 | return |
| 92 | |
| 93 | bb.note("Generating symlinks for ptest") |
| 94 | bin_paths = { d.getVar("bindir"), d.getVar("base_bindir"), |
| 95 | d.getVar("sbindir"), d.getVar("base_sbindir") } |
| 96 | ptest_bindir = d.getVar("PTEST_BINDIR_PKGD_PATH") |
| 97 | os.mkdir(ptest_bindir) |
| 98 | for pkg in (d.getVar('PACKAGES') or "").split(): |
| 99 | alternatives = update_alternatives_alt_targets(d, pkg) |
| 100 | for alt_name, alt_link, alt_target, _ in alternatives: |
| 101 | # Some alternatives are for man pages, |
| 102 | # check if the alternative is in PATH |
| 103 | if os.path.dirname(alt_link) in bin_paths: |
| 104 | os.symlink(alt_target, os.path.join(ptest_bindir, alt_name)) |
| 105 | } |
| 106 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | do_configure_ptest_base[dirs] = "${B}" |
| 108 | do_compile_ptest_base[dirs] = "${B}" |
| 109 | do_install_ptest_base[dirs] = "${B}" |
| 110 | do_install_ptest_base[cleandirs] = "${D}${PTEST_PATH}" |
| 111 | |
| 112 | addtask configure_ptest_base after do_configure before do_compile |
| 113 | addtask compile_ptest_base after do_compile before do_install |
| 114 | addtask install_ptest_base after do_install before do_package do_populate_sysroot |
| 115 | |
| 116 | python () { |
| 117 | if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 118 | d.setVarFlag('do_install_ptest_base', 'fakeroot', '1') |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 119 | d.setVarFlag('do_install_ptest_base', 'umask', '022') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | |
| 121 | # Remove all '*ptest_base' tasks when ptest is not enabled |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 122 | if not(d.getVar('PTEST_ENABLED') == "1"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | for i in ['do_configure_ptest_base', 'do_compile_ptest_base', 'do_install_ptest_base']: |
| 124 | bb.build.deltask(i, d) |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 125 | } |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 126 | |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 127 | QARECIPETEST[missing-ptest] = "package_qa_check_missing_ptest" |
| 128 | def package_qa_check_missing_ptest(pn, d, messages): |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 129 | # This checks that ptest package is actually included |
| 130 | # in standard oe-core ptest images - only for oe-core recipes |
| 131 | if not 'meta/recipes' in d.getVar('FILE') or not(d.getVar('PTEST_ENABLED') == "1"): |
| 132 | return |
| 133 | |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 134 | enabled_ptests = " ".join([d.getVar('PTESTS_FAST'), d.getVar('PTESTS_SLOW'), d.getVar('PTESTS_PROBLEMS')]).split() |
| 135 | if (pn + "-ptest").replace(d.getVar('MLPREFIX'), '') not in enabled_ptests: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 136 | oe.qa.handle_error("missing-ptest", "supports ptests but is not included in oe-core's ptest-packagelists.inc", d) |