summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorneliu Stoicescu <corneliux.stoicescu@intel.com>2014-01-14 14:21:21 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-16 12:18:52 +0000
commitcfd1520b4b492ab27b2900ba3510abe6f288097e (patch)
tree66b2cb3af6b404cf83ecb18fa73ac24d76d2dd94
parent9229f253224c9003a530941ccd97fdc41702b748 (diff)
downloadpoky-cfd1520b4b492ab27b2900ba3510abe6f288097e.tar.gz
oe-selftest: separated the SStateBase and SStateTests in different modules
- SStateBase now has its own module to be imported by itself by other modules like sstatetests.py (From OE-Core rev: 8163854adf87ac42a8f08ee25685d0ce1efb4724) Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/sstate.py53
-rw-r--r--meta/lib/oeqa/selftest/sstatetests.py43
2 files changed, 54 insertions, 42 deletions
diff --git a/meta/lib/oeqa/selftest/sstate.py b/meta/lib/oeqa/selftest/sstate.py
new file mode 100644
index 0000000000..5989724432
--- /dev/null
+++ b/meta/lib/oeqa/selftest/sstate.py
@@ -0,0 +1,53 @@
1import datetime
2import unittest
3import os
4import re
5import shutil
6
7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest
9from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
10
11
12class SStateBase(oeSelfTest):
13
14 def setUpLocal(self):
15 self.temp_sstate_location = None
16 self.sstate_path = get_bb_var('SSTATE_DIR')
17 self.distro = get_bb_var('NATIVELSBSTRING')
18 self.distro_specific_sstate = os.path.join(self.sstate_path, self.distro)
19
20 # Creates a special sstate configuration with the option to add sstate mirrors
21 def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]):
22 self.temp_sstate_location = temp_sstate_location
23
24 if self.temp_sstate_location:
25 temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
26 config_temp_sstate = "SSTATE_DIR = \"%s\"" % temp_sstate_path
27 self.append_config(config_temp_sstate)
28 self.track_for_cleanup(temp_sstate_path)
29 self.sstate_path = get_bb_var('SSTATE_DIR')
30 self.distro = get_bb_var('NATIVELSBSTRING')
31 self.distro_specific_sstate = os.path.join(self.sstate_path, self.distro)
32
33 if add_local_mirrors:
34 config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""'
35 self.append_config(config_set_sstate_if_not_set)
36 for local_mirror in add_local_mirrors:
37 self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror')
38 config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror
39 self.append_config(config_sstate_mirror)
40
41 # Returns a list containing sstate files
42 def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True):
43 result = []
44 for root, dirs, files in os.walk(self.sstate_path):
45 if distro_specific and re.search("%s/[a-z0-9]{2}$" % self.distro, root):
46 for f in files:
47 if re.search(filename_regex, f):
48 result.append(f)
49 if distro_nonspecific and re.search("%s/[a-z0-9]{2}$" % self.sstate_path, root):
50 for f in files:
51 if re.search(filename_regex, f):
52 result.append(f)
53 return result
diff --git a/meta/lib/oeqa/selftest/sstatetests.py b/meta/lib/oeqa/selftest/sstatetests.py
index a0489fe4f1..4b2c26d0c1 100644
--- a/meta/lib/oeqa/selftest/sstatetests.py
+++ b/meta/lib/oeqa/selftest/sstatetests.py
@@ -7,49 +7,8 @@ import shutil
7import oeqa.utils.ftools as ftools 7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest 8from oeqa.selftest.base import oeSelfTest
9from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer 9from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
10from oeqa.selftest.sstate import SStateBase
10 11
11class SStateBase(oeSelfTest):
12
13 def setUpLocal(self):
14 self.temp_sstate_location = None
15 self.sstate_path = get_bb_var('SSTATE_DIR')
16 self.distro = get_bb_var('NATIVELSBSTRING')
17 self.distro_specific_sstate = os.path.join(self.sstate_path, self.distro)
18
19 # Creates a special sstate configuration with the option to add sstate mirrors
20 def config_sstate(self, temp_sstate_location=False, add_local_mirrors=[]):
21 self.temp_sstate_location = temp_sstate_location
22
23 if self.temp_sstate_location:
24 temp_sstate_path = os.path.join(self.builddir, "temp_sstate_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
25 config_temp_sstate = "SSTATE_DIR = \"%s\"" % temp_sstate_path
26 self.append_config(config_temp_sstate)
27 self.track_for_cleanup(temp_sstate_path)
28 self.sstate_path = get_bb_var('SSTATE_DIR')
29 self.distro = get_bb_var('NATIVELSBSTRING')
30 self.distro_specific_sstate = os.path.join(self.sstate_path, self.distro)
31
32 if add_local_mirrors:
33 config_set_sstate_if_not_set = 'SSTATE_MIRRORS ?= ""'
34 self.append_config(config_set_sstate_if_not_set)
35 for local_mirror in add_local_mirrors:
36 self.assertFalse(os.path.join(local_mirror) == os.path.join(self.sstate_path), msg='Cannot add the current sstate path as a sstate mirror')
37 config_sstate_mirror = "SSTATE_MIRRORS += \"file://.* file:///%s/PATH\"" % local_mirror
38 self.append_config(config_sstate_mirror)
39
40 # Returns a list containing sstate files
41 def search_sstate(self, filename_regex, distro_specific=True, distro_nonspecific=True):
42 result = []
43 for root, dirs, files in os.walk(self.sstate_path):
44 if distro_specific and re.search("%s/[a-z0-9]{2}$" % self.distro, root):
45 for f in files:
46 if re.search(filename_regex, f):
47 result.append(f)
48 if distro_nonspecific and re.search("%s/[a-z0-9]{2}$" % self.sstate_path, root):
49 for f in files:
50 if re.search(filename_regex, f):
51 result.append(f)
52 return result
53 12
54class SStateTests(SStateBase): 13class SStateTests(SStateBase):
55 14