summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/selftest/cases/runtime_test.py97
1 files changed, 62 insertions, 35 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index 7aa9fb25da..60cb2e01a6 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -10,6 +10,7 @@ import re
10import tempfile 10import tempfile
11import shutil 11import shutil
12import oe.lsb 12import oe.lsb
13from oeqa.core.decorator.data import skipIfNotQemu
13 14
14class TestExport(OESelftestTestCase): 15class TestExport(OESelftestTestCase):
15 16
@@ -243,7 +244,47 @@ class TestImage(OESelftestTestCase):
243 bitbake('-c testimage core-image-minimal') 244 bitbake('-c testimage core-image-minimal')
244 245
245class Postinst(OESelftestTestCase): 246class Postinst(OESelftestTestCase):
246 def test_postinst_rootfs_and_boot(self): 247
248 def init_manager_loop(self, init_manager):
249 import oe.path
250
251 vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal")
252 rootfs = vars["IMAGE_ROOTFS"]
253 self.assertIsNotNone(rootfs)
254 sysconfdir = vars["sysconfdir"]
255 self.assertIsNotNone(sysconfdir)
256 # Need to use oe.path here as sysconfdir starts with /
257 hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test")
258 targettestdir = os.path.join(sysconfdir, "postinst-test")
259
260 for classes in ("package_rpm", "package_deb", "package_ipk"):
261 with self.subTest(init_manager=init_manager, package_class=classes):
262 features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-delayed-b"\n'
263 features += 'IMAGE_FEATURES += "package-management empty-root-password"\n'
264 features += 'PACKAGE_CLASSES = "%s"\n' % classes
265 if init_manager == "systemd":
266 features += 'DISTRO_FEATURES_append = " systemd"\n'
267 features += 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
268 features += 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n'
269 features += 'VIRTUAL-RUNTIME_initscripts = ""\n'
270 self.write_config(features)
271
272 bitbake('core-image-minimal')
273
274 self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs")),
275 "rootfs state file was not created")
276
277 with runqemu('core-image-minimal') as qemu:
278 # Make the test echo a string and search for that as
279 # run_serial()'s status code is useless.'
280 for filename in ("rootfs", "delayed-a", "delayed-b"):
281 status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
282 self.assertEqual(output, "found", "%s was not present on boot" % filename)
283
284
285
286 @skipIfNotQemu('qemuall', 'Test only runs in qemu')
287 def test_postinst_rootfs_and_boot_sysvinit(self):
247 """ 288 """
248 Summary: The purpose of this test case is to verify Post-installation 289 Summary: The purpose of this test case is to verify Post-installation
249 scripts are called when rootfs is created and also test 290 scripts are called when rootfs is created and also test
@@ -257,46 +298,32 @@ class Postinst(OESelftestTestCase):
257 created by postinst_boot recipe is present on image. 298 created by postinst_boot recipe is present on image.
258 Expected: The files are successfully created during rootfs and boot 299 Expected: The files are successfully created during rootfs and boot
259 time for 3 different package managers: rpm,ipk,deb and 300 time for 3 different package managers: rpm,ipk,deb and
260 for initialization managers: sysvinit and systemd. 301 for initialization managers: sysvinit.
261 302
262 """ 303 """
304 self.init_manager_loop("sysvinit")
263 305
264 import oe.path
265 306
266 vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal") 307 @skipIfNotQemu('qemuall', 'Test only runs in qemu')
267 rootfs = vars["IMAGE_ROOTFS"] 308 def test_postinst_rootfs_and_boot_systemd(self):
268 self.assertIsNotNone(rootfs) 309 """
269 sysconfdir = vars["sysconfdir"] 310 Summary: The purpose of this test case is to verify Post-installation
270 self.assertIsNotNone(sysconfdir) 311 scripts are called when rootfs is created and also test
271 # Need to use oe.path here as sysconfdir starts with / 312 that script can be delayed to run at first boot.
272 hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test") 313 Dependencies: NA
273 targettestdir = os.path.join(sysconfdir, "postinst-test") 314 Steps: 1. Add proper configuration to local.conf file
315 2. Build a "core-image-minimal" image
316 3. Verify that file created by postinst_rootfs recipe is
317 present on rootfs dir.
318 4. Boot the image created on qemu and verify that the file
319 created by postinst_boot recipe is present on image.
320 Expected: The files are successfully created during rootfs and boot
321 time for 3 different package managers: rpm,ipk,deb and
322 for initialization managers: systemd.
274 323
275 for init_manager in ("sysvinit", "systemd"): 324 """
276 for classes in ("package_rpm", "package_deb", "package_ipk"):
277 with self.subTest(init_manager=init_manager, package_class=classes):
278 features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-delayed-b"\n'
279 features += 'IMAGE_FEATURES += "package-management empty-root-password"\n'
280 features += 'PACKAGE_CLASSES = "%s"\n' % classes
281 if init_manager == "systemd":
282 features += 'DISTRO_FEATURES_append = " systemd"\n'
283 features += 'VIRTUAL-RUNTIME_init_manager = "systemd"\n'
284 features += 'DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"\n'
285 features += 'VIRTUAL-RUNTIME_initscripts = ""\n'
286 self.write_config(features)
287
288 bitbake('core-image-minimal')
289
290 self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs")),
291 "rootfs state file was not created")
292
293 with runqemu('core-image-minimal') as qemu:
294 # Make the test echo a string and search for that as
295 # run_serial()'s status code is useless.'
296 for filename in ("rootfs", "delayed-a", "delayed-b"):
297 status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
298 self.assertEqual(output, "found", "%s was not present on boot" % filename)
299 325
326 self.init_manager_loop("systemd")
300 327
301 328
302 def test_failing_postinst(self): 329 def test_failing_postinst(self):