summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/liboe.py
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-05-12 14:40:21 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-06 19:02:43 +0100
commit157c3be2ca93f076033f725ec1ee912df91f7488 (patch)
tree8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/cases/liboe.py
parent10c512b60d1167122b5fe778b93838dca3def717 (diff)
downloadpoky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to support these. Changes include changes on base classes and decorators. Also include paths in selftest/__init__.py isn't needed because the loader is the standard unittest one. (From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/liboe.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/liboe.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/liboe.py b/meta/lib/oeqa/selftest/cases/liboe.py
new file mode 100644
index 0000000000..01b2cab7aa
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/liboe.py
@@ -0,0 +1,98 @@
1from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import get_bb_var, get_bb_vars, bitbake, runCmd
3import oe.path
4import os
5
6class LibOE(OESelftestTestCase):
7
8 @classmethod
9 def setUpClass(cls):
10 super(LibOE, cls).setUpClass()
11 cls.tmp_dir = get_bb_var('TMPDIR')
12
13 def test_copy_tree_special(self):
14 """
15 Summary: oe.path.copytree() should copy files with special character
16 Expected: 'test file with sp£c!al @nd spaces' should exist in
17 copy destination
18 Product: OE-Core
19 Author: Joshua Lock <joshua.g.lock@intel.com>
20 """
21 testloc = oe.path.join(self.tmp_dir, 'liboetests')
22 src = oe.path.join(testloc, 'src')
23 dst = oe.path.join(testloc, 'dst')
24 bb.utils.mkdirhier(testloc)
25 bb.utils.mkdirhier(src)
26 testfilename = 'test file with sp£c!al @nd spaces'
27
28 # create the test file and copy it
29 open(oe.path.join(src, testfilename), 'w+b').close()
30 oe.path.copytree(src, dst)
31
32 # ensure path exists in dest
33 fileindst = os.path.isfile(oe.path.join(dst, testfilename))
34 self.assertTrue(fileindst, "File with spaces doesn't exist in dst")
35
36 oe.path.remove(testloc)
37
38 def test_copy_tree_xattr(self):
39 """
40 Summary: oe.path.copytree() should preserve xattr on copied files
41 Expected: testxattr file in destination should have user.oetest
42 extended attribute
43 Product: OE-Core
44 Author: Joshua Lock <joshua.g.lock@intel.com>
45 """
46 testloc = oe.path.join(self.tmp_dir, 'liboetests')
47 src = oe.path.join(testloc, 'src')
48 dst = oe.path.join(testloc, 'dst')
49 bb.utils.mkdirhier(testloc)
50 bb.utils.mkdirhier(src)
51 testfilename = 'testxattr'
52
53 # ensure we have setfattr available
54 bitbake("attr-native")
55
56 bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'attr-native')
57 destdir = bb_vars['SYSROOT_DESTDIR']
58 bindir = bb_vars['bindir']
59 bindir = destdir + bindir
60
61 # create a file with xattr and copy it
62 open(oe.path.join(src, testfilename), 'w+b').close()
63 runCmd('%s/setfattr -n user.oetest -v "testing liboe" %s' % (bindir, oe.path.join(src, testfilename)))
64 oe.path.copytree(src, dst)
65
66 # ensure file in dest has user.oetest xattr
67 result = runCmd('%s/getfattr -n user.oetest %s' % (bindir, oe.path.join(dst, testfilename)))
68 self.assertIn('user.oetest="testing liboe"', result.output, 'Extended attribute not sert in dst')
69
70 oe.path.remove(testloc)
71
72 def test_copy_hardlink_tree_count(self):
73 """
74 Summary: oe.path.copyhardlinktree() shouldn't miss out files
75 Expected: src and dst should have the same number of files
76 Product: OE-Core
77 Author: Joshua Lock <joshua.g.lock@intel.com>
78 """
79 testloc = oe.path.join(self.tmp_dir, 'liboetests')
80 src = oe.path.join(testloc, 'src')
81 dst = oe.path.join(testloc, 'dst')
82 bb.utils.mkdirhier(testloc)
83 bb.utils.mkdirhier(src)
84 testfiles = ['foo', 'bar', '.baz', 'quux']
85
86 def touchfile(tf):
87 open(oe.path.join(src, tf), 'w+b').close()
88
89 for f in testfiles:
90 touchfile(f)
91
92 oe.path.copyhardlinktree(src, dst)
93
94 dstcnt = len(os.listdir(dst))
95 srccnt = len(os.listdir(src))
96 self.assertEquals(dstcnt, len(testfiles), "Number of files in dst (%s) differs from number of files in src(%s)." % (dstcnt, srccnt))
97
98 oe.path.remove(testloc)