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 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | FILES_${PN}-ptest = "${PTEST_PATH}" |
| 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 | |
| 23 | do_configure_ptest() { |
| 24 | : |
| 25 | } |
| 26 | |
| 27 | do_configure_ptest_base() { |
| 28 | do_configure_ptest |
| 29 | } |
| 30 | |
| 31 | do_compile_ptest() { |
| 32 | : |
| 33 | } |
| 34 | |
| 35 | do_compile_ptest_base() { |
| 36 | do_compile_ptest |
| 37 | } |
| 38 | |
| 39 | do_install_ptest() { |
| 40 | : |
| 41 | } |
| 42 | |
| 43 | do_install_ptest_base() { |
| 44 | if [ -f ${WORKDIR}/run-ptest ]; then |
| 45 | install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | fi |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 47 | if grep -q install-ptest: Makefile; then |
| 48 | oe_runmake DESTDIR=${D}${PTEST_PATH} install-ptest |
| 49 | fi |
| 50 | do_install_ptest |
| 51 | chown -R root:root ${D}${PTEST_PATH} |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 52 | |
| 53 | # Strip build host paths from any installed Makefile |
| 54 | for filename in ${PTEST_BUILD_HOST_FILES}; do |
| 55 | for installed_ptest_file in $(find ${D}${PTEST_PATH} -type f -name $filename); do |
| 56 | bbnote "Stripping host paths from: $installed_ptest_file" |
| 57 | sed -e 's#${HOSTTOOLS_DIR}/*##g' \ |
| 58 | -e 's#${WORKDIR}/*=#.=#g' \ |
| 59 | -e 's#${WORKDIR}/*##g' \ |
| 60 | -i $installed_ptest_file |
| 61 | if [ -n "${PTEST_BUILD_HOST_PATTERN}" ]; then |
| 62 | sed -E '/${PTEST_BUILD_HOST_PATTERN}/d' \ |
| 63 | -i $installed_ptest_file |
| 64 | fi |
| 65 | done |
| 66 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 69 | PTEST_BINDIR_PKGD_PATH = "${PKGD}${PTEST_PATH}/bin" |
| 70 | |
| 71 | # This function needs to run after apply_update_alternative_renames because the |
| 72 | # aforementioned function will update the ALTERNATIVE_LINK_NAME flag. Append is |
| 73 | # used here to make this function to run as late as possible. |
| 74 | PACKAGE_PREPROCESS_FUNCS_append = "${@bb.utils.contains('PTEST_BINDIR', '1', \ |
| 75 | bb.utils.contains('PTEST_ENABLED', '1', ' ptest_update_alternatives', '', d), '', d)}" |
| 76 | |
| 77 | python ptest_update_alternatives() { |
| 78 | """ |
| 79 | This function will generate the symlinks in the PTEST_BINDIR_PKGD_PATH |
| 80 | to match the renamed binaries by update-alternatives. |
| 81 | """ |
| 82 | |
| 83 | if not bb.data.inherits_class('update-alternatives', d) \ |
| 84 | or not update_alternatives_enabled(d): |
| 85 | return |
| 86 | |
| 87 | bb.note("Generating symlinks for ptest") |
| 88 | bin_paths = { d.getVar("bindir"), d.getVar("base_bindir"), |
| 89 | d.getVar("sbindir"), d.getVar("base_sbindir") } |
| 90 | ptest_bindir = d.getVar("PTEST_BINDIR_PKGD_PATH") |
| 91 | os.mkdir(ptest_bindir) |
| 92 | for pkg in (d.getVar('PACKAGES') or "").split(): |
| 93 | alternatives = update_alternatives_alt_targets(d, pkg) |
| 94 | for alt_name, alt_link, alt_target, _ in alternatives: |
| 95 | # Some alternatives are for man pages, |
| 96 | # check if the alternative is in PATH |
| 97 | if os.path.dirname(alt_link) in bin_paths: |
| 98 | os.symlink(alt_target, os.path.join(ptest_bindir, alt_name)) |
| 99 | } |
| 100 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | do_configure_ptest_base[dirs] = "${B}" |
| 102 | do_compile_ptest_base[dirs] = "${B}" |
| 103 | do_install_ptest_base[dirs] = "${B}" |
| 104 | do_install_ptest_base[cleandirs] = "${D}${PTEST_PATH}" |
| 105 | |
| 106 | addtask configure_ptest_base after do_configure before do_compile |
| 107 | addtask compile_ptest_base after do_compile before do_install |
| 108 | addtask install_ptest_base after do_install before do_package do_populate_sysroot |
| 109 | |
| 110 | python () { |
| 111 | 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] | 112 | d.setVarFlag('do_install_ptest_base', 'fakeroot', '1') |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 113 | d.setVarFlag('do_install_ptest_base', 'umask', '022') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | |
| 115 | # Remove all '*ptest_base' tasks when ptest is not enabled |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 116 | if not(d.getVar('PTEST_ENABLED') == "1"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 117 | for i in ['do_configure_ptest_base', 'do_compile_ptest_base', 'do_install_ptest_base']: |
| 118 | bb.build.deltask(i, d) |
| 119 | } |