summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2018-08-29 10:52:17 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-09-05 18:01:37 +0100
commitb7e26bedc2952e4ac0edface4bd20be22d7708cd (patch)
tree7eb6def35e254ae265cf7e4321c050a855a76ef9 /bitbake
parent2e9189c70ce60adee66fc602f684574bd305a4f9 (diff)
downloadpoky-b7e26bedc2952e4ac0edface4bd20be22d7708cd.tar.gz
bitbake: cooker.py: Fix incorrect bb files matched warning
In the case of a sublayer of an existing layer, where the sublayer and main layer share a path, the system may not match the paths properly resulting in: No bb files matched BBFILE_PATTERN_sublayer '^/path/main/sublayer' because it has already matched the main layer. Fix this issue by sorting the collection items based on the pattern, using longest to shortest. Obviously regex wildcards could still be an issue but these are typically not used, so this simply fix should work in the existing cases. (Bitbake rev: 1787cef7221b88f6920ea70fadaffc117d84c7aa) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake-selftest1
-rw-r--r--bitbake/lib/bb/cooker.py5
-rw-r--r--bitbake/lib/bb/tests/cooker.py83
3 files changed, 88 insertions, 1 deletions
diff --git a/bitbake/bin/bitbake-selftest b/bitbake/bin/bitbake-selftest
index 7564de304c..cfa7ac5391 100755
--- a/bitbake/bin/bitbake-selftest
+++ b/bitbake/bin/bitbake-selftest
@@ -27,6 +27,7 @@ except RuntimeError as exc:
27 sys.exit(str(exc)) 27 sys.exit(str(exc))
28 28
29tests = ["bb.tests.codeparser", 29tests = ["bb.tests.codeparser",
30 "bb.tests.cooker",
30 "bb.tests.cow", 31 "bb.tests.cow",
31 "bb.tests.data", 32 "bb.tests.data",
32 "bb.tests.event", 33 "bb.tests.event",
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 946ba9ca06..d7e90f25d2 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1661,7 +1661,10 @@ class CookerExit(bb.event.Event):
1661class CookerCollectFiles(object): 1661class CookerCollectFiles(object):
1662 def __init__(self, priorities): 1662 def __init__(self, priorities):
1663 self.bbappends = [] 1663 self.bbappends = []
1664 self.bbfile_config_priorities = priorities 1664 # Priorities is a list of tupples, with the second element as the pattern.
1665 # We need to sort the list with the longest pattern first, and so on to
1666 # the shortest. This allows nested layers to be properly evaluated.
1667 self.bbfile_config_priorities = sorted(priorities, key=lambda tup: tup[1], reverse=True)
1665 1668
1666 def calc_bbfile_priority( self, filename, matched = None ): 1669 def calc_bbfile_priority( self, filename, matched = None ):
1667 for _, _, regex, pri in self.bbfile_config_priorities: 1670 for _, _, regex, pri in self.bbfile_config_priorities:
diff --git a/bitbake/lib/bb/tests/cooker.py b/bitbake/lib/bb/tests/cooker.py
new file mode 100644
index 0000000000..2b44236506
--- /dev/null
+++ b/bitbake/lib/bb/tests/cooker.py
@@ -0,0 +1,83 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# BitBake Tests for cooker.py
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 2 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18#
19
20import unittest
21import tempfile
22import os
23import bb, bb.cooker
24import re
25import logging
26
27# Cooker tests
28class CookerTest(unittest.TestCase):
29 def setUp(self):
30 # At least one variable needs to be set
31 self.d = bb.data.init()
32 topdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "testdata/cooker")
33 self.d.setVar('TOPDIR', topdir)
34
35 def test_CookerCollectFiles_sublayers(self):
36 '''Test that a sublayer of an existing layer does not trigger
37 No bb files matched ...'''
38
39 def append_collection(topdir, path, d):
40 collection = path.split('/')[-1]
41 pattern = "^" + topdir + "/" + path + "/"
42 regex = re.compile(pattern)
43 priority = 5
44
45 d.setVar('BBFILE_COLLECTIONS', (d.getVar('BBFILE_COLLECTIONS') or "") + " " + collection)
46 d.setVar('BBFILE_PATTERN_%s' % (collection), pattern)
47 d.setVar('BBFILE_PRIORITY_%s' % (collection), priority)
48
49 return (collection, pattern, regex, priority)
50
51 topdir = self.d.getVar("TOPDIR")
52
53 # Priorities: list of (collection, pattern, regex, priority)
54 bbfile_config_priorities = []
55 # Order is important for this test, shortest to longest is typical failure case
56 bbfile_config_priorities.append( append_collection(topdir, 'first', self.d) )
57 bbfile_config_priorities.append( append_collection(topdir, 'second', self.d) )
58 bbfile_config_priorities.append( append_collection(topdir, 'second/third', self.d) )
59
60 pkgfns = [ topdir + '/first/recipes/sample1_1.0.bb',
61 topdir + '/second/recipes/sample2_1.0.bb',
62 topdir + '/second/third/recipes/sample3_1.0.bb' ]
63
64 class LogHandler(logging.Handler):
65 def __init__(self):
66 logging.Handler.__init__(self)
67 self.logdata = []
68
69 def emit(self, record):
70 self.logdata.append(record.getMessage())
71
72 # Move cooker to use my special logging
73 logger = bb.cooker.logger
74 log_handler = LogHandler()
75 logger.addHandler(log_handler)
76 collection = bb.cooker.CookerCollectFiles(bbfile_config_priorities)
77 collection.collection_priorities(pkgfns, self.d)
78 logger.removeHandler(log_handler)
79
80 # Should be empty (no generated messages)
81 expected = []
82
83 self.assertEqual(log_handler.logdata, expected)