[U-Boot] [PATCH 11/15] buildman: Allow tests to have their own boards

Simon Glass sjg at chromium.org
Mon Aug 25 18:01:16 CEST 2014


Rather than reading boards.cfg, which may take time to generate and is not
necessarily suitable for running tests, create our own list of boards.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/buildman/control.py   | 25 ++++++++++++++-----------
 tools/buildman/func_test.py | 20 +++++++++++++++++++-
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index a27f7db..3f3cce8 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -78,7 +78,7 @@ def ShowActions(series, why_selected, boards_selected, builder, options):
     print ('Total boards to build for each commit: %d\n' %
             why_selected['all'])
 
-def DoBuildman(options, args, toolchains=None, make_func=None):
+def DoBuildman(options, args, toolchains=None, make_func=None, boards=None):
     """The main control code for buildman
 
     Args:
@@ -90,6 +90,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None):
                 to execute 'make'. If this is None, the normal function
                 will be used, which calls the 'make' tool with suitable
                 arguments. This setting is useful for tests.
+        board: Boards() object to use, containing a list of available
+                boards. If this is None it will be created and scanned.
     """
     if options.full_help:
         pager = os.getenv('PAGER')
@@ -135,16 +137,17 @@ def DoBuildman(options, args, toolchains=None, make_func=None):
         sys.exit(col.Color(col.RED, str))
 
     # Work out what subset of the boards we are building
-    board_file = os.path.join(options.git, 'boards.cfg')
-    if not os.path.exists(board_file):
-        print 'Could not find %s' % board_file
-        status = subprocess.call([os.path.join(options.git,
-                                               'tools/genboardscfg.py')])
-        if status != 0:
-            sys.exit("Failed to generate boards.cfg")
-
-    boards = board.Boards()
-    boards.ReadBoards(os.path.join(options.git, 'boards.cfg'))
+    if not boards:
+      board_file = os.path.join(options.git, 'boards.cfg')
+      if not os.path.exists(board_file):
+          print 'Could not find %s' % board_file
+          status = subprocess.call([os.path.join(options.git,
+                                                'tools/genboardscfg.py')])
+          if status != 0:
+              sys.exit("Failed to generate boards.cfg")
+
+      boards = board.Boards()
+      boards.ReadBoards(os.path.join(options.git, 'boards.cfg'))
 
     exclude = []
     if options.exclude:
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index c023425..27a303e 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -9,6 +9,7 @@ import sys
 import tempfile
 import unittest
 
+import board
 import bsettings
 import cmdline
 import command
@@ -33,6 +34,14 @@ chromeos_daisy=VBOOT=${chroot}/build/daisy/usr ${vboot}
 chromeos_peach=VBOOT=${chroot}/build/peach_pit/usr ${vboot}
 '''
 
+boards = [
+    ['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 1', 'board0',  ''],
+    ['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 2', 'board1', ''],
+    ['Active', 'powerpc', 'powerpc', '', 'Tester', 'PowerPC board 1', 'board2', ''],
+    ['Active', 'powerpc', 'mpc5xx', '', 'Tester', 'PowerPC board 2', 'board3', ''],
+    ['Active', 'sandbox', 'sandbox', '', 'Tester', 'Sandbox board', 'board4', ''],
+]
+
 class TestFunctional(unittest.TestCase):
     """Functional test for buildman.
 
@@ -54,6 +63,9 @@ class TestFunctional(unittest.TestCase):
         self._toolchains.Add('gcc', test=False)
         bsettings.Setup(None)
         bsettings.AddFile(settings_data)
+        self._boards = board.Boards()
+        for brd in boards:
+            self._boards.AddBoard(board.Board(*brd))
 
     def _RunBuildman(self, *args):
         return command.RunPipe([[self._buildman_pathname] + list(args)],
@@ -63,7 +75,7 @@ class TestFunctional(unittest.TestCase):
         sys.argv = [sys.argv[0]] + list(args)
         options, args = cmdline.ParseArgs()
         return control.DoBuildman(options, args, toolchains=self._toolchains,
-                make_func=self._HandleMake)
+                make_func=self._HandleMake, boards=self._boards)
 
     def testFullHelp(self):
         command.test_result = None
@@ -188,6 +200,12 @@ class TestFunctional(unittest.TestCase):
         print 'make', stage
         sys.exit(1)
 
+    def testNoBoards(self):
+        """Test that buildman aborts when there are no boards"""
+        self._boards = board.Boards()
+        with self.assertRaises(SystemExit):
+            self._RunControl()
+
     def testCurrentSource(self):
         """Very simple test to invoke buildman on the current source"""
         self._RunControl()
-- 
2.1.0.rc2.206.gedb03e5



More information about the U-Boot mailing list