summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Perez Carranza <jose.perez.carranza@linux.intel.com>2016-12-06 11:29:01 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-16 08:30:01 +0000
commit82b171f3b37e6733997fc1e7685b7cac5a3476e7 (patch)
tree23568f21db11479249723275de91d69935955976
parenta8ff789a3bfedcbc4358db7907a45270d8b1b76a (diff)
downloadopenembedded-core-82b171f3b37e6733997fc1e7685b7cac5a3476e7.tar.gz
openembedded-core-82b171f3b37e6733997fc1e7685b7cac5a3476e7.tar.bz2
openembedded-core-82b171f3b37e6733997fc1e7685b7cac5a3476e7.zip
postinst: Add a test case to verify postinst scripts behavior
Add test case that verify behavior of postinst scripts at roofts time and when is delayed to the first boot directly on the target. Signed-off-by: Jose Perez Carranza <jose.perez.carranza@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--meta-selftest/recipes-test/postinst/postinst_1.0.bb2
-rw-r--r--meta/lib/oeqa/selftest/runtime-test.py61
2 files changed, 63 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
index 97a1987305..6d49734277 100644
--- a/meta-selftest/recipes-test/postinst/postinst_1.0.bb
+++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
@@ -24,6 +24,7 @@ RDEPENDS_${PN}-delayed-t = "${PN}-delayed-p"
# Main recipe post-install
pkg_postinst_${PN}-at-rootfs () {
tfile="/etc/postinsta-test"
+ touch "$D"/this-was-created-at-rootfstime
if test "x$D" != "x" then
# Need to run on first boot
exit 1
@@ -42,6 +43,7 @@ pkg_postinst_${PN}-delayed-a () {
# Need to run on first boot
exit 1
else
+ touch /etc/this-was-created-at-first-boot
if test -e $efile ; then
echo 'success' > $tfile
else
diff --git a/meta/lib/oeqa/selftest/runtime-test.py b/meta/lib/oeqa/selftest/runtime-test.py
index 1dbfae1106..20caa97d16 100644
--- a/meta/lib/oeqa/selftest/runtime-test.py
+++ b/meta/lib/oeqa/selftest/runtime-test.py
@@ -155,3 +155,64 @@ postinst-delayed-t \
elif found:
self.assertEqual(idx, len(postinst_list), "Not found all postinsts")
break
+
+ @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-at-rootfs'
+ boot_pkg = 'postinst-delayed-a'
+ #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,
+ if (init_manager is "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')