diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py | 92 |
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 @@ | |||
1 | import os | ||
2 | import shutil | ||
3 | |||
4 | import oeqa.utils.ftools as ftools | ||
5 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer | ||
6 | from oeqa.selftest.cases.sstate import SStateBase | ||
7 | |||
8 | |||
9 | class 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) | ||