]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
oe-selftest: devtool: use stat for reading user/group names in ide-sdk tests
authorAdrian Freihofer <adrian.freihofer@siemens.com>
Sun, 2 Aug 2026 19:52:49 +0000 (21:52 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 5 Aug 2026 13:38:55 +0000 (14:38 +0100)
On some systems, ls truncates long user and group names, which causes the
ownership check to fail. For example:

AssertionError: Regex didn't match:
  '^-.+ cmake-example cmake-example .+ /etc/cmake\\-example\\.conf$' not found in
  '-rw-r--r--    1 cmake-ex cmake-ex        83 Mar  9  2018 /etc/cmake-example.conf'

Use "stat -c '%U %G'" instead, which always returns the full user and group
names regardless of terminal width or system configuration.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oeqa/selftest/cases/devtool.py

index b138a5ef6f6fab3735ba52bb01fc9189e69e4056..2e91c2be971b0d25038c9f40a575730aba7d37cb 100644 (file)
@@ -3118,11 +3118,14 @@ class DevtoolIdeSdkTests(DevtoolBase):
 
     def _verify_conf_file(self, qemu, conf_file, owner, group):
         """Helper to verify a configuration file is owned by the proper user and group"""
-        ls_cmd = "ls -l %s" % conf_file
-        status, output = qemu.run(ls_cmd)
-        self.assertEqual(status, 0, msg="Failed to ls %s: %s" % (conf_file, output))
-        self.assertRegex(output, rf"^-.+ {owner} {group} .+ {re.escape(conf_file)}$",
-                         msg="%s not owned by %s:%s: %s" % (conf_file, owner, group, output))
+        stat_cmd = "stat -c '%%U %%G' %s" % conf_file
+        status, output = qemu.run(stat_cmd)
+        self.assertEqual(status, 0, msg="Failed to stat %s: %s" % (conf_file, output))
+        actual_owner, actual_group = output.strip().split()
+        self.assertEqual(actual_owner, owner,
+                         msg="%s not owned by user %s: got %s" % (conf_file, owner, actual_owner))
+        self.assertEqual(actual_group, group,
+                         msg="%s not owned by group %s: got %s" % (conf_file, group, actual_group))
 
     @OETestTag("runqemu")
     def test_devtool_ide_sdk_none_qemu(self):