summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2018-03-12 18:49:43 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-15 06:27:18 -0700
commit682705389526fba41ef8763d290ea4cab8787e43 (patch)
tree95ec95f772e6f04cd8d792e7ef0dfb54695ba75e /meta/lib/oeqa
parentcd005e2d5bab8bc7cf4fd8b66c0bcc0328a0decd (diff)
downloadpoky-682705389526fba41ef8763d290ea4cab8787e43.tar.gz
oe-selftest: add a test for failing package post-installation scriptlets
The test runs a scriptlet that has an intentionally failing command in the middle and checks for two things: 1) that bitbake does warn the user about the failure 2) that scriptlet execution stops at that point. The test is run for all three package types: rpm, deb, ipk. (From OE-Core rev: 865fafb0dff19d27bd417c28c95fb8fdf0326a2b) Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/selftest/cases/runtime_test.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index 1c69255b56..9c9b4b3411 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -221,3 +221,40 @@ class Postinst(OESelftestTestCase):
221 for filename in ("rootfs", "delayed-a", "delayed-b"): 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)) 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) 223 self.assertEqual(output, "found", "%s was not present on boot" % filename)
224
225
226
227 def test_failing_postinst(self):
228 """
229 Summary: The purpose of this test case is to verify that post-installation
230 scripts that contain errors are properly reported.
231 Expected: The scriptlet failure is properly reported.
232 The file that is created after the error in the scriptlet is not present.
233 Product: oe-core
234 Author: Alexander Kanavin <alexander.kanavin@intel.com>
235 """
236
237 import oe.path
238
239 vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal")
240 rootfs = vars["IMAGE_ROOTFS"]
241 self.assertIsNotNone(rootfs)
242 sysconfdir = vars["sysconfdir"]
243 self.assertIsNotNone(sysconfdir)
244 # Need to use oe.path here as sysconfdir starts with /
245 hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test")
246
247 for classes in ("package_rpm", "package_deb", "package_ipk"):
248 with self.subTest(package_class=classes):
249 features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-rootfs-failing"\n'
250 features += 'PACKAGE_CLASSES = "%s"\n' % classes
251 self.write_config(features)
252 bb_result = bitbake('core-image-minimal')
253 self.assertGreaterEqual(bb_result.output.find("Intentionally failing postinstall scriptlets of ['postinst-rootfs-failing'] to defer them to first boot is deprecated."), 0,
254 "Warning about a failed scriptlet not found in bitbake output: %s" %(bb_result.output))
255
256 self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs-before-failure")),
257 "rootfs-before-failure file was not created")
258 self.assertFalse(os.path.isfile(os.path.join(hosttestdir, "rootfs-after-failure")),
259 "rootfs-after-failure file was created")
260