summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2017-11-22 16:00:17 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-12-02 11:25:33 +0000
commitd5f42075e6b344f2719e588da5aebd3ff4b4e6e0 (patch)
tree565fd86e672523ad0833e3906c207ffb7b0a6723 /meta/lib
parentd39a30177842e07a1c5037308a01d5e7dbc573a5 (diff)
downloadpoky-d5f42075e6b344f2719e588da5aebd3ff4b4e6e0.tar.gz
oeqa/selftest/runtime_test: simplify postinst testing
Update the packages and file names to reflect the new postinst recipe. Fix a sh syntax error in the run_serial file exists test which was hidden by a logic problem in the status code. Remove the older test_verify_postinst as it's effectively a subset of test_postinst_rootfs_and_boot, and doesn't work: when booting under systemd the strings it searches for are not output to the console, but the test still passes. (From OE-Core rev: 781a1be88f5812157a231bf5771a01bb978bfcd9) 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/cases/runtime_test.py82
1 files changed, 19 insertions, 63 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index 25270b7535..1c69255b56 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -167,55 +167,6 @@ class TestImage(OESelftestTestCase):
167 167
168class Postinst(OESelftestTestCase): 168class Postinst(OESelftestTestCase):
169 @OETestID(1540) 169 @OETestID(1540)
170 def test_verify_postinst(self):
171 """
172 Summary: The purpose of this test is to verify the execution order of postinst Bugzilla ID: [5319]
173 Expected :
174 1. Compile a minimal image.
175 2. The compiled image will add the created layer with the recipes postinst[ abdpt]
176 3. Run qemux86
177 4. Validate the task execution order
178 Author: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>
179 """
180 features = 'INHERIT += "testimage"\n'
181 features += 'CORE_IMAGE_EXTRA_INSTALL += "postinst-at-rootfs \
182postinst-delayed-a \
183postinst-delayed-b \
184postinst-delayed-d \
185postinst-delayed-p \
186postinst-delayed-t \
187"\n'
188 self.write_config(features)
189
190 bitbake('core-image-minimal -f ')
191
192 postinst_list = ['100-postinst-at-rootfs',
193 '101-postinst-delayed-a',
194 '102-postinst-delayed-b',
195 '103-postinst-delayed-d',
196 '104-postinst-delayed-p',
197 '105-postinst-delayed-t']
198 path_workdir = get_bb_var('WORKDIR','core-image-minimal')
199 workspacedir = 'testimage/qemu_boot_log'
200 workspacedir = os.path.join(path_workdir, workspacedir)
201 rexp = re.compile("^Running postinst .*/(?P<postinst>.*)\.\.\.$")
202 with runqemu('core-image-minimal') as qemu:
203 with open(workspacedir) as f:
204 found = False
205 idx = 0
206 for line in f.readlines():
207 line = line.strip().replace("^M","")
208 if not line: # To avoid empty lines
209 continue
210 m = rexp.search(line)
211 if m:
212 self.assertEqual(postinst_list[idx], m.group('postinst'), "Fail")
213 idx = idx+1
214 found = True
215 elif found:
216 self.assertEqual(idx, len(postinst_list), "Not found all postinsts")
217 break
218
219 @OETestID(1545) 170 @OETestID(1545)
220 def test_postinst_rootfs_and_boot(self): 171 def test_postinst_rootfs_and_boot(self):
221 """ 172 """
@@ -234,16 +185,22 @@ postinst-delayed-t \
234 for initialization managers: sysvinit and systemd. 185 for initialization managers: sysvinit and systemd.
235 186
236 """ 187 """
237 file_rootfs_name = "this-was-created-at-rootfstime" 188
238 fileboot_name = "this-was-created-at-first-boot" 189 import oe.path
239 rootfs_pkg = 'postinst-at-rootfs' 190
240 boot_pkg = 'postinst-delayed-a' 191 vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal")
192 rootfs = vars["IMAGE_ROOTFS"]
193 self.assertIsNotNone(rootfs)
194 sysconfdir = vars["sysconfdir"]
195 self.assertIsNotNone(sysconfdir)
196 # Need to use oe.path here as sysconfdir starts with /
197 hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test")
198 targettestdir = os.path.join(sysconfdir, "postinst-test")
241 199
242 for init_manager in ("sysvinit", "systemd"): 200 for init_manager in ("sysvinit", "systemd"):
243 for classes in ("package_rpm", "package_deb", "package_ipk"): 201 for classes in ("package_rpm", "package_deb", "package_ipk"):
244 with self.subTest(init_manager=init_manager, package_class=classes): 202 with self.subTest(init_manager=init_manager, package_class=classes):
245 features = 'MACHINE = "qemux86"\n' 203 features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-delayed-b"\n'
246 features += 'CORE_IMAGE_EXTRA_INSTALL += "%s %s "\n'% (rootfs_pkg, boot_pkg)
247 features += 'IMAGE_FEATURES += "package-management empty-root-password"\n' 204 features += 'IMAGE_FEATURES += "package-management empty-root-password"\n'
248 features += 'PACKAGE_CLASSES = "%s"\n' % classes 205 features += 'PACKAGE_CLASSES = "%s"\n' % classes
249 if init_manager == "systemd": 206 if init_manager == "systemd":
@@ -255,13 +212,12 @@ postinst-delayed-t \
255 212
256 bitbake('core-image-minimal') 213 bitbake('core-image-minimal')
257 214
258 file_rootfs_created = os.path.join(get_bb_var('IMAGE_ROOTFS', "core-image-minimal"), 215 self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs")),
259 file_rootfs_name) 216 "rootfs state file was not created")
260 found = os.path.isfile(file_rootfs_created)
261 self.assertTrue(found, "File %s was not created at rootfs time by %s" % \
262 (file_rootfs_name, rootfs_pkg))
263 217
264 testcommand = 'ls /etc/' + fileboot_name
265 with runqemu('core-image-minimal') as qemu: 218 with runqemu('core-image-minimal') as qemu:
266 status, output = qemu.run_serial("-f /etc/" + fileboot_name) 219 # Make the test echo a string and search for that as
267 self.assertEqual(status, 0, 'File %s was not created at first boot (%s)' % (fileboot_name, output)) 220 # run_serial()'s status code is useless.'
221 for filename in ("rootfs", "delayed-a", "delayed-b"):
222 status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
223 self.assertEqual(output, "found", "%s was not present on boot" % filename)