summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.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/_sstatetests_noauto.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/_sstatetests_noauto.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py
new file mode 100644
index 0000000000..0e5896234c
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py
@@ -0,0 +1,92 @@
1import os
2import shutil
3
4import oeqa.utils.ftools as ftools
5from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
6from oeqa.selftest.cases.sstate import SStateBase
7
8
9class RebuildFromSState(SStateBase):
10
11 @classmethod
12 def setUpClass(self):
13 super(RebuildFromSState, self).setUpClass()
14 self.builddir = os.path.join(os.environ.get('BUILDDIR'))
15
16 def get_dep_targets(self, primary_targets):
17 found_targets = []
18 bitbake("-g " + ' '.join(map(str, primary_targets)))
19 with open(os.path.join(self.builddir, 'pn-buildlist'), 'r') as pnfile:
20 found_targets = pnfile.read().splitlines()
21 return found_targets
22
23 def configure_builddir(self, builddir):
24 os.mkdir(builddir)
25 self.track_for_cleanup(builddir)
26 os.mkdir(os.path.join(builddir, 'conf'))
27 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(builddir, 'conf/local.conf'))
28 config = {}
29 config['default_sstate_dir'] = "SSTATE_DIR ?= \"${TOPDIR}/sstate-cache\""
30 config['null_sstate_mirrors'] = "SSTATE_MIRRORS = \"\""
31 config['default_tmp_dir'] = "TMPDIR = \"${TOPDIR}/tmp\""
32 for key in config:
33 ftools.append_file(os.path.join(builddir, 'conf/selftest.inc'), config[key])
34 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/bblayers.conf'), os.path.join(builddir, 'conf/bblayers.conf'))
35 try:
36 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/auto.conf'), os.path.join(builddir, 'conf/auto.conf'))
37 except:
38 pass
39
40 def hardlink_tree(self, src, dst):
41 os.mkdir(dst)
42 self.track_for_cleanup(dst)
43 for root, dirs, files in os.walk(src):
44 if root == src:
45 continue
46 os.mkdir(os.path.join(dst, root.split(src)[1][1:]))
47 for sstate_file in files:
48 os.link(os.path.join(root, sstate_file), os.path.join(dst, root.split(src)[1][1:], sstate_file))
49
50 def run_test_sstate_rebuild(self, primary_targets, relocate=False, rebuild_dependencies=False):
51 buildA = os.path.join(self.builddir, 'buildA')
52 if relocate:
53 buildB = os.path.join(self.builddir, 'buildB')
54 else:
55 buildB = buildA
56
57 if rebuild_dependencies:
58 rebuild_targets = self.get_dep_targets(primary_targets)
59 else:
60 rebuild_targets = primary_targets
61
62 self.configure_builddir(buildA)
63 runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildA)) + 'bitbake ' + ' '.join(map(str, primary_targets)), shell=True, executable='/bin/bash')
64 self.hardlink_tree(os.path.join(buildA, 'sstate-cache'), os.path.join(self.builddir, 'sstate-cache-buildA'))
65 shutil.rmtree(buildA)
66
67 failed_rebuild = []
68 failed_cleansstate = []
69 for target in rebuild_targets:
70 self.configure_builddir(buildB)
71 self.hardlink_tree(os.path.join(self.builddir, 'sstate-cache-buildA'), os.path.join(buildB, 'sstate-cache'))
72
73 result_cleansstate = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake -ccleansstate ' + target, ignore_status=True, shell=True, executable='/bin/bash')
74 if not result_cleansstate.status == 0:
75 failed_cleansstate.append(target)
76 shutil.rmtree(buildB)
77 continue
78
79 result_build = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake ' + target, ignore_status=True, shell=True, executable='/bin/bash')
80 if not result_build.status == 0:
81 failed_rebuild.append(target)
82
83 shutil.rmtree(buildB)
84
85 self.assertFalse(failed_rebuild, msg="The following recipes have failed to rebuild: %s" % ' '.join(map(str, failed_rebuild)))
86 self.assertFalse(failed_cleansstate, msg="The following recipes have failed cleansstate(all others have passed both cleansstate and rebuild from sstate tests): %s" % ' '.join(map(str, failed_cleansstate)))
87
88 def test_sstate_relocation(self):
89 self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=True, rebuild_dependencies=True)
90
91 def test_sstate_rebuild(self):
92 self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=False, rebuild_dependencies=True)