summaryrefslogtreecommitdiff
path: root/tools/buildman/func_test.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-03-18 09:42:42 -0600
committerTom Rini <trini@konsulko.com>2020-04-10 21:21:06 -0400
commitd829f1217c678d663263061e990481ae6e051e1d (patch)
treeaa36995b989d55a9555c7afbd8031f7879f423b8 /tools/buildman/func_test.py
parente9fbbf633e6256a9749c6d8e6876dafa86213351 (diff)
bulidman: Add support for a simple build
It is useful to run a simple build and put all the output in a single directory. Add a -w option to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/buildman/func_test.py')
-rw-r--r--tools/buildman/func_test.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 4c3d497294d..f9f8f80593c 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -16,6 +16,7 @@ import control
import gitutil
import terminal
import toolchain
+import tools
settings_data = '''
# Buildman settings file
@@ -208,7 +209,7 @@ class TestFunctional(unittest.TestCase):
def tearDown(self):
shutil.rmtree(self._base_dir)
- shutil.rmtree(self._output_dir)
+ #shutil.rmtree(self._output_dir)
def setupToolchains(self):
self._toolchains = toolchain.Toolchains()
@@ -218,12 +219,12 @@ class TestFunctional(unittest.TestCase):
return command.RunPipe([[self._buildman_pathname] + list(args)],
capture=True, capture_stderr=True)
- def _RunControl(self, *args, **kwargs):
+ def _RunControl(self, *args, clean_dir=False, boards=None):
sys.argv = [sys.argv[0]] + list(args)
options, args = cmdline.ParseArgs()
result = control.DoBuildman(options, args, toolchains=self._toolchains,
- make_func=self._HandleMake, boards=self._boards,
- clean_dir=kwargs.get('clean_dir', True))
+ make_func=self._HandleMake, boards=boards or self._boards,
+ clean_dir=clean_dir)
self._builder = control.builder
return result
@@ -397,6 +398,12 @@ class TestFunctional(unittest.TestCase):
combined='Test configuration complete')
elif stage == 'build':
stderr = ''
+ out_dir = ''
+ for arg in args:
+ if arg.startswith('O='):
+ out_dir = arg[2:]
+ fname = os.path.join(cwd or '', out_dir, 'u-boot')
+ tools.WriteFile(fname, b'U-Boot')
if type(commit) is not str:
stderr = self._error.get((brd.target, commit.sequence))
if stderr:
@@ -535,3 +542,27 @@ class TestFunctional(unittest.TestCase):
with self.assertRaises(SystemExit):
self._RunControl('-b', self._test_branch, '-o',
os.path.join(os.getcwd(), 'test'))
+
+ def testWorkInOutput(self):
+ """Test the -w option which should write directly to the output dir"""
+ board_list = board.Boards()
+ board_list.AddBoard(board.Board(*boards[0]))
+ self._RunControl('-o', self._output_dir, '-w', clean_dir=False,
+ boards=board_list)
+ self.assertTrue(
+ os.path.exists(os.path.join(self._output_dir, 'u-boot')))
+
+ def testWorkInOutputFail(self):
+ """Test the -w option failures"""
+ with self.assertRaises(SystemExit) as e:
+ self._RunControl('-o', self._output_dir, '-w', clean_dir=False)
+ self.assertIn("single board", str(e.exception))
+ self.assertFalse(
+ os.path.exists(os.path.join(self._output_dir, 'u-boot')))
+
+ board_list = board.Boards()
+ board_list.AddBoard(board.Board(*boards[0]))
+ with self.assertRaises(SystemExit) as e:
+ self._RunControl('-b', self._test_branch, '-o', self._output_dir,
+ '-w', clean_dir=False, boards=board_list)
+ self.assertIn("single commit", str(e.exception))