diff options
author | Simon Glass <sjg@chromium.org> | 2022-08-06 17:51:56 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-09-12 18:06:36 -0400 |
commit | 486680272e38890f4938ec2a8673c66f42cc5c45 (patch) | |
tree | ec99c317322dd1b78961fd826f1cd82bb794da2c | |
parent | f6e6022ff1b13260ce60123dc6b2ecc369c0234f (diff) | |
download | u-boot-486680272e38890f4938ec2a8673c66f42cc5c45.zip u-boot-486680272e38890f4938ec2a8673c66f42cc5c45.tar.gz u-boot-486680272e38890f4938ec2a8673c66f42cc5c45.tar.bz2 |
test/py: Move U-Boot building into a function
This is a lot of code in a function that is too long. Split out the
building code.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/py/conftest.py | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py index dbe1acd..906387d 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -76,6 +76,41 @@ def pytest_addoption(parser): help='Run sandbox under gdbserver. The argument is the channel '+ 'over which gdbserver should communicate, e.g. localhost:1234') +def run_build(config, source_dir, build_dir, board_type, log): + """run_build: Build U-Boot + + Args: + config: The pytest configuration. + soruce_dir (str): Directory containing source code + build_dir (str): Directory to build in + board_type (str): board_type parameter (e.g. 'sandbox') + log (Logfile): Log file to use + """ + if config.getoption('buildman'): + if build_dir != source_dir: + dest_args = ['-o', build_dir, '-w'] + else: + dest_args = ['-i'] + cmds = (['buildman', '--board', board_type] + dest_args,) + name = 'buildman' + else: + if build_dir != source_dir: + o_opt = 'O=%s' % build_dir + else: + o_opt = '' + cmds = ( + ['make', o_opt, '-s', board_type + '_defconfig'], + ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())], + ) + name = 'make' + + with log.section(name): + runner = log.get_runner(name, sys.stdout) + for cmd in cmds: + runner.run(cmd, cwd=source_dir) + runner.close() + log.status_pass('OK') + def pytest_configure(config): """pytest hook: Perform custom initialization at startup time. @@ -142,30 +177,7 @@ def pytest_configure(config): log = multiplexed_log.Logfile(result_dir + '/test-log.html') if config.getoption('build'): - if config.getoption('buildman'): - if build_dir != source_dir: - dest_args = ['-o', build_dir, '-w'] - else: - dest_args = ['-i'] - cmds = (['buildman', '--board', board_type] + dest_args,) - name = 'buildman' - else: - if build_dir != source_dir: - o_opt = 'O=%s' % build_dir - else: - o_opt = '' - cmds = ( - ['make', o_opt, '-s', board_type + '_defconfig'], - ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())], - ) - name = 'make' - - with log.section(name): - runner = log.get_runner(name, sys.stdout) - for cmd in cmds: - runner.run(cmd, cwd=source_dir) - runner.close() - log.status_pass('OK') + run_build(config, source_dir, build_dir, board_type, log) class ArbitraryAttributeContainer(object): pass |