summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/buildhistory.py69
1 files changed, 65 insertions, 4 deletions
diff --git a/meta/lib/oeqa/selftest/buildhistory.py b/meta/lib/oeqa/selftest/buildhistory.py
index d8cae4664b..e8aa05df7a 100644
--- a/meta/lib/oeqa/selftest/buildhistory.py
+++ b/meta/lib/oeqa/selftest/buildhistory.py
@@ -1,12 +1,10 @@
1import unittest
2import os 1import os
3import re 2import re
4import shutil
5import datetime 3import datetime
6 4
7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest 5from oeqa.selftest.base import oeSelfTest
9from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer 6from oeqa.utils.commands import bitbake, get_bb_var
7from oeqa.utils.decorators import testcase
10 8
11 9
12class BuildhistoryBase(oeSelfTest): 10class BuildhistoryBase(oeSelfTest):
@@ -43,3 +41,66 @@ class BuildhistoryBase(oeSelfTest):
43 self.assertTrue(search_for_error, msg="Could not find desired error in output: %s" % error_regex) 41 self.assertTrue(search_for_error, msg="Could not find desired error in output: %s" % error_regex)
44 else: 42 else:
45 self.assertEqual(result.status, 0, msg="Command 'bitbake %s' has failed unexpectedly: %s" % (target, result.output)) 43 self.assertEqual(result.status, 0, msg="Command 'bitbake %s' has failed unexpectedly: %s" % (target, result.output))
44
45 @testcase(1386)
46 def test_buildhistory_does_not_change_signatures(self):
47 """
48 Summary: Ensure that buildhistory does not change signatures
49 Expected: Only 'do_rootfs' and 'do_build' tasks are rerun
50 Product: oe-core
51 Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
52 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
53 """
54
55 tmpdir1_name = 'tmpsig1'
56 tmpdir2_name = 'tmpsig2'
57 builddir = os.environ.get('BUILDDIR')
58 tmpdir1 = os.path.join(builddir, tmpdir1_name)
59 tmpdir2 = os.path.join(builddir, tmpdir2_name)
60
61 self.track_for_cleanup(tmpdir1)
62 self.track_for_cleanup(tmpdir2)
63
64 features = 'TMPDIR = "%s"\n' % tmpdir1
65 self.write_config(features)
66 bitbake('core-image-sato -S none')
67
68 features = 'TMPDIR = "%s"\n' % tmpdir2
69 features += 'INHERIT += "buildhistory"\n'
70 self.write_config(features)
71 bitbake('core-image-sato -S none')
72
73 def get_files(d):
74 f = []
75 for root, dirs, files in os.walk(d):
76 for name in files:
77 f.append(os.path.join(root, name))
78 return f
79
80 files1 = get_files(tmpdir1 + '/stamps')
81 files2 = get_files(tmpdir2 + '/stamps')
82 files2 = [x.replace(tmpdir2_name, tmpdir1_name) for x in files2]
83
84 f1 = set(files1)
85 f2 = set(files2)
86 sigdiff = f1 - f2
87
88 self.assertEqual(len(sigdiff), 2, 'Expected 2 signature differences. Out: %s' % list(sigdiff))
89
90 unexpected_diff = []
91
92 # No new signatures should appear apart from do_rootfs and do_build
93 found_do_rootfs_flag = False
94 found_do_build_flag = False
95
96 for sig in sigdiff:
97 if 'do_rootfs' in sig:
98 found_do_rootfs_flag = True
99 elif 'do_build' in sig:
100 found_do_build_flag = True
101 else:
102 unexpected_diff.append(sig)
103
104 self.assertTrue(found_do_rootfs_flag, 'Task do_rootfs did not rerun.')
105 self.assertTrue(found_do_build_flag, 'Task do_build did not rerun')
106 self.assertFalse(unexpected_diff, 'Found unexpected signature differences. Out: %s' % unexpected_diff)