diff options
-rw-r--r-- | meta-selftest/recipes-test/selftest-chown/selftest-chown.bb | 25 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/package.py | 23 |
2 files changed, 48 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/selftest-chown/selftest-chown.bb b/meta-selftest/recipes-test/selftest-chown/selftest-chown.bb new file mode 100644 index 0000000000..87bf9438b8 --- /dev/null +++ b/meta-selftest/recipes-test/selftest-chown/selftest-chown.bb | |||
@@ -0,0 +1,25 @@ | |||
1 | SUMMARY = "selftest chown" | ||
2 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
3 | |||
4 | LICENSE = "MIT" | ||
5 | |||
6 | S = "${WORKDIR}" | ||
7 | |||
8 | inherit useradd allarch | ||
9 | |||
10 | USERADD_PACKAGES = "${PN}" | ||
11 | USERADD_PARAM_${PN} = "-u 1234 -M test" | ||
12 | TESTDIR = "${D}${sysconfdir}/selftest-chown" | ||
13 | |||
14 | do_install() { | ||
15 | install -d ${TESTDIR} | ||
16 | install -d ${TESTDIR}/dir | ||
17 | touch ${TESTDIR}/file | ||
18 | ln -s ./file ${TESTDIR}/symlink | ||
19 | |||
20 | chown test:test ${TESTDIR}/file | ||
21 | chown -R test:test ${TESTDIR}/dir | ||
22 | chown -h test:test ${TESTDIR}/symlink | ||
23 | } | ||
24 | |||
25 | FILES_${PN} = "${sysconfdir}/selftest-chown/*" | ||
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) | ||