summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
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/lib/bb/tests
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/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/cooker.py83
1 files changed, 83 insertions, 0 deletions
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)