Message ID | 20240820223140.770567-2-pkj@axis.com |
---|---|
State | Accepted, archived |
Commit | 4ef25caa00ad08046567d0e7f4523486c3a256d0 |
Headers | show |
Series | [PATCHv2,1/2] systemd.bbclass: Clean up empty parent directories | expand |
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
On Thu, 2024-08-22 at 11:07 +0100, Richard Purdie via lists.openembedded.org wrote: > 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. I meant to add that I'm a bit worried this series is also causing these runtime test failures: https://autobuilder.yoctoproject.org/typhoon/#/builders/101/builds/8100/steps/14/logs/stdio https://autobuilder.yoctoproject.org/typhoon/#/builders/102/builds/6427/steps/15/logs/stdio https://autobuilder.yoctoproject.org/typhoon/#/builders/107/builds/6478/steps/14/logs/stdio https://autobuilder.yoctoproject.org/typhoon/#/builders/109/builds/8213/steps/14/logs/stdio https://autobuilder.yoctoproject.org/typhoon/#/builders/110/builds/8253/steps/14/logs/stdio Cheers, Richard
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}")
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