systemd: re-enable ptest support
PATCH 1/1 systemd: re-enable ptest support
ptest support for systemd was dropped in 2018 (commit 906230a73b3c) when the recipe switched to meson, as there was no easy way to install and run the test suite. Current systemd and meson resolve this: the meson 'install-tests' option installs the unit-test binaries and a run-unit-tests.py runner under ${prefix}/lib/systemd/tests, and run-unit-tests.py already emits PASS:/SKIP: results per test.
Enable install-tests, package the installed tree into systemd-ptest, and add a run-ptest wrapper that drives run-unit-tests.py. This provides ptest coverage for the systemd:test and libsystemd meson unit-test suites.
The test/units integration tests, which require a booted system, are out of scope here and can be addressed separately.
Verified on systemd 257.6: -Dinstall-tests=true installs 313 test-* unit-test binaries plus run-unit-tests.py; systemd-ptest packages cleanly. The recipe change parses without error against oe-core master (261.2).
[YOCTO #16386]
--- meta/recipes-core/systemd/systemd/run-ptest | 11 +++++++++++ meta/recipes-core/systemd/systemd_261.2.bb | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-core/systemd/systemd/run-ptest
meta/recipes-core/systemd/systemd/run-ptest new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +# Run systemd's installed meson unit tests in ptest format. +# systemd's -Dinstall-tests=true installs run-unit-tests.py plus the +# unit-tests/test-* binaries; run-unit-tests.py already emits PASS:/SKIP: lines. +set -u +here="$(cd "$(dirname "$0")" && pwd)" +for cand in "$here/run-unit-tests.py" "$here/tests/run-unit-tests.py" /usr/lib/systemd/tests/run-unit-tests.py; do + [ -f "$cand" ] && { python3 "$cand" 2>&1; exit 0; } +done +echo "FAIL: systemd-ptest (run-unit-tests.py not found)" +exit 1
meta/recipes-core/systemd/systemd_261.2.bb +17 -1
@@ -9,7 +9,7 @@ DEPENDS:append:libc-musl = " libucontext" SECTION = "base/shell" -inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives systemd gettext bash-completion manpages features_check mime +inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives systemd gettext bash-completion manpages features_check mime ptest # unmerged-usr support is deprecated upstream, taints the system and will be # removed in the near future. Fail the build if it is not enabled.
@@ -37,6 +37,7 @@ SRC_URI += " \ file://systemd-pager.sh \ file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ file://0003-Do-not-create-var-log-README.patch \ +file://run-ptest \ " PAM_PLUGINS = " \
@@ -937,3 +938,18 @@ python do_warn_musl() { bb.warn("Using systemd with musl is experimental, see https://github.com/systemd/systemd/blob/9ca4334/NEWS#L524 for details") } addtask warn_musl before do_configure + +# ptest support: systemd's meson 'install-tests' option installs the unit-test +# binaries and run-unit-tests.py under ${prefix}/lib/systemd/tests. Package them +# into systemd-ptest and drive them via run-ptest. [YOCTO #16386] +EXTRA_OEMESON:append = " -Dinstall-tests=true" + +do_install_ptest() { + install -d ${D}${PTEST_PATH} + if [ -d ${D}${prefix}/lib/systemd/tests ]; then + cp -r ${D}${prefix}/lib/systemd/tests/* ${D}${PTEST_PATH}/ + fi +} + +RDEPENDS:${PN}-ptest += "${PN} python3-core bash" +INSANE_SKIP:${PN}-ptest += "dev-deps debug-files"
Signature · 1 line
2.54.0
PATCH v2 1/1 systemd: re-enable ptest support
ptest support for systemd was dropped in 2018 (commit 906230a73b3c) when the recipe switched to meson, as there was no easy way to install and run the test suite. Current systemd and meson resolve this: the meson 'install-tests' option installs the unit-test binaries and a run-unit-tests.py runner under ${prefix}/lib/systemd/tests, and run-unit-tests.py already emits PASS:/SKIP: results per test.
Add a 'tests' PACKAGECONFIG gated on PTEST_ENABLED that sets -Dtests and -Dinstall-tests and pulls in python3-pefile-native (needed to build the boot hwids test). do_install_ptest relocates the installed tests into ${PTEST_PATH} and drops the mkosi/integration-tests harness (which needs a booted system). A run-ptest wrapper drives run-unit-tests.py, and systemd is registered in ptest-packagelists.inc.
The test/units integration tests, which require a booted system, are out of scope here and can be addressed separately.
Verified on oe-core master (261.2, qemux86-64): with ptest enabled, 342 unit-test binaries plus run-unit-tests.py install into ${PTEST_PATH} and systemd-ptest packages cleanly with no QA errors.
[YOCTO #16386]
---
v2:
- Gate tests via a PACKAGECONFIG on PTEST_ENABLED (Jose Quaresma).
- Drop the redundant copy; relocate installed tests into ${PTEST_PATH} (Jose Quaresma).
- Register systemd in ptest-packagelists.inc, fixing the missing-ptest QA error seen on the autobuilder (Khem Raj, Richard Purdie).
- Add python3-pefile-native dependency (fixes boot hwids test build failure).
- Exclude the mkosi/integration-test harness from the ptest package.
.../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/systemd/systemd/run-ptest | 11 ++++++++++ meta/recipes-core/systemd/systemd_261.2.bb | 21 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-core/systemd/systemd/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -146,6 +146,7 @@ PTESTS_SLOW = "\ python3-numpy \ python3-xmltodict \ strace \ + systemd \ tar \ tcl \ tcl8 \
meta/recipes-core/systemd/systemd/run-ptest new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh +# Run systemd's installed meson unit tests in ptest format. +# systemd's -Dinstall-tests=true installs run-unit-tests.py plus the +# unit-tests/test-* binaries; run-unit-tests.py already emits PASS:/SKIP: lines. +set -u +here="$(cd "$(dirname "$0")" && pwd)" +for cand in "$here/run-unit-tests.py" "$here/tests/run-unit-tests.py" /usr/lib/systemd/tests/run-unit-tests.py; do + [ -f "$cand" ] && { python3 "$cand" 2>&1; exit 0; } +done +echo "FAIL: systemd-ptest (run-unit-tests.py not found)" +exit 1
meta/recipes-core/systemd/systemd_261.2.bb +20 -1
@@ -9,7 +9,7 @@ DEPENDS:append:libc-musl = " libucontext" SECTION = "base/shell" -inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives systemd gettext bash-completion manpages features_check mime +inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives systemd gettext bash-completion manpages features_check mime ptest # unmerged-usr support is deprecated upstream, taints the system and will be # removed in the near future. Fail the build if it is not enabled.
@@ -37,6 +37,7 @@ SRC_URI += " \ file://systemd-pager.sh \ file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ file://0003-Do-not-create-var-log-README.patch \ +file://run-ptest \ " PAM_PLUGINS = " \
@@ -937,3 +938,21 @@ python do_warn_musl() { bb.warn("Using systemd with musl is experimental, see https://github.com/systemd/systemd/blob/9ca4334/NEWS#L524 for details") } addtask warn_musl before do_configure + +# ptest support. systemd's meson 'install-tests' option installs the unit-test +# binaries and run-unit-tests.py under ${prefix}/lib/systemd/tests. Gate it on +# ptest being enabled and package the installed tree. [YOCTO #16386] +PACKAGECONFIG[tests] = "-Dtests=unsafe -Dinstall-tests=true,-Dtests=false -Dinstall-tests=false,python3-pefile-native" +PACKAGECONFIG:append = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}" + +do_install_ptest() { + install -d ${D}${PTEST_PATH} + if [ -d ${D}${prefix}/lib/systemd/tests ]; then + mv ${D}${prefix}/lib/systemd/tests/* ${D}${PTEST_PATH}/ + rm -rf ${D}${prefix}/lib/systemd/tests + fi + rm -rf ${D}${PTEST_PATH}/mkosi ${D}${PTEST_PATH}/integration-tests +} + +RDEPENDS:${PN}-ptest += "python3-core bash" +INSANE_SKIP:${PN}-ptest += "dev-deps debug-files"
Signature · 1 line
2.54.0
Hi Himani,
Quoted 14 lines · Himani Ramesh Barde
ptest support for systemd was dropped in 2018 (commit
906230a73b3c) when the recipe switched to meson, as there was no easy way to install and run the test suite. Current systemd and meson resolve this: the meson 'install-tests' option installs the unit-test binaries and arun-unit-tests.pyrunner under ${prefix}/lib/systemd/tests, andrun-unit-tests.pyalready emits PASS:/SKIP: results per test.Add a 'tests' PACKAGECONFIG gated on
PTEST_ENABLEDthat sets -Dtests and -Dinstall-tests and pulls in python3-pefile-native (needed to build the boot hwids test).do_install_ptestrelocates the installed tests into ${PTEST_PATH} and drops the mkosi/integration-tests harness (which needs a booted system). A run-ptest wrapper drivesrun-unit-tests.py, and systemd is registered in ptest-packagelists.inc.
Quoted 7 lines
The test/units integration tests, which require a booted system, are out of scope here and can be addressed separately.
Verified on oe-core master (261.2, qemux86-64): with ptest enabled, 342 unit-test binaries plus
run-unit-tests.pyinstall into ${PTEST_PATH} and systemd-ptest packages cleanly with no QA errors.
Please try to keep the commit message to approximately 72 characters per line.
Quoted 73 lines
[YOCTO #16386]
Signed-off-by Himani Ramesh Barde <[email protected]>---
v2:
- Gate tests via a PACKAGECONFIG onPTEST_ENABLED(Jose Quaresma).
- Drop the redundant copy; relocate installed tests into ${PTEST_PATH} (Jose Quaresma).
- Register systemd in ptest-packagelists.inc, fixing the missing-ptest QA error seen on the autobuilder (Khem Raj, Richard Purdie).
- Add python3-pefile-native dependency (fixes boot hwids test build failure).
- Exclude the mkosi/integration-test harness from the ptest package..../distro/include/ptest-packagelists.inc | 1 + meta/recipes-core/systemd/systemd/run-ptest | 11 ++++++++++ meta/recipes-core/systemd/systemd_261.2.bb | 21 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-core/systemd/systemd/run-ptestmeta/conf/distro/include/ptest-packagelists.inc +1
-0@@ -146,6 +146,7 @@ PTESTS_SLOW = "\ python3-numpy \ python3-xmltodict \ strace \ + systemd \ tar \ tcl \ tcl8 \meta/recipes-core/systemd/systemd/run-ptest new file +4
-0@@ -0,0 +1,11 @@ +#!/bin/sh +# Run systemd's installed meson unit tests in ptest format. +# systemd's -Dinstall-tests=true installs run-unit-tests.py plus the +# unit-tests/test-* binaries; run-unit-tests.py already emits PASS:/SKIP:lines.
meta/recipes-core/systemd/systemd/run-ptest new file +3
-0+set -u +here="$(cd "$(dirname "$0")" && pwd)" +for cand in "$here/run-unit-tests.py" "$here/tests/run-unit-tests.py"
/usr/lib/systemd/tests/run-unit-tests.py; dometa/recipes-core/systemd/systemd/run-ptest new file +4
-0+ [ -f "$cand" ] && { python3 "$cand" 2>&1; exit 0; } +done +echo "FAIL: systemd-ptest (run-unit-tests.py not found)" +exit 1meta/recipes-core/systemd/systemd_261.2.bb +0
-1@@ -9,7 +9,7 @@ DEPENDS:append:libc-musl = " libucontext" SECTION = "base/shell" -inherit useradd pkgconfig meson perlnative update-rc.dupdate-alternatives systemd gettext bash-completion manpages
features_checkmime
+inherit useradd pkgconfig meson perlnative update-rc.d update-alternatives systemd gettext bash-completion manpagesfeatures_checkmime ptest# unmerged-usr support is deprecated upstream, taints the system and will be # removed in the near future. Fail the build if it is not enabled.
meta/recipes-core/systemd/systemd_261.2.bb SRC_URI += " \ · line 42
Quoted 6 lines
meta/recipes-core/systemd/systemd_261.2.bb +1
-0@@ -37,6 +37,7 @@ SRC_URI += " \ file://systemd-pager.sh \ file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ file://0003-Do-not-create-var-log-README.patch \ +file://run-ptest \
Please fix the indentation.
Quoted 10 lines
meta/recipes-core/systemd/systemd_261.2.bb +0
-0"
PAM_PLUGINS= " \meta/recipes-core/systemd/systemd_261.2.bb +2
-0@@ -937,3 +938,21 @@ python do_warn_musl() { bb.warn("Using systemd with musl is experimental, see https://github.com/systemd/systemd/blob/9ca4334/NEWS#L524 for details") } addtask warn_musl before do_configure + +# ptest support. systemd's meson 'install-tests' option installs the
Quoted 5 lines
unit-test
+# binaries andrun-unit-tests.pyunder ${prefix}/lib/systemd/tests. Gate it on
+# ptest being enabled and package the installed tree. [YOCTO #16386]
I think this comment could be dropped and moved to the commit message.
meta/recipes-core/systemd/systemd_261.2.bb
Quoted 3 lines
meta/recipes-core/systemd/systemd_261.2.bb +1
-1+PACKAGECONFIG[tests] = "-Dtests=unsafe -Dinstall-tests=true,-Dtests=false -Dinstall-tests=false,python3-pefile-native"
Any special reason to not put the PACKAGECONFIG[tests] along with the others?
https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd_261.2.bb#n110
Quoted 3 lines
+PACKAGECONFIG:append = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)}"
The bb.utils.contains fits better along with the others?
https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd_261.2.bb#n52
Jose
meta/recipes-core/systemd/systemd_261.2.bb python do_warn_musl() { · line 951
Quoted 6 lines
meta/recipes-core/systemd/systemd_261.2.bb +5
-0+ +do_install_ptest() { + install -d ${D}${PTEST_PATH} + if [ -d ${D}${prefix}/lib/systemd/tests ]; then + mv ${D}${prefix}/lib/systemd/tests/* ${D}${PTEST_PATH}/
+ rm -rf ${D}${prefix}/lib/systemd/tests
Quoted 10 lines
meta/recipes-core/systemd/systemd_261.2.bb +6
-1+ fi + rm -rf ${D}${PTEST_PATH}/mkosi ${D}${PTEST_PATH}/integration-tests +} + +RDEPENDS:${PN}-ptest += "python3-core bash" +INSANE_SKIP:${PN}-ptest += "dev-deps debug-files" --2.54.0