blob: b82304e361609bb0e3ccd82b6afdde68d7612a67 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001# Copyright (C) 2017 Intel Corporation
Brad Bishopc342db32019-05-15 21:57:59 -04002#
3# SPDX-License-Identifier: MIT
4#
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005
6import glob
7import os
8import unittest
9from checklayer import get_signatures, LayerType, check_command, get_depgraph, compare_signatures
10from checklayer.case import OECheckLayerTestCase
11
12class CommonCheckLayer(OECheckLayerTestCase):
13 def test_readme(self):
14 # The top-level README file may have a suffix (like README.rst or README.txt).
Brad Bishop79641f22019-09-10 07:20:22 -040015 readme_files = glob.glob(os.path.join(self.tc.layer['path'], '[Rr][Ee][Aa][Dd][Mm][Ee]*'))
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016 self.assertTrue(len(readme_files) > 0,
17 msg="Layer doesn't contains README file.")
18
19 # There might be more than one file matching the file pattern above
20 # (for example, README.rst and README-COPYING.rst). The one with the shortest
21 # name is considered the "main" one.
22 readme_file = sorted(readme_files)[0]
23 data = ''
24 with open(readme_file, 'r') as f:
25 data = f.read()
26 self.assertTrue(data,
27 msg="Layer contains a README file but it is empty.")
28
29 def test_parse(self):
30 check_command('Layer %s failed to parse.' % self.tc.layer['name'],
31 'bitbake -p')
32
33 def test_show_environment(self):
34 check_command('Layer %s failed to show environment.' % self.tc.layer['name'],
35 'bitbake -e')
36
37 def test_world(self):
38 '''
39 "bitbake world" is expected to work. test_signatures does not cover that
40 because it is more lenient and ignores recipes in a world build that
41 are not actually buildable, so here we fail when "bitbake -S none world"
42 fails.
43 '''
44 get_signatures(self.td['builddir'], failsafe=False)
45
46 def test_signatures(self):
47 if self.tc.layer['type'] == LayerType.SOFTWARE and \
48 not self.tc.test_software_layer_signatures:
49 raise unittest.SkipTest("Not testing for signature changes in a software layer %s." \
50 % self.tc.layer['name'])
51
52 curr_sigs, _ = get_signatures(self.td['builddir'], failsafe=True)
53 msg = compare_signatures(self.td['sigs'], curr_sigs)
54 if msg is not None:
55 self.fail('Adding layer %s changed signatures.\n%s' % (self.tc.layer['name'], msg))
Brad Bishop316dfdd2018-06-25 12:45:53 -040056
57 def test_layerseries_compat(self):
58 for collection_name, collection_data in self.tc.layer['collections'].items():
59 self.assertTrue(collection_data['compat'], "Collection %s from layer %s does not set compatible oe-core versions via LAYERSERIES_COMPAT_collection." \
60 % (collection_name, self.tc.layer['name']))