summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/sstate.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/sstate.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/sstate.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/sstate.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/sstate.py b/meta/lib/oeqa/selftest/cases/sstate.py
new file mode 100644
index 0000000000..bc2fdbd8cc
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/sstate.py
@@ -0,0 +1,63 @@
1import datetime
2import unittest
3import os
4import re
5import shutil
6
7import oeqa.utils.ftools as ftools
8from oeqa.selftest.case import OESelftestTestCase
9from oeqa.utils.commands import runCmd, bitbake, get_bb_vars, get_test_layer
10
11
12class SStateBase(OESelftestTestCase):
13
14 def setUpLocal(self):
15 super(SStateBase, self).setUpLocal()
16 self.temp_sstate_location = None
17 needed_vars = ['SSTATE_DIR', 'NATIVELSBSTRING', 'TCLIBC', 'TUNE_ARCH',
18 'TOPDIR', 'TARGET_VENDOR', 'TARGET_OS']
19 bb_vars = get_bb_vars(needed_vars)
20 self.sstate_path = bb_vars['SSTATE_DIR']
21 self.hostdistro = bb_vars['NATIVELSBSTRING']
22 self.tclibc = bb_vars['TCLIBC']
23 self.tune_arch = bb_vars['TUNE_ARCH']
24 self.topdir = bb_vars['TOPDIR']
25 self.target_vendor = bb_vars['TARGET_VENDOR']
26 self.target_os = bb_vars['TARGET_OS']
27 self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro)
28
29 # Creates a special sstate configuration with the option to add sstate mirrors
30 def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]):
31 self.temp_sstate_location = temp_sstate_location
32
33 if self.temp_sstate_location:
34 temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
35 config_temp_sstate = "SSTATE_DIR = \"%s\"" % temp_sstate_path
36 self.append_config(config_temp_sstate)
37 self.track_for_cleanup(temp_sstate_path)
38 bb_vars = get_bb_vars(['SSTATE_DIR', 'NATIVELSBSTRING'])
39 self.sstate_path = bb_vars['SSTATE_DIR']
40 self.hostdistro = bb_vars['NATIVELSBSTRING']
41 self.distro_specific_sstate = os.path.join(self.sstate_path, self.hostdistro)
42
43 if add_local_mirrors:
44 config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""'
45 self.append_config(config_set_sstate_if_not_set)
46 for local_mirror in add_local_mirrors:
47 self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror')
48 config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror
49 self.append_config(config_sstate_mirror)
50
51 # Returns a list containing sstate files
52 def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True):
53 result = []
54 for root, dirs, files in os.walk(self.sstate_path):
55 if distro_specific and re.search("%s/[a-z0-9]{2}$" % self.hostdistro, root):
56 for f in files:
57 if re.search(filename_regex, f):
58 result.append(f)
59 if distro_nonspecific and re.search("%s/[a-z0-9]{2}$" % self.sstate_path, root):
60 for f in files:
61 if re.search(filename_regex, f):
62 result.append(f)
63 return result