summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/_sstatetests_noauto.py
diff options
context:
space:
mode:
authorCorneliu Stoicescu <corneliux.stoicescu@intel.com>2014-01-24 18:05:47 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-01-28 00:52:36 +0000
commit464c120036011f2d8e5ce5f33a5d449fa0fefc83 (patch)
treefdc89e4103cc99cc65609099f3c56f8d73a83dab /meta/lib/oeqa/selftest/_sstatetests_noauto.py
parenta329371eaa6751eaf0d25f272ba4ba2107b65207 (diff)
downloadpoky-464c120036011f2d8e5ce5f33a5d449fa0fefc83.tar.gz
oe-selftest: New tests for sstate relocation
Added new tests: - sstate relocation stress testing - rebuild from sstate stress testing (From OE-Core rev: 461ae0bd06da89d31cba2459fb1e6f7e57ad6519) Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/_sstatetests_noauto.py')
-rw-r--r--meta/lib/oeqa/selftest/_sstatetests_noauto.py96
1 files changed, 96 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..5253334e12
--- /dev/null
+++ b/meta/lib/oeqa/selftest/_sstatetests_noauto.py
@@ -0,0 +1,96 @@
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
10from oeqa.selftest.sstate import SStateBase
11
12
13class 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 if os.path.exists(builddir):
28 raise AssertionError("Cannot create build directory at %s: Path allready exists!" % builddir)
29 try:
30 os.mkdir(builddir)
31 except:
32 raise AssertionError("Cannot create %s . Make sure %s exists!" % (dst, os.path.dirname(dst)))
33 os.mkdir(os.path.join(builddir, 'conf'))
34 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(builddir, 'conf/local.conf'))
35 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/bblayers.conf'), os.path.join(builddir, 'conf/bblayers.conf'))
36
37 def hardlink_tree(self, src, dst):
38 if os.path.exists(dst):
39 raise AssertionError("Cannot create directory at %s: Path allready exists!" % dst)
40 try:
41 os.mkdir(dst)
42 except:
43 raise AssertionError("Cannot create %s . Make sure %s exists!" % (dst, os.path.dirname(dst)))
44 for root, dirs, files in os.walk(src):
45 if root == src:
46 continue
47 os.mkdir(os.path.join(dst, root.split(src)[1][1:]))
48 for sstate_file in files:
49 os.link(os.path.join(root, sstate_file), os.path.join(dst, root.split(src)[1][1:], sstate_file))
50
51 def run_test_sstate_rebuild(self, primary_targets, relocate=False, rebuild_dependencies=False):
52 buildA = os.path.join(self.builddir, 'buildA')
53 if relocate:
54 buildB = os.path.join(self.builddir, 'buildB')
55 else:
56 buildB = buildA
57 self.track_for_cleanup(buildA)
58 self.track_for_cleanup(buildB)
59 self.track_for_cleanup(os.path.join(self.builddir, 'sstate-cache-buildA'))
60
61 if rebuild_dependencies:
62 rebuild_targets = self.get_dep_targets(primary_targets)
63 else:
64 rebuild_targets = primary_targets
65
66 self.configure_builddir(buildA)
67 runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildA)) + 'bitbake ' + ' '.join(map(str, primary_targets)), shell=True, executable='/bin/bash')
68 self.hardlink_tree(os.path.join(buildA, 'sstate-cache'), os.path.join(self.builddir, 'sstate-cache-buildA'))
69 shutil.rmtree(buildA)
70
71 failed_rebuild = []
72 failed_cleansstate = []
73 for target in rebuild_targets:
74 self.configure_builddir(buildB)
75 self.hardlink_tree(os.path.join(self.builddir, 'sstate-cache-buildA'), os.path.join(buildB, 'sstate-cache'))
76
77 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')
78 if not result_cleansstate.status == 0:
79 failed_cleansstate.append(target)
80 shutil.rmtree(buildB)
81 continue
82
83 result_build = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake ' + target, ignore_status=True, shell=True, executable='/bin/bash')
84 if not result_build.status == 0:
85 failed_rebuild.append(target)
86
87 shutil.rmtree(buildB)
88
89 self.assertFalse(failed_rebuild, msg="The following recipes have failed to rebuild: %s" % ' '.join(map(str, failed_rebuild)))
90 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)))
91
92 def test_sstate_relocation(self):
93 self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=True, rebuild_dependencies=True)
94
95 def test_sstate_rebuild(self):
96 self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=False, rebuild_dependencies=True)