blob: 1bef61b0487e5f8f61ad9bdf631db1757dea70bd [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001# Copyright (C) 2017 Intel Corporation
2# Released under the MIT license (see COPYING.MIT)
3
4import glob
5import os
6import unittest
7from checklayer import get_signatures, LayerType, check_command, get_depgraph, compare_signatures
8from checklayer.case import OECheckLayerTestCase
9
10class 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))
Brad Bishop316dfdd2018-06-25 12:45:53 -040054
55 def test_layerseries_compat(self):
56 for collection_name, collection_data in self.tc.layer['collections'].items():
57 self.assertTrue(collection_data['compat'], "Collection %s from layer %s does not set compatible oe-core versions via LAYERSERIES_COMPAT_collection." \
58 % (collection_name, self.tc.layer['name']))