From a3997696f72b05021e1f5b34ee419d7d94c3002a Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Tue, 30 Aug 2016 14:05:11 +0100 Subject: oeqa.selftest.liboe: add test for xattr in copytree Add a test to ensure that oe.path.copytree() preserves extended attributes on files. Signed-off-by: Joshua Lock Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/liboe.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/liboe.py b/meta/lib/oeqa/selftest/liboe.py index 454b92a3b7..2aeab614c6 100644 --- a/meta/lib/oeqa/selftest/liboe.py +++ b/meta/lib/oeqa/selftest/liboe.py @@ -1,5 +1,5 @@ from oeqa.selftest.base import oeSelfTest -from oeqa.utils.commands import get_bb_var +from oeqa.utils.commands import get_bb_var, bitbake, runCmd import oe.path import glob import os @@ -31,3 +31,33 @@ class LibOE(oeSelfTest): self.assertTrue(fileindst, "File with spaces doesn't exist in dst") oe.path.remove(testloc) + + def test_copy_tree_xattr(self): + """ + Summary: oe.path.copytree() should preserve xattr on copied files + Expected: testxattr file in destination should have user.oetest + extended attribute + Product: OE-Core + Author: Joshua Lock + """ + tmp_dir = get_bb_var('TMPDIR') + testloc = oe.path.join(tmp_dir, 'liboetests') + src = oe.path.join(testloc, 'src') + dst = oe.path.join(testloc, 'dst') + bb.utils.mkdirhier(testloc) + bb.utils.mkdirhier(src) + testfilename = 'testxattr' + + # ensure we have setfattr available + bitbake("attr-native") + + # create a file with xattr and copy it + open(oe.path.join(src, testfilename), 'w+b').close() + runCmd('setfattr -n user.oetest -v "testing liboe" %s' % oe.path.join(src, testfilename)) + oe.path.copytree(src, dst) + + # ensure file in dest has user.oetest xattr + result = runCmd('getfattr -n user.oetest %s' % oe.path.join(dst, testfilename)) + self.assertIn('user.oetest="testing liboe"', result.output, 'Extended attribute not sert in dst') + + oe.path.remove(testloc) -- cgit 1.2.3-korg