Re: execute pkg_postinst_ontarget when read-only-rootfs-delayed-postinsts is set for a read only rootfs
"Gassner, Tobias.ext" <[email protected]>
| Newsgroups | org.yoctoproject.lists.poky |
|---|---|
| Message-ID | <[email protected]> |
Hi Alex, I wrote a test in meta/lib/oeqa/selftest/cases/buildoptions.py that fails without my patch and passes with my patch. Please review if the test as specified makes sense to you: From e125ef8504a83cedd014d275387a16f519880eb5 Mon Sep 17 00:00:00 2001 From: "Gassner, Tobias.ext" <[email protected]> Date: Tue, 2 Jul 2024 14:53:04 +0200 Subject: [PATCH] Test that pkg_postinst_ontarget task is executed on read-only-rootfs, when read-only-rootfs-delayed-postinsts is specified Signed-off-by: Gassner, Tobias.ext <[email protected]> --- meta/lib/oeqa/selftest/cases/buildoptions.py | 39 +++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/cases/buildoptions.py b/meta/lib/oeqa/selftest/cases/buildoptions.py index 31dafaa9c5..f166de89dd 100644 --- a/meta/lib/oeqa/selftest/cases/buildoptions.py +++ b/meta/lib/oeqa/selftest/cases/buildoptions.py @@ -12,7 +12,7 @@ import tempfile from oeqa.selftest.case import OESelftestTestCase from oeqa.selftest.cases.buildhistory import BuildhistoryBase from oeqa.core.decorator.data import skipIfMachine -from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars +from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu import oeqa.utils.ftools as ftools from oeqa.core.decorator import OETestTag @@ -59,6 +59,43 @@ class ImageOptionsTests(OESelftestTestCase): bitbake("core-image-sato core-image-weston") # do_image will fail if there are any pending postinsts + def test_postinst_ontarget_executes_on_read_only_image(self): + # Test checks that pkg_postinst_ontarget task is executed even + # for read-only-rootfs, when read-only-rootfs-delayed-postinsts + # is specified as well + + # Define a recipe that touches a file in its postinst ontarget step + emptytest_inc = """ +SUMMARY = "summary" +DESCRIPTION = "description" +LICENSE:forcevariable = "CLOSED" + +ALLOW_EMPTY:${PN} = "1" + +inherit allarch + +pkg_postinst_ontarget:${PN} () { + touch /tmp/ro_rootfs_postinst_ontarget +} +""" + + self.write_recipeinc('emptytest', emptytest_inc) + + # Make rootfs read-only, but allow postinst ontarget task + self.write_config('IMAGE_FEATURES += "read-only-rootfs"') + self.append_config('IMAGE_FEATURES += "read-only-rootfs-delayed-postinsts"') + + self.append_config('IMAGE_INSTALL:append = " emptytest"') + + self.append_config('INIT_MANAGER = "systemd"') + + bitbake("core-image-minimal") + + with runqemu('core-image-minimal') as qemu: + # Check that the file, touched in postinst ontarget task exists + status, output = qemu.run_serial("[ -f /tmp/ro_rootfs_postinst_ontarget ] && echo 1 || echo 0") + self.assertTrue("1" in output, msg=output) + class DiskMonTest(OESelftestTestCase): def test_stoptask_behavior(self): -- 2.45.2