diff options
| author | Daniel Istrate <daniel.alexandrux.istrate@intel.com> | 2015-12-15 16:32:43 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-22 16:08:49 +0000 |
| commit | d4b5a1f171e5f76c5f9d376317d1f5b931f2d66e (patch) | |
| tree | 69a8f1a6772a8b50c4f55581f1c05f8318299e59 | |
| parent | 4b83f1fef986b72c59ac438372c4a576745b9d4f (diff) | |
| download | poky-d4b5a1f171e5f76c5f9d376317d1f5b931f2d66e.tar.gz | |
selftest/buildhistory.py: Test buildhistory does not change sigs
[YOCTO #5953] Add a test to ensure buildhistory does not
change signatures.
Also removed unused imports.
(From OE-Core rev: 9e8f5ff6b0bd6cffcbb991d75487ab6005974000)
Signed-off-by: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/lib/oeqa/selftest/buildhistory.py | 69 |
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 @@ | |||
| 1 | import unittest | ||
| 2 | import os | 1 | import os |
| 3 | import re | 2 | import re |
| 4 | import shutil | ||
| 5 | import datetime | 3 | import datetime |
| 6 | 4 | ||
| 7 | import oeqa.utils.ftools as ftools | ||
| 8 | from oeqa.selftest.base import oeSelfTest | 5 | from oeqa.selftest.base import oeSelfTest |
| 9 | from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer | 6 | from oeqa.utils.commands import bitbake, get_bb_var |
| 7 | from oeqa.utils.decorators import testcase | ||
| 10 | 8 | ||
| 11 | 9 | ||
| 12 | class BuildhistoryBase(oeSelfTest): | 10 | class 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) | ||
