Re: [poky] execute pkg_postinst_ontarget when read-only-rootfs-delayed-postinsts is set for a read only rootfs

Alexander Kanavin <[email protected]>
Newsgroups org.yoctoproject.lists.poky
Message-ID <CANNYZj8MvP3C8++HT03wUgNA9vkDtjUMGRqjhPAiJ7EA4PtxOw@mail.gmail.com>
Hello Tobias, the test is basically ok, but I looked a bit further,
and I think there should be improvements:

- there is already meta-selftest/recipes-test/postinst/postinst_1.0.bb
for the purpose of testing postinsts, the test should be using that
instead of writing out its own recipe
- that recipe is used in meta/lib/oeqa/selftest/cases/runtime_test.py
so I think that's actually the correct place for the test,
specifically in Postinst class.

Alex

On Tue, 2 Jul 2024 at 15:08, Gassner, Tobias.ext via
lists.yoctoproject.org
<[email protected]> wrote:
>
> 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
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#13401): https://lists.yoctoproject.org/g/poky/message/13401
> Mute This Topic: https://lists.yoctoproject.org/mt/106869018/1686489
> Group Owner: [email protected]
> Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [[email protected]]
> -=-=-=-=-=-=-=-=-=-=-=-
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.