summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Lock <joshua.g.lock@intel.com>2016-09-01 17:26:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-03 09:58:31 +0100
commit2b047b8e3218f95978e41fee13635bff9af03dd6 (patch)
tree8a62e4aed4f3d3e1087af9083aff627413ff0741
parente591d69103a40ec4f76d1132a6039d9cb1555103 (diff)
downloadopenembedded-core-2b047b8e3218f95978e41fee13635bff9af03dd6.tar.gz
openembedded-core-2b047b8e3218f95978e41fee13635bff9af03dd6.tar.bz2
openembedded-core-2b047b8e3218f95978e41fee13635bff9af03dd6.zip
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 <joshua.g.lock@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/liboe.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/liboe.py b/meta/lib/oeqa/selftest/liboe.py
index 454b92a3b7..5c93069b5d 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,34 @@ 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 <joshua.g.lock@intel.com>
+ """
+ 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")
+ bindir = get_bb_var('STAGING_BINDIR_NATIVE')
+
+ # create a file with xattr and copy it
+ open(oe.path.join(src, testfilename), 'w+b').close()
+ runCmd('%s/setfattr -n user.oetest -v "testing liboe" %s' % (bindir, oe.path.join(src, testfilename)))
+ oe.path.copytree(src, dst)
+
+ # ensure file in dest has user.oetest xattr
+ result = runCmd('%s/getfattr -n user.oetest %s' % (bindir, oe.path.join(dst, testfilename)))
+ self.assertIn('user.oetest="testing liboe"', result.output, 'Extended attribute not sert in dst')
+
+ oe.path.remove(testloc)