aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-selftest/recipes-test/postinst-boot/postinst-boot_1.0.bb12
-rw-r--r--meta-selftest/recipes-test/postinst-rootfs/postinst-rootfs_1.0.bb7
-rw-r--r--meta/lib/oeqa/selftest/runtime-test.py63
3 files changed, 82 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/postinst-boot/postinst-boot_1.0.bb b/meta-selftest/recipes-test/postinst-boot/postinst-boot_1.0.bb
new file mode 100644
index 00000000000..f42148ea637
--- /dev/null
+++ b/meta-selftest/recipes-test/postinst-boot/postinst-boot_1.0.bb
@@ -0,0 +1,12 @@
+LICENSE = "MIT"
+
+ALLOW_EMPTY_${PN} = "1"
+
+pkg_postinst_${PN} () {
+ if [ x"$D" = "x" ]; then
+ # Actions to carry out on the device go here
+ touch /etc/this-was-created-at-first-boot
+ else
+ exit 1
+ fi
+}
diff --git a/meta-selftest/recipes-test/postinst-rootfs/postinst-rootfs_1.0.bb b/meta-selftest/recipes-test/postinst-rootfs/postinst-rootfs_1.0.bb
new file mode 100644
index 00000000000..6461e0e6f5b
--- /dev/null
+++ b/meta-selftest/recipes-test/postinst-rootfs/postinst-rootfs_1.0.bb
@@ -0,0 +1,7 @@
+LICENSE = "MIT"
+
+ALLOW_EMPTY_${PN} = "1"
+
+pkg_postinst_${PN} () {
+ touch "$D"/this-was-created-at-rootfstime
+}
diff --git a/meta/lib/oeqa/selftest/runtime-test.py b/meta/lib/oeqa/selftest/runtime-test.py
index c2d5b45a4b1..94372f9a15b 100644
--- a/meta/lib/oeqa/selftest/runtime-test.py
+++ b/meta/lib/oeqa/selftest/runtime-test.py
@@ -103,3 +103,66 @@ class TestImage(oeSelfTest):
# Build core-image-sato and testimage
bitbake('core-image-full-cmdline socat')
bitbake('-c testimage core-image-full-cmdline')
+
+class Postinst(oeSelfTest):
+
+ @testcase(1545)
+ def test_postinst_roofs_and_boot(self):
+ """
+ Summary: The purpose of this test case is to verify Post-installation
+ scripts are called when roofs is created and also test
+ that script can be delayed to run at first boot.
+ Dependencies: NA
+ Steps: 1. Add proper configuration to local.conf file
+ 2. Build a "core-image-full-cmdline" image
+ 3. Verify that file created by postinst_rootfs recipe is
+ present on rootfs dir.
+ 4. Boot the image created on qemu and verify that the file
+ created by postinst_boot recipe is present on image.
+ 5. Clean the packages and image created to test with
+ different package managers
+ Expected: The files are successfully created during rootfs and boot
+ time for 3 different package managers: rpm,ipk,deb and
+ for initialization managers: sysvinit and systemd.
+
+ """
+ file_rootfs_name = "this-was-created-at-rootfstime"
+ fileboot_name = "this-was-created-at-first-boot"
+ rootfs_pkg = 'postinst-rootfs'
+ boot_pkg = 'postinst-boot'
+ #Step 1
+ features = 'MACHINE = "qemux86"\n'
+ features += 'CORE_IMAGE_EXTRA_INSTALL += "%s %s "\n'% (rootfs_pkg, boot_pkg)
+ for init_manager in ("sysvinit", "systemd"):
+ #for sysvinit no extra configuration is needed, hnece this executed
+ if (init_manager == "systemd"):
+ features += 'DISTRO_FEATURES_append = " systemd"\n'
+ features += 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
+ features += 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n'
+ features += 'VIRTUAL-RUNTIME_initscripts = ""\n'
+ for classes in ("package_rpm package_deb package_ipk",
+ "package_deb package_rpm package_ipk",
+ "package_ipk package_deb package_rpm"):
+ features += 'PACKAGE_CLASSES = "%s"\n' % classes
+ self.write_config(features)
+
+ #Step 2
+ bitbake('core-image-full-cmdline')
+
+ #Step 3
+ file_rootfs_created = os.path.join(get_bb_var('IMAGE_ROOTFS',"core-image-full-cmdline"),
+ file_rootfs_name)
+ found = os.path.isfile(file_rootfs_created)
+ self.assertTrue(found, "File %s was not created at rootfs time by %s" % \
+ (file_rootfs_name, rootfs_pkg))
+
+ #Step 4
+ testcommand = 'ls /etc/'+fileboot_name
+ with runqemu('core-image-full-cmdline') as qemu:
+ sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
+ result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand))
+ self.assertEqual(result.status, 0, 'File %s was not created at firts boot'% fileboot_name)
+
+ #Step 5
+ bitbake(' %s %s -c cleanall' % (rootfs_pkg, boot_pkg))
+ bitbake('core-image-full-cmdline -c cleanall')