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