summaryrefslogtreecommitdiffstats
path: root/scripts/lib/checklayer/cases/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/checklayer/cases/common.py')
-rw-r--r--scripts/lib/checklayer/cases/common.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/scripts/lib/checklayer/cases/common.py b/scripts/lib/checklayer/cases/common.py
index b82304e361..97b16f78c8 100644
--- a/scripts/lib/checklayer/cases/common.py
+++ b/scripts/lib/checklayer/cases/common.py
@@ -6,15 +6,19 @@
6import glob 6import glob
7import os 7import os
8import unittest 8import unittest
9import re
9from checklayer import get_signatures, LayerType, check_command, get_depgraph, compare_signatures 10from checklayer import get_signatures, LayerType, check_command, get_depgraph, compare_signatures
10from checklayer.case import OECheckLayerTestCase 11from checklayer.case import OECheckLayerTestCase
11 12
12class CommonCheckLayer(OECheckLayerTestCase): 13class CommonCheckLayer(OECheckLayerTestCase):
13 def test_readme(self): 14 def test_readme(self):
15 if self.tc.layer['type'] == LayerType.CORE:
16 raise unittest.SkipTest("Core layer's README is top level")
17
14 # The top-level README file may have a suffix (like README.rst or README.txt). 18 # The top-level README file may have a suffix (like README.rst or README.txt).
15 readme_files = glob.glob(os.path.join(self.tc.layer['path'], '[Rr][Ee][Aa][Dd][Mm][Ee]*')) 19 readme_files = glob.glob(os.path.join(self.tc.layer['path'], '[Rr][Ee][Aa][Dd][Mm][Ee]*'))
16 self.assertTrue(len(readme_files) > 0, 20 self.assertTrue(len(readme_files) > 0,
17 msg="Layer doesn't contains README file.") 21 msg="Layer doesn't contain a README file.")
18 22
19 # There might be more than one file matching the file pattern above 23 # 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 24 # (for example, README.rst and README-COPYING.rst). The one with the shortest
@@ -26,6 +30,16 @@ class CommonCheckLayer(OECheckLayerTestCase):
26 self.assertTrue(data, 30 self.assertTrue(data,
27 msg="Layer contains a README file but it is empty.") 31 msg="Layer contains a README file but it is empty.")
28 32
33 # If a layer's README references another README, then the checks below are not valid
34 if re.search('README', data, re.IGNORECASE):
35 return
36
37 self.assertIn('maintainer', data.lower())
38 self.assertIn('patch', data.lower())
39 # Check that there is an email address in the README
40 email_regex = re.compile(r"[^@]+@[^@]+")
41 self.assertTrue(email_regex.match(data))
42
29 def test_parse(self): 43 def test_parse(self):
30 check_command('Layer %s failed to parse.' % self.tc.layer['name'], 44 check_command('Layer %s failed to parse.' % self.tc.layer['name'],
31 'bitbake -p') 45 'bitbake -p')
@@ -43,6 +57,36 @@ class CommonCheckLayer(OECheckLayerTestCase):
43 ''' 57 '''
44 get_signatures(self.td['builddir'], failsafe=False) 58 get_signatures(self.td['builddir'], failsafe=False)
45 59
60 def test_world_inherit_class(self):
61 '''
62 This also does "bitbake -S none world" along with inheriting "yocto-check-layer"
63 class, which can do additional per-recipe test cases.
64 '''
65 msg = []
66 try:
67 get_signatures(self.td['builddir'], failsafe=False, machine=None, extravars='BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS INHERIT" INHERIT="yocto-check-layer"')
68 except RuntimeError as ex:
69 msg.append(str(ex))
70 if msg:
71 msg.insert(0, 'Layer %s failed additional checks from yocto-check-layer.bbclass\nSee below log for specific recipe parsing errors:\n' % \
72 self.tc.layer['name'])
73 self.fail('\n'.join(msg))
74
75 @unittest.expectedFailure
76 def test_patches_upstream_status(self):
77 import sys
78 sys.path.append(os.path.join(sys.path[0], '../../../../meta/lib/'))
79 import oe.qa
80 patches = []
81 for dirpath, dirs, files in os.walk(self.tc.layer['path']):
82 for filename in files:
83 if filename.endswith(".patch"):
84 ppath = os.path.join(dirpath, filename)
85 if oe.qa.check_upstream_status(ppath):
86 patches.append(ppath)
87 self.assertEqual(len(patches), 0 , \
88 msg="Found following patches with malformed or missing upstream status:\n%s" % '\n'.join([str(patch) for patch in patches]))
89
46 def test_signatures(self): 90 def test_signatures(self):
47 if self.tc.layer['type'] == LayerType.SOFTWARE and \ 91 if self.tc.layer['type'] == LayerType.SOFTWARE and \
48 not self.tc.test_software_layer_signatures: 92 not self.tc.test_software_layer_signatures: