summaryrefslogtreecommitdiffstats
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 10:23:23 +0000
commit333890953db568118b34692e9beb15c3c8eecdd0 (patch)
tree0a94b063b245689f57c928e67c21098012632a62
parent23d1c4ffb7791e2f75f0eaa84dd6b936d3b861f7 (diff)
downloadpoky-333890953db568118b34692e9beb15c3c8eecdd0.tar.gz
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. (From OE-Core rev: 82b171f3b37e6733997fc1e7685b7cac5a3476e7) Signed-off-by: Jose Perez Carranza <jose.perez.carranza@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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"
24# Main recipe post-install 24# Main recipe post-install
25pkg_postinst_${PN}-at-rootfs () { 25pkg_postinst_${PN}-at-rootfs () {
26 tfile="/etc/postinsta-test" 26 tfile="/etc/postinsta-test"
27 touch "$D"/this-was-created-at-rootfstime
27 if test "x$D" != "x" then 28 if test "x$D" != "x" then
28 # Need to run on first boot 29 # Need to run on first boot
29 exit 1 30 exit 1
@@ -42,6 +43,7 @@ pkg_postinst_${PN}-delayed-a () {
42 # Need to run on first boot 43 # Need to run on first boot
43 exit 1 44 exit 1
44 else 45 else
46 touch /etc/this-was-created-at-first-boot
45 if test -e $efile ; then 47 if test -e $efile ; then
46 echo 'success' > $tfile 48 echo 'success' > $tfile
47 else 49 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 \
155 elif found: 155 elif found:
156 self.assertEqual(idx, len(postinst_list), "Not found all postinsts") 156 self.assertEqual(idx, len(postinst_list), "Not found all postinsts")
157 break 157 break
158
159 @testcase(1545)
160 def test_postinst_roofs_and_boot(self):
161 """
162 Summary: The purpose of this test case is to verify Post-installation
163 scripts are called when roofs is created and also test
164 that script can be delayed to run at first boot.
165 Dependencies: NA
166 Steps: 1. Add proper configuration to local.conf file
167 2. Build a "core-image-full-cmdline" image
168 3. Verify that file created by postinst_rootfs recipe is
169 present on rootfs dir.
170 4. Boot the image created on qemu and verify that the file
171 created by postinst_boot recipe is present on image.
172 5. Clean the packages and image created to test with
173 different package managers
174 Expected: The files are successfully created during rootfs and boot
175 time for 3 different package managers: rpm,ipk,deb and
176 for initialization managers: sysvinit and systemd.
177
178 """
179 file_rootfs_name = "this-was-created-at-rootfstime"
180 fileboot_name = "this-was-created-at-first-boot"
181 rootfs_pkg = 'postinst-at-rootfs'
182 boot_pkg = 'postinst-delayed-a'
183 #Step 1
184 features = 'MACHINE = "qemux86"\n'
185 features += 'CORE_IMAGE_EXTRA_INSTALL += "%s %s "\n'% (rootfs_pkg, boot_pkg)
186 for init_manager in ("sysvinit", "systemd"):
187 #for sysvinit no extra configuration is needed,
188 if (init_manager is "systemd"):
189 features += 'DISTRO_FEATURES_append = " systemd"\n'
190 features += 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
191 features += 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n'
192 features += 'VIRTUAL-RUNTIME_initscripts = ""\n'
193 for classes in ("package_rpm package_deb package_ipk",
194 "package_deb package_rpm package_ipk",
195 "package_ipk package_deb package_rpm"):
196 features += 'PACKAGE_CLASSES = "%s"\n' % classes
197 self.write_config(features)
198
199 #Step 2
200 bitbake('core-image-full-cmdline')
201
202 #Step 3
203 file_rootfs_created = os.path.join(get_bb_var('IMAGE_ROOTFS',"core-image-full-cmdline"),
204 file_rootfs_name)
205 found = os.path.isfile(file_rootfs_created)
206 self.assertTrue(found, "File %s was not created at rootfs time by %s" % \
207 (file_rootfs_name, rootfs_pkg))
208
209 #Step 4
210 testcommand = 'ls /etc/'+fileboot_name
211 with runqemu('core-image-full-cmdline') as qemu:
212 sshargs = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
213 result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand))
214 self.assertEqual(result.status, 0, 'File %s was not created at firts boot'% fileboot_name)
215
216 #Step 5
217 bitbake(' %s %s -c cleanall' % (rootfs_pkg, boot_pkg))
218 bitbake('core-image-full-cmdline -c cleanall')