summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/buildhistory.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/buildhistory.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/buildhistory.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/buildhistory.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/buildhistory.py b/meta/lib/oeqa/selftest/cases/buildhistory.py
new file mode 100644
index 0000000000..06792d9146
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/buildhistory.py
@@ -0,0 +1,46 @@
1import os
2import re
3import datetime
4
5from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import bitbake, get_bb_vars
7
8
9class BuildhistoryBase(OESelftestTestCase):
10
11 def config_buildhistory(self, tmp_bh_location=False):
12 bb_vars = get_bb_vars(['USER_CLASSES', 'INHERIT'])
13 if (not 'buildhistory' in bb_vars['USER_CLASSES']) and (not 'buildhistory' in bb_vars['INHERIT']):
14 add_buildhistory_config = 'INHERIT += "buildhistory"\nBUILDHISTORY_COMMIT = "1"'
15 self.append_config(add_buildhistory_config)
16
17 if tmp_bh_location:
18 # Using a temporary buildhistory location for testing
19 tmp_bh_dir = os.path.join(self.builddir, "tmp_buildhistory_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
20 buildhistory_dir_config = "BUILDHISTORY_DIR = \"%s\"" % tmp_bh_dir
21 self.append_config(buildhistory_dir_config)
22 self.track_for_cleanup(tmp_bh_dir)
23
24 def run_buildhistory_operation(self, target, global_config='', target_config='', change_bh_location=False, expect_error=False, error_regex=''):
25 if change_bh_location:
26 tmp_bh_location = True
27 else:
28 tmp_bh_location = False
29 self.config_buildhistory(tmp_bh_location)
30
31 self.append_config(global_config)
32 self.append_recipeinc(target, target_config)
33 bitbake("-cclean %s" % target)
34 result = bitbake(target, ignore_status=True)
35 self.remove_config(global_config)
36 self.remove_recipeinc(target, target_config)
37
38 if expect_error:
39 self.assertEqual(result.status, 1, msg="Error expected for global config '%s' and target config '%s'" % (global_config, target_config))
40 search_for_error = re.search(error_regex, result.output)
41 self.assertTrue(search_for_error, msg="Could not find desired error in output: %s (%s)" % (error_regex, result.output))
42 else:
43 self.assertEqual(result.status, 0, msg="Command 'bitbake %s' has failed unexpectedly: %s" % (target, result.output))
44
45 # No tests should be added to the base class.
46 # Please create a new class that inherit this one, or use one of those already available for adding tests.