diff options
Diffstat (limited to 'scripts/lib/checklayer/cases/common.py')
-rw-r--r-- | scripts/lib/checklayer/cases/common.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/lib/checklayer/cases/common.py b/scripts/lib/checklayer/cases/common.py new file mode 100644 index 0000000000..a13c1088f0 --- /dev/null +++ b/scripts/lib/checklayer/cases/common.py | |||
@@ -0,0 +1,53 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | import glob | ||
5 | import os | ||
6 | import unittest | ||
7 | from checklayer import get_signatures, LayerType, check_command, get_depgraph, compare_signatures | ||
8 | from checklayer.case import OECheckLayerTestCase | ||
9 | |||
10 | class CommonCheckLayer(OECheckLayerTestCase): | ||
11 | def test_readme(self): | ||
12 | # The top-level README file may have a suffix (like README.rst or README.txt). | ||
13 | readme_files = glob.glob(os.path.join(self.tc.layer['path'], 'README*')) | ||
14 | self.assertTrue(len(readme_files) > 0, | ||
15 | msg="Layer doesn't contains README file.") | ||
16 | |||
17 | # There might be more than one file matching the file pattern above | ||
18 | # (for example, README.rst and README-COPYING.rst). The one with the shortest | ||
19 | # name is considered the "main" one. | ||
20 | readme_file = sorted(readme_files)[0] | ||
21 | data = '' | ||
22 | with open(readme_file, 'r') as f: | ||
23 | data = f.read() | ||
24 | self.assertTrue(data, | ||
25 | msg="Layer contains a README file but it is empty.") | ||
26 | |||
27 | def test_parse(self): | ||
28 | check_command('Layer %s failed to parse.' % self.tc.layer['name'], | ||
29 | 'bitbake -p') | ||
30 | |||
31 | def test_show_environment(self): | ||
32 | check_command('Layer %s failed to show environment.' % self.tc.layer['name'], | ||
33 | 'bitbake -e') | ||
34 | |||
35 | def test_world(self): | ||
36 | ''' | ||
37 | "bitbake world" is expected to work. test_signatures does not cover that | ||
38 | because it is more lenient and ignores recipes in a world build that | ||
39 | are not actually buildable, so here we fail when "bitbake -S none world" | ||
40 | fails. | ||
41 | ''' | ||
42 | get_signatures(self.td['builddir'], failsafe=False) | ||
43 | |||
44 | def test_signatures(self): | ||
45 | if self.tc.layer['type'] == LayerType.SOFTWARE and \ | ||
46 | not self.tc.test_software_layer_signatures: | ||
47 | raise unittest.SkipTest("Not testing for signature changes in a software layer %s." \ | ||
48 | % self.tc.layer['name']) | ||
49 | |||
50 | curr_sigs, _ = get_signatures(self.td['builddir'], failsafe=True) | ||
51 | msg = compare_signatures(self.td['sigs'], curr_sigs) | ||
52 | if msg is not None: | ||
53 | self.fail('Adding layer %s changed signatures.\n%s' % (self.tc.layer['name'], msg)) | ||