mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-22 20:58:22 +00:00
test: Create a common function to get the config
The settings are decoded in two places. Combine them into a new function, before (in a future patch) expanding the number of items. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4018a08e42
commit
40a1ed1e76
1 changed files with 28 additions and 13 deletions
|
@ -115,14 +115,36 @@ def run_build(config, source_dir, build_dir, board_type, log):
|
|||
runner.close()
|
||||
log.status_pass('OK')
|
||||
|
||||
def get_details(config):
|
||||
"""Obtain salient details about the board and directories to use
|
||||
|
||||
Args:
|
||||
config (pytest.Config): pytest configuration
|
||||
|
||||
Returns:
|
||||
tuple:
|
||||
str: Board type (U-Boot build name)
|
||||
str: Identity for the lab board
|
||||
str: Build directory
|
||||
str: Source directory
|
||||
"""
|
||||
board_type = config.getoption('board_type')
|
||||
board_identity = config.getoption('board_identity')
|
||||
build_dir = config.getoption('build_dir')
|
||||
|
||||
source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
|
||||
default_build_dir = source_dir + '/build-' + board_type
|
||||
if not build_dir:
|
||||
build_dir = default_build_dir
|
||||
|
||||
return board_type, board_identity, build_dir, source_dir
|
||||
|
||||
def pytest_xdist_setupnodes(config, specs):
|
||||
"""Clear out any 'done' file from a previous build"""
|
||||
global build_done_file
|
||||
build_dir = config.getoption('build_dir')
|
||||
board_type = config.getoption('board_type')
|
||||
source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
|
||||
if not build_dir:
|
||||
build_dir = source_dir + '/build-' + board_type
|
||||
|
||||
build_dir = get_details(config)[2]
|
||||
|
||||
build_done_file = Path(build_dir) / 'build.done'
|
||||
if build_done_file.exists():
|
||||
os.remove(build_done_file)
|
||||
|
@ -161,17 +183,10 @@ def pytest_configure(config):
|
|||
global console
|
||||
global ubconfig
|
||||
|
||||
source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
|
||||
board_type, board_identity, build_dir, source_dir = get_details(config)
|
||||
|
||||
board_type = config.getoption('board_type')
|
||||
board_type_filename = board_type.replace('-', '_')
|
||||
|
||||
board_identity = config.getoption('board_identity')
|
||||
board_identity_filename = board_identity.replace('-', '_')
|
||||
|
||||
build_dir = config.getoption('build_dir')
|
||||
if not build_dir:
|
||||
build_dir = source_dir + '/build-' + board_type
|
||||
mkdir_p(build_dir)
|
||||
|
||||
result_dir = config.getoption('result_dir')
|
||||
|
|
Loading…
Add table
Reference in a new issue