summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/package.py
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2022-11-09 19:31:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-11 13:43:37 +0000
commita26fc7c2119df12468b0a834de6fe67aa9c86085 (patch)
tree9f1ff57e6748660a9cf0526e8d0a797671a2421f /meta/lib/oeqa/selftest/cases/package.py
parentc51c12154851d04a81c8fbe190e712b3cd8dc941 (diff)
downloadopenembedded-core-a26fc7c2119df12468b0a834de6fe67aa9c86085.tar.gz
oeqa/selftest/package: improve test_preserve_ownership
This test was failing very oddly in qemuarm64 runs. Rewriting the test to be clearer and less fragile fixed it. Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/package.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/package.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/meta/lib/oeqa/selftest/cases/package.py b/meta/lib/oeqa/selftest/cases/package.py
index 482a7c02ad..4f7cd10658 100644
--- a/meta/lib/oeqa/selftest/cases/package.py
+++ b/meta/lib/oeqa/selftest/cases/package.py
@@ -153,25 +153,25 @@ class PackageTests(OESelftestTestCase):
self.fail('GDB %s failed' % binary)
def test_preserve_ownership(self):
- import os, stat, oe.cachedpath
features = 'IMAGE_INSTALL:append = " selftest-chown"\n'
self.write_config(features)
bitbake("core-image-minimal")
- sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
- def check_ownership(qemu, gid, uid, path):
+ def check_ownership(qemu, expected_gid, expected_uid, path):
self.logger.info("Check ownership of %s", path)
- status, output = qemu.run_serial(r'/bin/stat -c "%U %G" ' + path, timeout=60)
- output = output.split(" ")
- if output[0] != uid or output[1] != gid :
- self.logger.error("Incrrect ownership %s [%s:%s]", path, output[0], output[1])
- return False
- return True
+ status, output = qemu.run_serial('stat -c "%U %G" ' + path)
+ self.assertEqual(status, 1, "stat failed: " + output)
+ try:
+ uid, gid = output.split()
+ self.assertEqual(uid, expected_uid)
+ self.assertEqual(gid, expected_gid)
+ except ValueError:
+ self.fail("Cannot parse output: " + output)
+ sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
with runqemu('core-image-minimal') as qemu:
for path in [ sysconfdir + "/selftest-chown/file",
sysconfdir + "/selftest-chown/dir",
sysconfdir + "/selftest-chown/symlink",
sysconfdir + "/selftest-chown/fifotest/fifo"]:
- if not check_ownership(qemu, "test", "test", path):
- self.fail('Test ownership %s failed' % path)
+ check_ownership(qemu, "test", "test", path)