summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-27 17:33:16 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-29 10:17:16 +0100
commitbde0f60971c3c9b758b31fae7cf243e70b3833ff (patch)
tree2fab1f3979f39a7aa92f1a1fa40678b7695da363 /bitbake/lib/bb/tests
parent8d8b02aacde8d9fb87a55a7c200a4519bfbe8631 (diff)
downloadpoky-bde0f60971c3c9b758b31fae7cf243e70b3833ff.tar.gz
bitbake: tests/data: Add log parsing test code
This allows us to write tests which ensure a particular action generates a particular log message. (Bitbake rev: b30ee0aba51a35a194a4338b988f93ece1ed281c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/data.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 7994a88a78..b4e90e0327 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -24,6 +24,30 @@ import unittest
24import bb 24import bb
25import bb.data 25import bb.data
26import bb.parse 26import bb.parse
27import logging
28
29class LogRecord():
30 def __enter__(self):
31 logs = []
32 class LogHandler(logging.Handler):
33 def emit(self, record):
34 logs.append(record)
35 logger = logging.getLogger("BitBake")
36 handler = LogHandler()
37 self.handler = handler
38 logger.addHandler(handler)
39 return logs
40 def __exit__(self, type, value, traceback):
41 logger = logging.getLogger("BitBake")
42 logger.removeHandler(self.handler)
43 return
44
45def logContains(item, logs):
46 for l in logs:
47 m = l.getMessage()
48 if item in m:
49 return True
50 return False
27 51
28class DataExpansions(unittest.TestCase): 52class DataExpansions(unittest.TestCase):
29 def setUp(self): 53 def setUp(self):
@@ -301,7 +325,6 @@ class TestOverrides(unittest.TestCase):
301 bb.data.update_data(self.d) 325 bb.data.update_data(self.d)
302 self.assertEqual(self.d.getVar("TEST", True), "testvalue3") 326 self.assertEqual(self.d.getVar("TEST", True), "testvalue3")
303 327
304
305class TestFlags(unittest.TestCase): 328class TestFlags(unittest.TestCase):
306 def setUp(self): 329 def setUp(self):
307 self.d = bb.data.init() 330 self.d = bb.data.init()