* [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories
@ 2024-08-23 17:06 Peter Kjellerstedt
2024-08-23 17:06 ` [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Peter Kjellerstedt
0 siblings, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2024-08-23 17:06 UTC (permalink / raw)
To: openembedded-core
Previously, rm_systemd_unitdir() would remove one parent directory of
${systemd_unitdir} if it was empty after removing ${systemd_unitdir}.
rm_sysvinit_initddir() would not remove any parent directory. Thus, if
the only directory created in /etc was /etc/init.d, an empty /etc would
remain after the cleanup and would be packaged.
Simplify rm_systemd_unitdir() and rm_sysvinit_initddir() by rewriting
them in shell, and use rmdir -p to remove all empty parent directories.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
PATCHv2:
* Rewrote rm_systemd_unitdir() to avoid having `rmdir -p` potentially
delete ${D}.
* Add an argument to `read` used in rm_sysvinit_initddir() while
determining if ${systemd_system_unitdir} is empty. Calling read
without arguments is apparently a bashism.
meta/classes-recipe/systemd.bbclass | 45 +++++++++++++----------------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 0f7e3b5a08..fa6d3775ec 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -208,33 +208,28 @@ python systemd_populate_packages() {
PACKAGESPLITFUNCS =+ "systemd_populate_packages"
-python rm_systemd_unitdir (){
- import shutil
- if not bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
- systemd_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_unitdir'))
- if os.path.exists(systemd_unitdir):
- shutil.rmtree(systemd_unitdir)
- systemd_libdir = os.path.dirname(systemd_unitdir)
- if (os.path.exists(systemd_libdir) and not os.listdir(systemd_libdir)):
- os.rmdir(systemd_libdir)
+rm_systemd_unitdir() {
+ rm -rf ${D}${systemd_unitdir}
+ # Change into ${D} and use a relative path with rmdir -p to avoid
+ # having it remove ${D} if it becomes empty.
+ (cd ${D} && rmdir -p $(dirname ${systemd_unitdir#/}) 2>/dev/null || :)
}
-python rm_sysvinit_initddir (){
- import shutil
- sysv_initddir = oe.path.join(d.getVar("D"), (d.getVar('INIT_D_DIR') or "/etc/init.d"))
-
- if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
- not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) and \
- os.path.exists(sysv_initddir):
- systemd_system_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_system_unitdir'))
+rm_sysvinit_initddir() {
+ local sysv_initddir=${INIT_D_DIR}
+ : ${sysv_initddir:=${sysconfdir}/init.d}
- # If systemd_system_unitdir contains anything, delete sysv_initddir
- if (os.path.exists(systemd_system_unitdir) and os.listdir(systemd_system_unitdir)):
- shutil.rmtree(sysv_initddir)
+ # If systemd_system_unitdir contains anything, delete sysv_initddir
+ if find ${D}${systemd_system_unitdir} -mindepth 1 -maxdepth 1 2>/dev/null | read DUMMY; then
+ rm -rf ${D}$sysv_initddir
+ rmdir -p $(dirname ${D}$sysv_initddir) 2>/dev/null || :
+ fi
}
-do_install[postfuncs] += "${RMINITDIR} "
-RMINITDIR:class-target = " rm_sysvinit_initddir rm_systemd_unitdir "
-RMINITDIR:class-nativesdk = " rm_sysvinit_initddir rm_systemd_unitdir "
-RMINITDIR = ""
-
+do_install[postfuncs] += "${RMINITDIR}"
+RMINITDIR = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'rm_systemd_unitdir', d)} \
+ ${@'rm_sysvinit_initddir' if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
+ not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) else ''} \
+"
+RMINITDIR:class-native = ""
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction
2024-08-23 17:06 [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories Peter Kjellerstedt
@ 2024-08-23 17:06 ` Peter Kjellerstedt
2024-08-24 12:54 ` [OE-core] " Alexandre Belloni
0 siblings, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2024-08-23 17:06 UTC (permalink / raw)
To: openembedded-core
These tests verify that the correct files are left behind when systemd
is inherited and depending on whether the systemd and/or sysvinit distro
features are enabled.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
PATCHv2:
* Change LICENSE to MIT for the test recipes.
* Add EXCLUDE_FROM_WORLD to the test recipes.
.../bbclasses/systemd-and-sysvinit.bb | 17 +++
.../recipes-test/bbclasses/systemd-only.bb | 12 ++
meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++
3 files changed, 135 insertions(+)
create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-only.bb
create mode 100644 meta/lib/oeqa/selftest/cases/bbclasses.py
diff --git a/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
new file mode 100644
index 0000000000..f9fc59a494
--- /dev/null
+++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
@@ -0,0 +1,17 @@
+LICENSE = "MIT"
+
+inherit allarch systemd update-rc.d
+
+do_install() {
+ install -d ${D}${systemd_system_unitdir}
+ touch ${D}${systemd_system_unitdir}/${BPN}.service
+
+ install -d ${D}${INIT_D_DIR}
+ touch ${D}${INIT_D_DIR}/${BPN}
+}
+
+INITSCRIPT_NAME = "${BPN}"
+
+SYSTEMD_SERVICE:${PN} = "${BPN}.service"
+
+EXCLUDE_FROM_WORLD="1"
diff --git a/meta-selftest/recipes-test/bbclasses/systemd-only.bb b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
new file mode 100644
index 0000000000..590a27b9cb
--- /dev/null
+++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
@@ -0,0 +1,12 @@
+LICENSE = "MIT"
+
+inherit allarch systemd
+
+do_install() {
+ install -d ${D}${systemd_system_unitdir}
+ touch ${D}${systemd_system_unitdir}/${BPN}.service
+}
+
+SYSTEMD_SERVICE:${PN} = "${BPN}.service"
+
+EXCLUDE_FROM_WORLD="1"
diff --git a/meta/lib/oeqa/selftest/cases/bbclasses.py b/meta/lib/oeqa/selftest/cases/bbclasses.py
new file mode 100644
index 0000000000..10545ebe65
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/bbclasses.py
@@ -0,0 +1,106 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import get_bb_vars, bitbake
+
+class Systemd(OESelftestTestCase):
+ """
+ Tests related to the systemd bbclass.
+ """
+
+ def getVars(self, recipe):
+ self.bb_vars = get_bb_vars(
+ [
+ 'BPN',
+ 'D',
+ 'INIT_D_DIR',
+ 'prefix',
+ 'systemd_system_unitdir',
+ 'sysconfdir',
+ ],
+ recipe,
+ )
+
+ def fileExists(self, filename):
+ self.assertExists(filename.format(**self.bb_vars))
+
+ def fileNotExists(self, filename):
+ self.assertNotExists(filename.format(**self.bb_vars))
+
+ def test_systemd_in_distro(self):
+ """
+ Summary: Verify that no sysvinit files are installed when the
+ systemd distro feature is enabled, but sysvinit is not.
+ Expected: Systemd service file exists, but /etc does not.
+ Product: OE-Core
+ Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+ """
+
+ self.write_config("""
+DISTRO_FEATURES:append = " systemd usrmerge"
+DISTRO_FEATURES:remove = "sysvinit"
+VIRTUAL-RUNTIME_init_manager = "systemd"
+""")
+ bitbake("systemd-only systemd-and-sysvinit -c install")
+
+ self.getVars("systemd-only")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+
+ self.getVars("systemd-and-sysvinit")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileNotExists("{D}{sysconfdir}")
+
+ def test_systemd_and_sysvinit_in_distro(self):
+ """
+ Summary: Verify that both systemd and sysvinit files are installed
+ when both the systemd and sysvinit distro features are
+ enabled.
+ Expected: Systemd service file and sysvinit initscript exist.
+ Product: OE-Core
+ Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+ """
+
+ self.write_config("""
+DISTRO_FEATURES:append = " systemd sysvinit usrmerge"
+VIRTUAL-RUNTIME_init_manager = "systemd"
+""")
+ bitbake("systemd-only systemd-and-sysvinit -c install")
+
+ self.getVars("systemd-only")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+
+ self.getVars("systemd-and-sysvinit")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileExists("{D}{INIT_D_DIR}/{BPN}")
+
+ def test_sysvinit_in_distro(self):
+ """
+ Summary: Verify that no systemd service files are installed when the
+ sysvinit distro feature is enabled, but systemd is not.
+ Expected: The systemd service file does not exist, nor does /usr.
+ The sysvinit initscript exists.
+ Product: OE-Core
+ Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+ """
+
+ self.write_config("""
+DISTRO_FEATURES:remove = "systemd"
+DISTRO_FEATURES:append = " sysvinit usrmerge"
+VIRTUAL-RUNTIME_init_manager = "sysvinit"
+""")
+ bitbake("systemd-only systemd-and-sysvinit -c install")
+
+ self.getVars("systemd-only")
+ self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileNotExists("{D}{prefix}")
+ self.fileNotExists("{D}{sysconfdir}")
+ self.fileExists("{D}")
+
+ self.getVars("systemd-and-sysvinit")
+ self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileNotExists("{D}{prefix}")
+ self.fileExists("{D}{INIT_D_DIR}/{BPN}")
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [OE-core] [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction
2024-08-23 17:06 ` [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Peter Kjellerstedt
@ 2024-08-24 12:54 ` Alexandre Belloni
2024-08-24 23:49 ` Peter Kjellerstedt
0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2024-08-24 12:54 UTC (permalink / raw)
To: Peter Kjellerstedt; +Cc: openembedded-core
Hello,
This causes the following failures on the AB:
https://autobuilder.yoctoproject.org/typhoon/#/builders/131/builds/4746/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/102/builds/6435/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/107/builds/6486/steps/14/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/109/builds/8223/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/101/builds/8110/steps/14/logs/stdio
Traceback (most recent call last):
File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
return func(*args, **kwargs)
File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
return func(*args, **kwargs)
File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
return func(*args, **kwargs)
[Previous line repeated 1 more time]
File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/runtime/cases/opkg.py", line 59, in test_opkg_install_from_repo
self.pkg('install run-postinsts-dev')
File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/runtime/cases/opkg.py", line 19, in pkg
self.assertEqual(status, expected, message)
AssertionError: 255 != 0 : opkg install run-postinsts-dev
Synchronizing state of run-postinsts.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable run-postinsts
Failed to execute /usr/lib/systemd/systemd-sysv-install: No such file or directory
error: pkg_run_script: package "run-postinsts" postinst script returned status 1.
error: opkg_configure: run-postinsts.postinst returned 1.
On 23/08/2024 19:06:33+0200, Peter Kjellerstedt wrote:
> These tests verify that the correct files are left behind when systemd
> is inherited and depending on whether the systemd and/or sysvinit distro
> features are enabled.
>
> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
>
> PATCHv2:
> * Change LICENSE to MIT for the test recipes.
> * Add EXCLUDE_FROM_WORLD to the test recipes.
>
> .../bbclasses/systemd-and-sysvinit.bb | 17 +++
> .../recipes-test/bbclasses/systemd-only.bb | 12 ++
> meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++
> 3 files changed, 135 insertions(+)
> create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-only.bb
> create mode 100644 meta/lib/oeqa/selftest/cases/bbclasses.py
>
> diff --git a/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> new file mode 100644
> index 0000000000..f9fc59a494
> --- /dev/null
> +++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> @@ -0,0 +1,17 @@
> +LICENSE = "MIT"
> +
> +inherit allarch systemd update-rc.d
> +
> +do_install() {
> + install -d ${D}${systemd_system_unitdir}
> + touch ${D}${systemd_system_unitdir}/${BPN}.service
> +
> + install -d ${D}${INIT_D_DIR}
> + touch ${D}${INIT_D_DIR}/${BPN}
> +}
> +
> +INITSCRIPT_NAME = "${BPN}"
> +
> +SYSTEMD_SERVICE:${PN} = "${BPN}.service"
> +
> +EXCLUDE_FROM_WORLD="1"
> diff --git a/meta-selftest/recipes-test/bbclasses/systemd-only.bb b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> new file mode 100644
> index 0000000000..590a27b9cb
> --- /dev/null
> +++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> @@ -0,0 +1,12 @@
> +LICENSE = "MIT"
> +
> +inherit allarch systemd
> +
> +do_install() {
> + install -d ${D}${systemd_system_unitdir}
> + touch ${D}${systemd_system_unitdir}/${BPN}.service
> +}
> +
> +SYSTEMD_SERVICE:${PN} = "${BPN}.service"
> +
> +EXCLUDE_FROM_WORLD="1"
> diff --git a/meta/lib/oeqa/selftest/cases/bbclasses.py b/meta/lib/oeqa/selftest/cases/bbclasses.py
> new file mode 100644
> index 0000000000..10545ebe65
> --- /dev/null
> +++ b/meta/lib/oeqa/selftest/cases/bbclasses.py
> @@ -0,0 +1,106 @@
> +#
> +# Copyright OpenEmbedded Contributors
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +from oeqa.selftest.case import OESelftestTestCase
> +from oeqa.utils.commands import get_bb_vars, bitbake
> +
> +class Systemd(OESelftestTestCase):
> + """
> + Tests related to the systemd bbclass.
> + """
> +
> + def getVars(self, recipe):
> + self.bb_vars = get_bb_vars(
> + [
> + 'BPN',
> + 'D',
> + 'INIT_D_DIR',
> + 'prefix',
> + 'systemd_system_unitdir',
> + 'sysconfdir',
> + ],
> + recipe,
> + )
> +
> + def fileExists(self, filename):
> + self.assertExists(filename.format(**self.bb_vars))
> +
> + def fileNotExists(self, filename):
> + self.assertNotExists(filename.format(**self.bb_vars))
> +
> + def test_systemd_in_distro(self):
> + """
> + Summary: Verify that no sysvinit files are installed when the
> + systemd distro feature is enabled, but sysvinit is not.
> + Expected: Systemd service file exists, but /etc does not.
> + Product: OE-Core
> + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> + """
> +
> + self.write_config("""
> +DISTRO_FEATURES:append = " systemd usrmerge"
> +DISTRO_FEATURES:remove = "sysvinit"
> +VIRTUAL-RUNTIME_init_manager = "systemd"
> +""")
> + bitbake("systemd-only systemd-and-sysvinit -c install")
> +
> + self.getVars("systemd-only")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> +
> + self.getVars("systemd-and-sysvinit")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileNotExists("{D}{sysconfdir}")
> +
> + def test_systemd_and_sysvinit_in_distro(self):
> + """
> + Summary: Verify that both systemd and sysvinit files are installed
> + when both the systemd and sysvinit distro features are
> + enabled.
> + Expected: Systemd service file and sysvinit initscript exist.
> + Product: OE-Core
> + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> + """
> +
> + self.write_config("""
> +DISTRO_FEATURES:append = " systemd sysvinit usrmerge"
> +VIRTUAL-RUNTIME_init_manager = "systemd"
> +""")
> + bitbake("systemd-only systemd-and-sysvinit -c install")
> +
> + self.getVars("systemd-only")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> +
> + self.getVars("systemd-and-sysvinit")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileExists("{D}{INIT_D_DIR}/{BPN}")
> +
> + def test_sysvinit_in_distro(self):
> + """
> + Summary: Verify that no systemd service files are installed when the
> + sysvinit distro feature is enabled, but systemd is not.
> + Expected: The systemd service file does not exist, nor does /usr.
> + The sysvinit initscript exists.
> + Product: OE-Core
> + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> + """
> +
> + self.write_config("""
> +DISTRO_FEATURES:remove = "systemd"
> +DISTRO_FEATURES:append = " sysvinit usrmerge"
> +VIRTUAL-RUNTIME_init_manager = "sysvinit"
> +""")
> + bitbake("systemd-only systemd-and-sysvinit -c install")
> +
> + self.getVars("systemd-only")
> + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileNotExists("{D}{prefix}")
> + self.fileNotExists("{D}{sysconfdir}")
> + self.fileExists("{D}")
> +
> + self.getVars("systemd-and-sysvinit")
> + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileNotExists("{D}{prefix}")
> + self.fileExists("{D}{INIT_D_DIR}/{BPN}")
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#203702): https://lists.openembedded.org/g/openembedded-core/message/203702
> Mute This Topic: https://lists.openembedded.org/mt/108059587/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [OE-core] [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction
2024-08-24 12:54 ` [OE-core] " Alexandre Belloni
@ 2024-08-24 23:49 ` Peter Kjellerstedt
0 siblings, 0 replies; 6+ messages in thread
From: Peter Kjellerstedt @ 2024-08-24 23:49 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: openembedded-core@lists.openembedded.org
> -----Original Message-----
> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Sent: den 24 augusti 2024 14:55
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests
> for systemd and update-rc.d interaction
>
> Hello,
>
> This causes the following failures on the AB:
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/131/builds/4746/steps/14/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/102/builds/6435/steps/15/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/107/builds/6486/steps/14/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/109/builds/8223/steps/15/logs/stdio
> https://autobuilder.yoctoproject.org/typhoon/#/builders/101/builds/8110/steps/14/logs/stdio
>
> Traceback (most recent call last):
> File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
> return func(*args, **kwargs)
> File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
> return func(*args, **kwargs)
> File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/core/decorator/__init__.py", line 35, in wrapped_f
> return func(*args, **kwargs)
> [Previous line repeated 1 more time]
> File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/runtime/cases/opkg.py", line 59, in test_opkg_install_from_repo
> self.pkg('install run-postinsts-dev')
> File "/home/pokybuild/yocto-worker/qemux86-alt/build/meta/lib/oeqa/runtime/cases/opkg.py", line 19, in pkg
> self.assertEqual(status, expected, message)
> AssertionError: 255 != 0 : opkg install run-postinsts-dev
> Synchronizing state of run-postinsts.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
> Executing: /usr/lib/systemd/systemd-sysv-install enable run-postinsts
> Failed to execute /usr/lib/systemd/systemd-sysv-install: No such file or directory
> error: pkg_run_script: package "run-postinsts" postinst script returned status 1.
> error: opkg_configure: run-postinsts.postinst returned 1.
Ok, that was unexpected. Because that is the exact error that I fixed
between v1 and v2 (and obviously do not see in my own testing anymore)...
//Peter
> On 23/08/2024 19:06:33+0200, Peter Kjellerstedt wrote:
> > These tests verify that the correct files are left behind when systemd
> > is inherited and depending on whether the systemd and/or sysvinit distro
> > features are enabled.
> >
> > Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> > ---
> >
> > PATCHv2:
> > * Change LICENSE to MIT for the test recipes.
> > * Add EXCLUDE_FROM_WORLD to the test recipes.
> >
> > .../bbclasses/systemd-and-sysvinit.bb | 17 +++
> > .../recipes-test/bbclasses/systemd-only.bb | 12 ++
> > meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++
> > 3 files changed, 135 insertions(+)
> > create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-and-
> sysvinit.bb
> > create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-only.bb
> > create mode 100644 meta/lib/oeqa/selftest/cases/bbclasses.py
> >
> > diff --git a/meta-selftest/recipes-test/bbclasses/systemd-and-
> sysvinit.bb b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> > new file mode 100644
> > index 0000000000..f9fc59a494
> > --- /dev/null
> > +++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> > @@ -0,0 +1,17 @@
> > +LICENSE = "MIT"
> > +
> > +inherit allarch systemd update-rc.d
> > +
> > +do_install() {
> > + install -d ${D}${systemd_system_unitdir}
> > + touch ${D}${systemd_system_unitdir}/${BPN}.service
> > +
> > + install -d ${D}${INIT_D_DIR}
> > + touch ${D}${INIT_D_DIR}/${BPN}
> > +}
> > +
> > +INITSCRIPT_NAME = "${BPN}"
> > +
> > +SYSTEMD_SERVICE:${PN} = "${BPN}.service"
> > +
> > +EXCLUDE_FROM_WORLD="1"
> > diff --git a/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> > new file mode 100644
> > index 0000000000..590a27b9cb
> > --- /dev/null
> > +++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> > @@ -0,0 +1,12 @@
> > +LICENSE = "MIT"
> > +
> > +inherit allarch systemd
> > +
> > +do_install() {
> > + install -d ${D}${systemd_system_unitdir}
> > + touch ${D}${systemd_system_unitdir}/${BPN}.service
> > +}
> > +
> > +SYSTEMD_SERVICE:${PN} = "${BPN}.service"
> > +
> > +EXCLUDE_FROM_WORLD="1"
> > diff --git a/meta/lib/oeqa/selftest/cases/bbclasses.py
> b/meta/lib/oeqa/selftest/cases/bbclasses.py
> > new file mode 100644
> > index 0000000000..10545ebe65
> > --- /dev/null
> > +++ b/meta/lib/oeqa/selftest/cases/bbclasses.py
> > @@ -0,0 +1,106 @@
> > +#
> > +# Copyright OpenEmbedded Contributors
> > +#
> > +# SPDX-License-Identifier: MIT
> > +#
> > +
> > +from oeqa.selftest.case import OESelftestTestCase
> > +from oeqa.utils.commands import get_bb_vars, bitbake
> > +
> > +class Systemd(OESelftestTestCase):
> > + """
> > + Tests related to the systemd bbclass.
> > + """
> > +
> > + def getVars(self, recipe):
> > + self.bb_vars = get_bb_vars(
> > + [
> > + 'BPN',
> > + 'D',
> > + 'INIT_D_DIR',
> > + 'prefix',
> > + 'systemd_system_unitdir',
> > + 'sysconfdir',
> > + ],
> > + recipe,
> > + )
> > +
> > + def fileExists(self, filename):
> > + self.assertExists(filename.format(**self.bb_vars))
> > +
> > + def fileNotExists(self, filename):
> > + self.assertNotExists(filename.format(**self.bb_vars))
> > +
> > + def test_systemd_in_distro(self):
> > + """
> > + Summary: Verify that no sysvinit files are installed when
> the
> > + systemd distro feature is enabled, but sysvinit is
> not.
> > + Expected: Systemd service file exists, but /etc does not.
> > + Product: OE-Core
> > + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> > + """
> > +
> > + self.write_config("""
> > +DISTRO_FEATURES:append = " systemd usrmerge"
> > +DISTRO_FEATURES:remove = "sysvinit"
> > +VIRTUAL-RUNTIME_init_manager = "systemd"
> > +""")
> > + bitbake("systemd-only systemd-and-sysvinit -c install")
> > +
> > + self.getVars("systemd-only")
> > + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> > +
> > + self.getVars("systemd-and-sysvinit")
> > + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> > + self.fileNotExists("{D}{sysconfdir}")
> > +
> > + def test_systemd_and_sysvinit_in_distro(self):
> > + """
> > + Summary: Verify that both systemd and sysvinit files are
> installed
> > + when both the systemd and sysvinit distro features
> are
> > + enabled.
> > + Expected: Systemd service file and sysvinit initscript exist.
> > + Product: OE-Core
> > + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> > + """
> > +
> > + self.write_config("""
> > +DISTRO_FEATURES:append = " systemd sysvinit usrmerge"
> > +VIRTUAL-RUNTIME_init_manager = "systemd"
> > +""")
> > + bitbake("systemd-only systemd-and-sysvinit -c install")
> > +
> > + self.getVars("systemd-only")
> > + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> > +
> > + self.getVars("systemd-and-sysvinit")
> > + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> > + self.fileExists("{D}{INIT_D_DIR}/{BPN}")
> > +
> > + def test_sysvinit_in_distro(self):
> > + """
> > + Summary: Verify that no systemd service files are installed
> when the
> > + sysvinit distro feature is enabled, but systemd is
> not.
> > + Expected: The systemd service file does not exist, nor does
> /usr.
> > + The sysvinit initscript exists.
> > + Product: OE-Core
> > + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> > + """
> > +
> > + self.write_config("""
> > +DISTRO_FEATURES:remove = "systemd"
> > +DISTRO_FEATURES:append = " sysvinit usrmerge"
> > +VIRTUAL-RUNTIME_init_manager = "sysvinit"
> > +""")
> > + bitbake("systemd-only systemd-and-sysvinit -c install")
> > +
> > + self.getVars("systemd-only")
> > + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
> > + self.fileNotExists("{D}{prefix}")
> > + self.fileNotExists("{D}{sysconfdir}")
> > + self.fileExists("{D}")
> > +
> > + self.getVars("systemd-and-sysvinit")
> > + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
> > + self.fileNotExists("{D}{prefix}")
> > + self.fileExists("{D}{INIT_D_DIR}/{BPN}")
>
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#203702):
> https://lists.openembedded.org/g/openembedded-core/message/203702
> > Mute This Topic: https://lists.openembedded.org/mt/108059587/3617179
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
> [alexandre.belloni@bootlin.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories
@ 2024-08-20 22:31 Peter Kjellerstedt
2024-08-20 22:31 ` [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Peter Kjellerstedt
0 siblings, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2024-08-20 22:31 UTC (permalink / raw)
To: openembedded-core
Previously, rm_systemd_unitdir() would remove one parent directory of
${systemd_unitdir} if it was empty after removing ${systemd_unitdir}.
rm_sysvinit_initddir() would not remove any parent directory. Thus, if
the only directory created in /etc was /etc/init.d, an empty /etc would
remain after the cleanup and would be packaged.
Simplify rm_systemd_unitdir() and rm_sysvinit_initddir() by rewriting
them in shell, and use rmdir -p to remove all empty parent directories.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
PATCHv2: No changes.
meta/classes-recipe/systemd.bbclass | 46 +++++++++++++----------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 0f7e3b5a08..987b3fc0c7 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -208,33 +208,29 @@ python systemd_populate_packages() {
PACKAGESPLITFUNCS =+ "systemd_populate_packages"
-python rm_systemd_unitdir (){
- import shutil
- if not bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
- systemd_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_unitdir'))
- if os.path.exists(systemd_unitdir):
- shutil.rmtree(systemd_unitdir)
- systemd_libdir = os.path.dirname(systemd_unitdir)
- if (os.path.exists(systemd_libdir) and not os.listdir(systemd_libdir)):
- os.rmdir(systemd_libdir)
+rm_systemd_unitdir() {
+ rm -rf ${D}${systemd_unitdir}
+ rmdir -p $(dirname ${D}${systemd_unitdir}) 2>/dev/null || :
+ # Make sure ${D} still exists since rmdir -p may have removed it in
+ # case ${systemd_unitdir} was the only directory present.
+ [ -d ${D} ] || mkdir -p ${D}
}
-python rm_sysvinit_initddir (){
- import shutil
- sysv_initddir = oe.path.join(d.getVar("D"), (d.getVar('INIT_D_DIR') or "/etc/init.d"))
-
- if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
- not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) and \
- os.path.exists(sysv_initddir):
- systemd_system_unitdir = oe.path.join(d.getVar("D"), d.getVar('systemd_system_unitdir'))
+rm_sysvinit_initddir() {
+ local sysv_initddir=${INIT_D_DIR}
+ : ${sysv_initddir:=${sysconfdir}/init.d}
- # If systemd_system_unitdir contains anything, delete sysv_initddir
- if (os.path.exists(systemd_system_unitdir) and os.listdir(systemd_system_unitdir)):
- shutil.rmtree(sysv_initddir)
+ # If systemd_system_unitdir contains anything, delete sysv_initddir
+ if find ${D}${systemd_system_unitdir} -mindepth 1 -maxdepth 1 2>/dev/null | read; then
+ rm -rf ${D}$sysv_initddir
+ rmdir -p $(dirname ${D}$sysv_initddir) 2>/dev/null || :
+ fi
}
-do_install[postfuncs] += "${RMINITDIR} "
-RMINITDIR:class-target = " rm_sysvinit_initddir rm_systemd_unitdir "
-RMINITDIR:class-nativesdk = " rm_sysvinit_initddir rm_systemd_unitdir "
-RMINITDIR = ""
-
+do_install[postfuncs] += "${RMINITDIR}"
+RMINITDIR = " \
+ ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'rm_systemd_unitdir', d)} \
+ ${@'rm_sysvinit_initddir' if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
+ not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) else ''} \
+"
+RMINITDIR:class-native = ""
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction
2024-08-20 22:31 [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories Peter Kjellerstedt
@ 2024-08-20 22:31 ` Peter Kjellerstedt
2024-08-22 10:07 ` [OE-core] " Richard Purdie
[not found] ` <17EE05117ACE9BE7.29141@lists.openembedded.org>
0 siblings, 2 replies; 6+ messages in thread
From: Peter Kjellerstedt @ 2024-08-20 22:31 UTC (permalink / raw)
To: openembedded-core
These tests verify that the correct files are left behind when systemd
is inherited and depending on whether the systemd and/or sysvinit distro
features are enabled.
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
PATCHv2: Change LICENSE to MIT and add EXCLUDE_FROM_WORLD to the test
recipes
.../bbclasses/systemd-and-sysvinit.bb | 17 +++
.../recipes-test/bbclasses/systemd-only.bb | 12 ++
meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++
3 files changed, 135 insertions(+)
create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-only.bb
create mode 100644 meta/lib/oeqa/selftest/cases/bbclasses.py
diff --git a/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
new file mode 100644
index 0000000000..f9fc59a494
--- /dev/null
+++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
@@ -0,0 +1,17 @@
+LICENSE = "MIT"
+
+inherit allarch systemd update-rc.d
+
+do_install() {
+ install -d ${D}${systemd_system_unitdir}
+ touch ${D}${systemd_system_unitdir}/${BPN}.service
+
+ install -d ${D}${INIT_D_DIR}
+ touch ${D}${INIT_D_DIR}/${BPN}
+}
+
+INITSCRIPT_NAME = "${BPN}"
+
+SYSTEMD_SERVICE:${PN} = "${BPN}.service"
+
+EXCLUDE_FROM_WORLD = "1"
diff --git a/meta-selftest/recipes-test/bbclasses/systemd-only.bb b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
new file mode 100644
index 0000000000..590a27b9cb
--- /dev/null
+++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
@@ -0,0 +1,12 @@
+LICENSE = "MIT"
+
+inherit allarch systemd
+
+do_install() {
+ install -d ${D}${systemd_system_unitdir}
+ touch ${D}${systemd_system_unitdir}/${BPN}.service
+}
+
+SYSTEMD_SERVICE:${PN} = "${BPN}.service"
+
+EXCLUDE_FROM_WORLD = "1"
diff --git a/meta/lib/oeqa/selftest/cases/bbclasses.py b/meta/lib/oeqa/selftest/cases/bbclasses.py
new file mode 100644
index 0000000000..10545ebe65
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/bbclasses.py
@@ -0,0 +1,106 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import get_bb_vars, bitbake
+
+class Systemd(OESelftestTestCase):
+ """
+ Tests related to the systemd bbclass.
+ """
+
+ def getVars(self, recipe):
+ self.bb_vars = get_bb_vars(
+ [
+ 'BPN',
+ 'D',
+ 'INIT_D_DIR',
+ 'prefix',
+ 'systemd_system_unitdir',
+ 'sysconfdir',
+ ],
+ recipe,
+ )
+
+ def fileExists(self, filename):
+ self.assertExists(filename.format(**self.bb_vars))
+
+ def fileNotExists(self, filename):
+ self.assertNotExists(filename.format(**self.bb_vars))
+
+ def test_systemd_in_distro(self):
+ """
+ Summary: Verify that no sysvinit files are installed when the
+ systemd distro feature is enabled, but sysvinit is not.
+ Expected: Systemd service file exists, but /etc does not.
+ Product: OE-Core
+ Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+ """
+
+ self.write_config("""
+DISTRO_FEATURES:append = " systemd usrmerge"
+DISTRO_FEATURES:remove = "sysvinit"
+VIRTUAL-RUNTIME_init_manager = "systemd"
+""")
+ bitbake("systemd-only systemd-and-sysvinit -c install")
+
+ self.getVars("systemd-only")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+
+ self.getVars("systemd-and-sysvinit")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileNotExists("{D}{sysconfdir}")
+
+ def test_systemd_and_sysvinit_in_distro(self):
+ """
+ Summary: Verify that both systemd and sysvinit files are installed
+ when both the systemd and sysvinit distro features are
+ enabled.
+ Expected: Systemd service file and sysvinit initscript exist.
+ Product: OE-Core
+ Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+ """
+
+ self.write_config("""
+DISTRO_FEATURES:append = " systemd sysvinit usrmerge"
+VIRTUAL-RUNTIME_init_manager = "systemd"
+""")
+ bitbake("systemd-only systemd-and-sysvinit -c install")
+
+ self.getVars("systemd-only")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+
+ self.getVars("systemd-and-sysvinit")
+ self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileExists("{D}{INIT_D_DIR}/{BPN}")
+
+ def test_sysvinit_in_distro(self):
+ """
+ Summary: Verify that no systemd service files are installed when the
+ sysvinit distro feature is enabled, but systemd is not.
+ Expected: The systemd service file does not exist, nor does /usr.
+ The sysvinit initscript exists.
+ Product: OE-Core
+ Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+ """
+
+ self.write_config("""
+DISTRO_FEATURES:remove = "systemd"
+DISTRO_FEATURES:append = " sysvinit usrmerge"
+VIRTUAL-RUNTIME_init_manager = "sysvinit"
+""")
+ bitbake("systemd-only systemd-and-sysvinit -c install")
+
+ self.getVars("systemd-only")
+ self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileNotExists("{D}{prefix}")
+ self.fileNotExists("{D}{sysconfdir}")
+ self.fileExists("{D}")
+
+ self.getVars("systemd-and-sysvinit")
+ self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
+ self.fileNotExists("{D}{prefix}")
+ self.fileExists("{D}{INIT_D_DIR}/{BPN}")
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [OE-core] [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction
2024-08-20 22:31 ` [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Peter Kjellerstedt
@ 2024-08-22 10:07 ` Richard Purdie
[not found] ` <17EE05117ACE9BE7.29141@lists.openembedded.org>
1 sibling, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2024-08-22 10:07 UTC (permalink / raw)
To: peter.kjellerstedt, openembedded-core
On Wed, 2024-08-21 at 00:31 +0200, Peter Kjellerstedt via lists.openembedded.org wrote:
> These tests verify that the correct files are left behind when systemd
> is inherited and depending on whether the systemd and/or sysvinit distro
> features are enabled.
>
> Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> ---
>
> PATCHv2: Change LICENSE to MIT and add EXCLUDE_FROM_WORLD to the test
> recipes
>
> .../bbclasses/systemd-and-sysvinit.bb | 17 +++
> .../recipes-test/bbclasses/systemd-only.bb | 12 ++
> meta/lib/oeqa/selftest/cases/bbclasses.py | 106 ++++++++++++++++++
> 3 files changed, 135 insertions(+)
> create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> create mode 100644 meta-selftest/recipes-test/bbclasses/systemd-only.bb
> create mode 100644 meta/lib/oeqa/selftest/cases/bbclasses.py
>
> diff --git a/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> new file mode 100644
> index 0000000000..f9fc59a494
> --- /dev/null
> +++ b/meta-selftest/recipes-test/bbclasses/systemd-and-sysvinit.bb
> @@ -0,0 +1,17 @@
> +LICENSE = "MIT"
> +
> +inherit allarch systemd update-rc.d
> +
> +do_install() {
> + install -d ${D}${systemd_system_unitdir}
> + touch ${D}${systemd_system_unitdir}/${BPN}.service
> +
> + install -d ${D}${INIT_D_DIR}
> + touch ${D}${INIT_D_DIR}/${BPN}
> +}
> +
> +INITSCRIPT_NAME = "${BPN}"
> +
> +SYSTEMD_SERVICE:${PN} = "${BPN}.service"
> +
> +EXCLUDE_FROM_WORLD = "1"
> diff --git a/meta-selftest/recipes-test/bbclasses/systemd-only.bb b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> new file mode 100644
> index 0000000000..590a27b9cb
> --- /dev/null
> +++ b/meta-selftest/recipes-test/bbclasses/systemd-only.bb
> @@ -0,0 +1,12 @@
> +LICENSE = "MIT"
> +
> +inherit allarch systemd
> +
> +do_install() {
> + install -d ${D}${systemd_system_unitdir}
> + touch ${D}${systemd_system_unitdir}/${BPN}.service
> +}
> +
> +SYSTEMD_SERVICE:${PN} = "${BPN}.service"
> +
> +EXCLUDE_FROM_WORLD = "1"
> diff --git a/meta/lib/oeqa/selftest/cases/bbclasses.py b/meta/lib/oeqa/selftest/cases/bbclasses.py
> new file mode 100644
> index 0000000000..10545ebe65
> --- /dev/null
> +++ b/meta/lib/oeqa/selftest/cases/bbclasses.py
> @@ -0,0 +1,106 @@
> +#
> +# Copyright OpenEmbedded Contributors
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +from oeqa.selftest.case import OESelftestTestCase
> +from oeqa.utils.commands import get_bb_vars, bitbake
> +
> +class Systemd(OESelftestTestCase):
> + """
> + Tests related to the systemd bbclass.
> + """
> +
> + def getVars(self, recipe):
> + self.bb_vars = get_bb_vars(
> + [
> + 'BPN',
> + 'D',
> + 'INIT_D_DIR',
> + 'prefix',
> + 'systemd_system_unitdir',
> + 'sysconfdir',
> + ],
> + recipe,
> + )
> +
> + def fileExists(self, filename):
> + self.assertExists(filename.format(**self.bb_vars))
> +
> + def fileNotExists(self, filename):
> + self.assertNotExists(filename.format(**self.bb_vars))
> +
> + def test_systemd_in_distro(self):
> + """
> + Summary: Verify that no sysvinit files are installed when the
> + systemd distro feature is enabled, but sysvinit is not.
> + Expected: Systemd service file exists, but /etc does not.
> + Product: OE-Core
> + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> + """
> +
> + self.write_config("""
> +DISTRO_FEATURES:append = " systemd usrmerge"
> +DISTRO_FEATURES:remove = "sysvinit"
> +VIRTUAL-RUNTIME_init_manager = "systemd"
> +""")
> + bitbake("systemd-only systemd-and-sysvinit -c install")
> +
> + self.getVars("systemd-only")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> +
> + self.getVars("systemd-and-sysvinit")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileNotExists("{D}{sysconfdir}")
> +
> + def test_systemd_and_sysvinit_in_distro(self):
> + """
> + Summary: Verify that both systemd and sysvinit files are installed
> + when both the systemd and sysvinit distro features are
> + enabled.
> + Expected: Systemd service file and sysvinit initscript exist.
> + Product: OE-Core
> + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> + """
> +
> + self.write_config("""
> +DISTRO_FEATURES:append = " systemd sysvinit usrmerge"
> +VIRTUAL-RUNTIME_init_manager = "systemd"
> +""")
> + bitbake("systemd-only systemd-and-sysvinit -c install")
> +
> + self.getVars("systemd-only")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> +
> + self.getVars("systemd-and-sysvinit")
> + self.fileExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileExists("{D}{INIT_D_DIR}/{BPN}")
> +
> + def test_sysvinit_in_distro(self):
> + """
> + Summary: Verify that no systemd service files are installed when the
> + sysvinit distro feature is enabled, but systemd is not.
> + Expected: The systemd service file does not exist, nor does /usr.
> + The sysvinit initscript exists.
> + Product: OE-Core
> + Author: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> + """
> +
> + self.write_config("""
> +DISTRO_FEATURES:remove = "systemd"
> +DISTRO_FEATURES:append = " sysvinit usrmerge"
> +VIRTUAL-RUNTIME_init_manager = "sysvinit"
> +""")
> + bitbake("systemd-only systemd-and-sysvinit -c install")
> +
> + self.getVars("systemd-only")
> + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileNotExists("{D}{prefix}")
> + self.fileNotExists("{D}{sysconfdir}")
> + self.fileExists("{D}")
> +
> + self.getVars("systemd-and-sysvinit")
> + self.fileNotExists("{D}{systemd_system_unitdir}/{BPN}.service")
> + self.fileNotExists("{D}{prefix}")
> + self.fileExists("{D}{INIT_D_DIR}/{BPN}")
>
I'm really happy to see tests so thanks for that! Unfortunately
something isn't quite right, some builds passed and some failed. The
failures:
https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/3754/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/3754/steps/15/logs/stdio
https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/7088/steps/14/logs/stdio
and the passes:
https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/7074
https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/7096
At this point I've not looked into what happened, I'm just reporting the results.
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <17EE05117ACE9BE7.29141@lists.openembedded.org>]
end of thread, other threads:[~2024-08-24 23:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-23 17:06 [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories Peter Kjellerstedt
2024-08-23 17:06 ` [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Peter Kjellerstedt
2024-08-24 12:54 ` [OE-core] " Alexandre Belloni
2024-08-24 23:49 ` Peter Kjellerstedt
-- strict thread matches above, loose matches on Subject: below --
2024-08-20 22:31 [PATCHv2 1/2] systemd.bbclass: Clean up empty parent directories Peter Kjellerstedt
2024-08-20 22:31 ` [PATCHv2 2/2] oeqa/selftest/bbclasses: Add tests for systemd and update-rc.d interaction Peter Kjellerstedt
2024-08-22 10:07 ` [OE-core] " Richard Purdie
[not found] ` <17EE05117ACE9BE7.29141@lists.openembedded.org>
2024-08-22 10:10 ` Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.