Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY_${PN}-ptest ?= "${SUMMARY} - Package test files" |
| 2 | DESCRIPTION_${PN}-ptest ?= "${DESCRIPTION} \ |
| 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 ?= "" |
| 8 | |
Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 9 | FILES_${PN}-ptest += "${PTEST_PATH}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | SECTION_${PN}-ptest = "devel" |
| 11 | ALLOW_EMPTY_${PN}-ptest = "1" |
| 12 | PTEST_ENABLED = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '1', '0', d)}" |
| 13 | PTEST_ENABLED_class-native = "" |
| 14 | PTEST_ENABLED_class-nativesdk = "" |
| 15 | PTEST_ENABLED_class-cross-canadian = "" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 16 | RDEPENDS_${PN}-ptest += "${PN}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | RDEPENDS_${PN}-ptest_class-native = "" |
| 18 | RDEPENDS_${PN}-ptest_class-nativesdk = "" |
| 19 | RRECOMMENDS_${PN}-ptest += "ptest-runner" |
| 20 | |
| 21 | PACKAGES =+ "${@bb.utils.contains('PTEST_ENABLED', '1', '${PN}-ptest', '', d)}" |
| 22 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame^] | 23 | require conf/distro/include/ptest-packagelists.inc |
| 24 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | do_configure_ptest() { |
| 26 | : |
| 27 | } |
| 28 | |
| 29 | do_configure_ptest_base() { |
| 30 | do_configure_ptest |
| 31 | } |
| 32 | |
| 33 | do_compile_ptest() { |
| 34 | : |
| 35 | } |
| 36 | |
| 37 | do_compile_ptest_base() { |
| 38 | do_compile_ptest |
| 39 | } |
| 40 | |
| 41 | do_install_ptest() { |
| 42 | : |
| 43 | } |
| 44 | |
| 45 | do_install_ptest_base() { |
| 46 | if [ -f ${WORKDIR}/run-ptest ]; then |
| 47 | install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | fi |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 49 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 54 | |
| 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | } |
| 70 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 71 | PTEST_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. |
| 76 | PACKAGE_PREPROCESS_FUNCS_append = "${@bb.utils.contains('PTEST_BINDIR', '1', \ |
| 77 | bb.utils.contains('PTEST_ENABLED', '1', ' ptest_update_alternatives', '', d), '', d)}" |
| 78 | |
| 79 | python 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | do_configure_ptest_base[dirs] = "${B}" |
| 104 | do_compile_ptest_base[dirs] = "${B}" |
| 105 | do_install_ptest_base[dirs] = "${B}" |
| 106 | do_install_ptest_base[cleandirs] = "${D}${PTEST_PATH}" |
| 107 | |
| 108 | addtask configure_ptest_base after do_configure before do_compile |
| 109 | addtask compile_ptest_base after do_compile before do_install |
| 110 | addtask install_ptest_base after do_install before do_package do_populate_sysroot |
| 111 | |
| 112 | python () { |
| 113 | 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] | 114 | d.setVarFlag('do_install_ptest_base', 'fakeroot', '1') |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 115 | d.setVarFlag('do_install_ptest_base', 'umask', '022') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | |
| 117 | # Remove all '*ptest_base' tasks when ptest is not enabled |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 118 | if not(d.getVar('PTEST_ENABLED') == "1"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | for i in ['do_configure_ptest_base', 'do_compile_ptest_base', 'do_install_ptest_base']: |
| 120 | bb.build.deltask(i, d) |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame^] | 121 | |
| 122 | # This checks that ptest package is actually included |
| 123 | # in standard oe-core ptest images - only for oe-core recipes |
| 124 | if not 'meta/recipes' in d.getVar('FILE') or not(d.getVar('PTEST_ENABLED') == "1"): |
| 125 | return |
| 126 | |
| 127 | enabled_ptests = " ".join([d.getVar('PTESTS_FAST'),d.getVar('PTESTS_SLOW'), d.getVar('PTESTS_PROBLEMS')]).split() |
| 128 | if (d.getVar('PN') + "-ptest").replace(d.getVar('MLPREFIX'), '') not in enabled_ptests: |
| 129 | bb.error("Recipe %s supports ptests but is not included in oe-core's conf/distro/include/ptest-packagelists.inc" % d.getVar("PN")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 130 | } |