summaryrefslogtreecommitdiffstats
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:40 +0000
commit31926bd1c10bf7a7581c54d90739be9d0ce570df (patch)
treed63195b6ad0013dc15190230f27a3a29a1af04d7
parent8e72283f546e5ce99b05e1482b55cf5af7ae5f37 (diff)
downloadpoky-31926bd1c10bf7a7581c54d90739be9d0ce570df.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. (From OE-Core rev: a26fc7c2119df12468b0a834de6fe67aa9c86085) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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):
153 self.fail('GDB %s failed' % binary) 153 self.fail('GDB %s failed' % binary)
154 154
155 def test_preserve_ownership(self): 155 def test_preserve_ownership(self):
156 import os, stat, oe.cachedpath
157 features = 'IMAGE_INSTALL:append = " selftest-chown"\n' 156 features = 'IMAGE_INSTALL:append = " selftest-chown"\n'
158 self.write_config(features) 157 self.write_config(features)
159 bitbake("core-image-minimal") 158 bitbake("core-image-minimal")
160 159
161 sysconfdir = get_bb_var('sysconfdir', 'selftest-chown') 160 def check_ownership(qemu, expected_gid, expected_uid, path):
162 def check_ownership(qemu, gid, uid, path):
163 self.logger.info("Check ownership of %s", path) 161 self.logger.info("Check ownership of %s", path)
164 status, output = qemu.run_serial(r'/bin/stat -c "%U %G" ' + path, timeout=60) 162 status, output = qemu.run_serial('stat -c "%U %G" ' + path)
165 output = output.split(" ") 163 self.assertEqual(status, 1, "stat failed: " + output)
166 if output[0] != uid or output[1] != gid : 164 try:
167 self.logger.error("Incrrect ownership %s [%s:%s]", path, output[0], output[1]) 165 uid, gid = output.split()
168 return False 166 self.assertEqual(uid, expected_uid)
169 return True 167 self.assertEqual(gid, expected_gid)
168 except ValueError:
169 self.fail("Cannot parse output: " + output)
170 170
171 sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
171 with runqemu('core-image-minimal') as qemu: 172 with runqemu('core-image-minimal') as qemu:
172 for path in [ sysconfdir + "/selftest-chown/file", 173 for path in [ sysconfdir + "/selftest-chown/file",
173 sysconfdir + "/selftest-chown/dir", 174 sysconfdir + "/selftest-chown/dir",
174 sysconfdir + "/selftest-chown/symlink", 175 sysconfdir + "/selftest-chown/symlink",
175 sysconfdir + "/selftest-chown/fifotest/fifo"]: 176 sysconfdir + "/selftest-chown/fifotest/fifo"]:
176 if not check_ownership(qemu, "test", "test", path): 177 check_ownership(qemu, "test", "test", path)
177 self.fail('Test ownership %s failed' % path)