diff options
author | Jose Perez Carranza <jose.perez.carranza@linux.intel.com> | 2016-12-06 11:29:01 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-16 10:23:23 +0000 |
commit | 333890953db568118b34692e9beb15c3c8eecdd0 (patch) | |
tree | 0a94b063b245689f57c928e67c21098012632a62 /meta/lib | |
parent | 23d1c4ffb7791e2f75f0eaa84dd6b936d3b861f7 (diff) | |
download | poky-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>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/runtime-test.py | 61 |
1 files changed, 61 insertions, 0 deletions
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') | ||