diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2017-02-20 15:12:49 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-04 23:18:19 +0000 |
commit | 93633edcf84dbf5d97a43cb8d1ebff790a6ab334 (patch) | |
tree | 5d6a97536fd882c475b43f76c735d171d5b5df26 /scripts/lib/compatlayer/cases | |
parent | 28376f9552087bef93919cc5cf4a8e88a02f6d04 (diff) | |
download | poky-93633edcf84dbf5d97a43cb8d1ebff790a6ab334.tar.gz |
yocto-compat-layer.py: Add script to YP Compatible Layer validation
The yocto-compat-layer script serves as a tool to validate the alignament
of a layer with YP Compatible Layers Programme [1], is based on an RFC
sent to the ML to enable automatic testing of layers [2] that wants to
be YP Compatible.
The tool takes an layer (or set of layers) via command line option -l
and detects what kind of layer is distro, machine or software and then
executes a set of tests against the layer in order to validate the
compatibility.
The tests currently implemented are:
common.test_readme: Test if a README file exists in the layer and isn't
empty.
common.test_parse: Test for execute bitbake -p without errors.
common.test_show_environment: Test for execute bitbake -e without errors.
common.test_signatures: Test executed in BSP and DISTRO layers to review
doesn't comes with recipes that changes the signatures.
bsp.test_bsp_defines_machines: Test if a BSP layers has machines
configurations.
bsp.test_bsp_no_set_machine: Test the BSP layer to doesn't set
machine at adding layer.
distro.test_distro_defines_distros: Test if a DISTRO layers has distro
configurations.
distro.test_distro_no_set_distro: Test the DISTRO layer to doesn't set
distro at adding layer.
Example of usage:
$ source oe-init-build-env
$ yocto-compat-layer.py LAYER_DIR
[YOCTO #10596]
[1] https://www.yoctoproject.org/webform/yocto-project-compatible-registration
[2] https://lists.yoctoproject.org/pipermail/yocto-ab/2016-October/001801.html
(From OE-Core rev: e14596ac33329bc61fe38a6582fa91f76ff5b147)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/compatlayer/cases')
-rw-r--r-- | scripts/lib/compatlayer/cases/__init__.py | 0 | ||||
-rw-r--r-- | scripts/lib/compatlayer/cases/bsp.py | 26 | ||||
-rw-r--r-- | scripts/lib/compatlayer/cases/common.py | 66 | ||||
-rw-r--r-- | scripts/lib/compatlayer/cases/distro.py | 26 |
4 files changed, 118 insertions, 0 deletions
diff --git a/scripts/lib/compatlayer/cases/__init__.py b/scripts/lib/compatlayer/cases/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/scripts/lib/compatlayer/cases/__init__.py | |||
diff --git a/scripts/lib/compatlayer/cases/bsp.py b/scripts/lib/compatlayer/cases/bsp.py new file mode 100644 index 0000000000..5d9bf93e4a --- /dev/null +++ b/scripts/lib/compatlayer/cases/bsp.py | |||
@@ -0,0 +1,26 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | import unittest | ||
5 | |||
6 | from compatlayer import LayerType | ||
7 | from compatlayer.case import OECompatLayerTestCase | ||
8 | |||
9 | class BSPCompatLayer(OECompatLayerTestCase): | ||
10 | @classmethod | ||
11 | def setUpClass(self): | ||
12 | if self.tc.layer['type'] != LayerType.BSP: | ||
13 | raise unittest.SkipTest("BSPCompatLayer: Layer %s isn't BSP one." %\ | ||
14 | self.tc.layer['name']) | ||
15 | |||
16 | def test_bsp_defines_machines(self): | ||
17 | self.assertTrue(self.tc.layer['conf']['machines'], | ||
18 | "Layer is BSP but doesn't defines machines.") | ||
19 | |||
20 | def test_bsp_no_set_machine(self): | ||
21 | from oeqa.utils.commands import get_bb_var | ||
22 | |||
23 | machine = get_bb_var('MACHINE') | ||
24 | self.assertEqual(self.td['bbvars']['MACHINE'], machine, | ||
25 | msg="Layer %s modified machine %s -> %s" % \ | ||
26 | (self.tc.layer['name'], self.td['bbvars']['MACHINE'], machine)) | ||
diff --git a/scripts/lib/compatlayer/cases/common.py b/scripts/lib/compatlayer/cases/common.py new file mode 100644 index 0000000000..4d328ec1f1 --- /dev/null +++ b/scripts/lib/compatlayer/cases/common.py | |||
@@ -0,0 +1,66 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | import os | ||
5 | import subprocess | ||
6 | import unittest | ||
7 | from compatlayer import get_signatures, LayerType | ||
8 | from compatlayer.case import OECompatLayerTestCase | ||
9 | |||
10 | class CommonCompatLayer(OECompatLayerTestCase): | ||
11 | def test_readme(self): | ||
12 | readme_file = os.path.join(self.tc.layer['path'], 'README') | ||
13 | self.assertTrue(os.path.isfile(readme_file), | ||
14 | msg="Layer doesn't contains README file.") | ||
15 | |||
16 | data = '' | ||
17 | with open(readme_file, 'r') as f: | ||
18 | data = f.read() | ||
19 | self.assertTrue(data, | ||
20 | msg="Layer contains README file but is empty.") | ||
21 | |||
22 | def test_parse(self): | ||
23 | try: | ||
24 | output = subprocess.check_output('bitbake -p', shell=True, | ||
25 | stderr=subprocess.PIPE) | ||
26 | except subprocess.CalledProcessError as e: | ||
27 | import traceback | ||
28 | exc = traceback.format_exc() | ||
29 | msg = 'Layer %s failed to parse.\n%s\n%s\n' % (self.tc.layer['name'], | ||
30 | exc, e.output.decode('utf-8')) | ||
31 | raise RuntimeError(msg) | ||
32 | |||
33 | def test_show_environment(self): | ||
34 | try: | ||
35 | output = subprocess.check_output('bitbake -e', shell=True, | ||
36 | stderr=subprocess.PIPE) | ||
37 | except subprocess.CalledProcessError as e: | ||
38 | import traceback | ||
39 | exc = traceback.format_exc() | ||
40 | msg = 'Layer %s failed to show environment.\n%s\n%s\n' % \ | ||
41 | (self.tc.layer['name'], exc, e.output.decode('utf-8')) | ||
42 | raise RuntimeError(msg) | ||
43 | |||
44 | def test_signatures(self): | ||
45 | if self.tc.layer['type'] == LayerType.SOFTWARE: | ||
46 | raise unittest.SkipTest("Layer %s isn't BSP or DISTRO one." \ | ||
47 | % self.tc.layer['name']) | ||
48 | |||
49 | sig_diff = {} | ||
50 | |||
51 | curr_sigs = get_signatures(self.td['builddir'], failsafe=True) | ||
52 | for task in self.td['sigs']: | ||
53 | if task not in curr_sigs: | ||
54 | continue | ||
55 | |||
56 | if self.td['sigs'][task] != curr_sigs[task]: | ||
57 | sig_diff[task] = '%s -> %s' % \ | ||
58 | (self.td['sigs'][task], curr_sigs[task]) | ||
59 | |||
60 | detail = '' | ||
61 | if sig_diff: | ||
62 | for task in sig_diff: | ||
63 | detail += "%s changed %s\n" % (task, sig_diff[task]) | ||
64 | self.assertFalse(bool(sig_diff), "Layer %s changed signatures.\n%s" % \ | ||
65 | (self.tc.layer['name'], detail)) | ||
66 | |||
diff --git a/scripts/lib/compatlayer/cases/distro.py b/scripts/lib/compatlayer/cases/distro.py new file mode 100644 index 0000000000..523acc1e78 --- /dev/null +++ b/scripts/lib/compatlayer/cases/distro.py | |||
@@ -0,0 +1,26 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | import unittest | ||
5 | |||
6 | from compatlayer import LayerType | ||
7 | from compatlayer.case import OECompatLayerTestCase | ||
8 | |||
9 | class DistroCompatLayer(OECompatLayerTestCase): | ||
10 | @classmethod | ||
11 | def setUpClass(self): | ||
12 | if self.tc.layer['type'] != LayerType.DISTRO: | ||
13 | raise unittest.SkipTest("DistroCompatLayer: Layer %s isn't Distro one." %\ | ||
14 | self.tc.layer['name']) | ||
15 | |||
16 | def test_distro_defines_distros(self): | ||
17 | self.assertTrue(self.tc.layer['conf']['distros'], | ||
18 | "Layer is BSP but doesn't defines machines.") | ||
19 | |||
20 | def test_distro_no_set_distros(self): | ||
21 | from oeqa.utils.commands import get_bb_var | ||
22 | |||
23 | distro = get_bb_var('DISTRO') | ||
24 | self.assertEqual(self.td['bbvars']['DISTRO'], distro, | ||
25 | msg="Layer %s modified distro %s -> %s" % \ | ||
26 | (self.tc.layer['name'], self.td['bbvars']['DISTRO'], distro)) | ||