summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorDaisuke Yamane <daisuke.yamane@cybertrust.co.jp>2020-03-14 13:09:42 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-26 14:00:50 +0100
commitcaa530a277fd67cb88a077dddcad4b60911cf332 (patch)
tree9b06ae1e9ab520e0a3e49e00acd733ec47300687 /meta
parent6efa038c01e42af7602f805b9035df7ab4e0df73 (diff)
downloadpoky-caa530a277fd67cb88a077dddcad4b60911cf332.tar.gz
selftest/package: Add test to ensure ownership is preserved
Yocto Bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13806 Add test_preserve_ownership to selftest/package. This test creates a file, a directory and a symbolic link and changes ownership, then compares with them installed in rootfs to ensure ownership is preserved. [Test without a commit 'bitbake: lib/bb/utils.py: Preserve ownership of symlink'] | 2020-03-14 10:01:14,519 - oe-selftest - INFO - test_preserve_ownership (package.PackageTests) | 2020-03-14 10:56:44,612 - oe-selftest - INFO - Check ownership of /etc/selftest-chown/file | 2020-03-14 10:56:44,770 - oe-selftest - INFO - Check ownership of /etc/selftest-chown/dir | 2020-03-14 10:56:44,822 - oe-selftest - INFO - Check ownership of /etc/selftest-chown/symlink | 2020-03-14 10:56:44,879 - oe-selftest - ERROR - Incrrect ownership /etc/selftest-chown/symlink [root:root] | 2020-03-14 10:56:45,884 - oe-selftest - INFO - ... FAIL [Test with a commit 'bitbake: lib/bb/utils.py: Preserve ownership of symlink'] | 2020-03-14 10:58:49,599 - oe-selftest - INFO - test_preserve_ownership (package.PackageTests) | 2020-03-14 11:51:39,947 - oe-selftest - INFO - Check ownership of /etc/selftest-chown/file | 2020-03-14 11:51:40,013 - oe-selftest - INFO - Check ownership of /etc/selftest-chown/dir | 2020-03-14 11:51:40,063 - oe-selftest - INFO - Check ownership of /etc/selftest-chown/symlink | 2020-03-14 11:51:41,118 - oe-selftest - INFO - ... ok (From OE-Core rev: 88c1824468109d0f78d5fee7b71baa1f3944db7f) Signed-off-by: Daisuke Yamane <daisuke.yamane@cybertrust.co.jp> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/cases/package.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/package.py b/meta/lib/oeqa/selftest/cases/package.py
index b87f8dc3e2..3010b1af49 100644
--- a/meta/lib/oeqa/selftest/cases/package.py
+++ b/meta/lib/oeqa/selftest/cases/package.py
@@ -148,3 +148,26 @@ class PackageTests(OESelftestTestCase):
148 '/usr/libexec/hello4']: 148 '/usr/libexec/hello4']:
149 if not gdbtest(qemu, binary): 149 if not gdbtest(qemu, binary):
150 self.fail('GDB %s failed' % binary) 150 self.fail('GDB %s failed' % binary)
151
152 def test_preserve_ownership(self):
153 import os, stat, oe.cachedpath
154 features = 'IMAGE_INSTALL_append = " selftest-chown"\n'
155 self.write_config(features)
156 bitbake("core-image-minimal")
157
158 sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
159 def check_ownership(qemu, gid, uid, path):
160 self.logger.info("Check ownership of %s", path)
161 status, output = qemu.run_serial(r'/bin/stat -c "%U %G" ' + path, timeout=60)
162 output = output.split(" ")
163 if output[0] != uid or output[1] != gid :
164 self.logger.error("Incrrect ownership %s [%s:%s]", path, output[0], output[1])
165 return False
166 return True
167
168 with runqemu('core-image-minimal') as qemu:
169 for path in [ sysconfdir + "/selftest-chown/file",
170 sysconfdir + "/selftest-chown/dir",
171 sysconfdir + "/selftest-chown/symlink"]:
172 if not check_ownership(qemu, "test", "test", path):
173 self.fail('Test ownership %s failed' % path)