Skip to content

Commit

Permalink
twister: setup soc/arch roots based on module settings
Browse files Browse the repository at this point in the history
Get data for various roots from modules and do not hardcode location
when retrieving list of boards in testplan.

Fixes #71761

Signed-off-by: Anas Nashif <[email protected]>
(cherry picked from commit d145db0)
  • Loading branch information
nashif authored and github-actions[bot] committed Aug 30, 2024
1 parent df9a905 commit de0f972
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions scripts/pylib/twister/twisterlib/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,22 @@ def __init__(self, options=None, default_options=None) -> None:
if snippet_root:
self.snippet_roots.append(Path(module.project) / snippet_root)


self.soc_roots = [Path(ZEPHYR_BASE), Path(ZEPHYR_BASE) / 'subsys' / 'testsuite']
self.dts_roots = [Path(ZEPHYR_BASE)]
self.arch_roots = [Path(ZEPHYR_BASE)]

for module in modules:
soc_root = module.meta.get("build", {}).get("settings", {}).get("soc_root")
if soc_root:
self.soc_roots.append(os.path.join(module.project, soc_root))
dts_root = module.meta.get("build", {}).get("settings", {}).get("dts_root")
if soc_root:
self.dts_roots.append(os.path.join(module.project, dts_root))
arch_root = module.meta.get("build", {}).get("settings", {}).get("arch_root")
if arch_root:
self.arch_roots.append(os.path.join(module.project, arch_root))

self.hwm = None

self.test_config = options.test_config if options else None
Expand Down
4 changes: 2 additions & 2 deletions scripts/pylib/twister/twisterlib/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ def add_configurations(self):
# Note, internally in twister a board root includes the `boards` folder
# but in Zephyr build system, the board root is without the `boards` in folder path.
board_roots = [Path(os.path.dirname(root)) for root in self.env.board_roots]
lb_args = Namespace(arch_roots=[Path(ZEPHYR_BASE)], soc_roots=[Path(ZEPHYR_BASE),
Path(ZEPHYR_BASE) / 'subsys' / 'testsuite'],
lb_args = Namespace(arch_roots=self.env.arch_roots, soc_roots=self.env.soc_roots,
board_roots=board_roots, board=None, board_dir=None)

v1_boards = list_boards.find_boards(lb_args)
v2_dirs = list_boards.find_v2_board_dirs(lb_args)
for b in v1_boards:
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/twister/test_testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ def test_testplan_add_configurations(
p3_yamlfile = tmp_p3_dir / 'p3_B.conf'
p3_yamlfile.write_text('')

env = mock.Mock(board_roots=[tmp_board_root_dir])
env = mock.Mock(board_roots=[tmp_board_root_dir],soc_roots=[tmp_path], arch_roots=[tmp_path])

testplan = TestPlan(env=env)

Expand Down

0 comments on commit de0f972

Please sign in to comment.