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 moved the test to meta/lib/oeqa/selftest/cases/runtime_test.py, please review the following patch: From 69685cc1bf4fa97e1105ce336c08e30a09834c4c Mon Sep 17 00:00:00 2001 From: "Gassner, Tobias.ext" <[email protected]> Date: Thu, 4 Jul 2024 12:48:20 +0200 Subject: [PATCH] added test case to verify that post-installation on target scripts are executed even if using read-only rootfs when read-only-rootfs-delayed-postinsts is set Signed-off-by: Gassner, Tobias.ext <[email protected]> --- .../recipes-test/postinst/postinst_1.0.bb | 18 ++++++++++- meta/lib/oeqa/selftest/cases/runtime_test.py | 30 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb index b936c4f44b..000ea24208 100644 --- a/meta-selftest/recipes-test/postinst/postinst_1.0.bb +++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb @@ -3,12 +3,13 @@ LICENSE = "MIT" inherit allarch -PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-rootfs-failing" +PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-rootfs-failing ${PN}-tmp" ALLOW_EMPTY:${PN}-rootfs = "1" ALLOW_EMPTY:${PN}-delayed-a = "1" ALLOW_EMPTY:${PN}-delayed-b = "1" ALLOW_EMPTY:${PN}-rootfs-failing = "1" +ALLOW_EMPTY:${PN}-tmp = "1" RDEPENDS:${PN}-delayed-a = "${PN}-rootfs" RDEPENDS:${PN}-delayed-b = "${PN}-delayed-a" @@ -70,3 +71,18 @@ pkg_postinst:${PN}-rootfs-failing () { # (oe-selftest checks for it). touch $D${TESTDIR}/rootfs-after-failure } + +# This scriptlet is used by a test that configures a read-only rootfs, +# however, writing in /tmp is still possible. +pkg_postinst_ontarget:${PN}-tmp () { + set -e + + TESTFILE='/tmp/postinst_tmp' + + if [ -e ${TESTFILE} ]; then + echo "${PN}-tmp: ${TESTFILE} does already exist" + exit 1 + fi + + touch ${TESTFILE} +} \ No newline at end of file diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py index 12000aac16..5b097e5f92 100644 --- a/meta/lib/oeqa/selftest/cases/runtime_test.py +++ b/meta/lib/oeqa/selftest/cases/runtime_test.py @@ -407,6 +407,36 @@ class Postinst(OESelftestTestCase): self.assertFalse(os.path.isfile(os.path.join(hosttestdir, "rootfs-after-failure")), "rootfs-after-failure file was created") + + def test_postinst_on_target_for_read_only_rootfs(self): + """ + Summary: The purpose of this test case is to verify that post-installation + on target scripts are executed even if using read-only rootfs when + read-only-rootfs-delayed-postinsts is set + Expected: The test file in /tmp is created on first boot + Product: oe-core + """ + + for classes in ("package_rpm", "package_deb", "package_ipk"): + with self.subTest(package_class=classes): + features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-tmp"\n' + features += 'IMAGE_FEATURES += "package-management empty-root-password"\n' + features += 'PACKAGE_CLASSES = "%s"\n' % classes + features += 'INIT_MANAGER = "systemd"\n' + + features += 'IMAGE_FEATURES += "read-only-rootfs"\n' + features += 'IMAGE_FEATURES += "read-only-rootfs-delayed-postinsts"\n' + + self.write_config(features) + + bitbake('core-image-minimal') + + with runqemu('core-image-minimal') as qemu: + testfile = "/tmp/postinst_tmp" + status, output = qemu.run_serial("test -f %s && echo found" % testfile) + self.assertIn("found", output, "%s was not present on boot" % testfile) + + @OETestTag("runqemu") class SystemTap(OESelftestTestCase): """ -- 2.45.2