Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport v3.7-branch] twister: setup soc/arch roots based on module settings #77822

Open
wants to merge 1 commit into
base: v3.7-branch
Choose a base branch
from

Conversation

zephyrbot
Copy link
Collaborator

Backport d145db0 from #77163.

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)
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if soc_root:
if dts_root:

Copy link
Contributor

@rexut rexut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure, but using the path names as path-like objects helps to avoid an attribute exception.

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))
Copy link
Contributor

@rexut rexut Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: append with path-like object (PEP 519):

Suggested change
self.arch_roots.append(os.path.join(module.project, arch_root))
self.arch_roots.append(Path(os.path.join(module.project, arch_root)))

OR:

Suggested change
self.arch_roots.append(os.path.join(module.project, arch_root))
self.arch_roots.append(Path(module.project) / arch_root)

otherwise following line will cause AttributeError: 'str' object has no attribute '_closed':

v1_boards = list_boards.find_boards(lb_args)

full traceback:

Traceback (most recent call last):
  File "./zephyr/scripts/twister", line 215, in <module>
    ret = main(options, default_options)
  File "/.../workspace/zephyr/scripts/pylib/twister/twisterlib/twister_main.py", line 124, in main
    tplan.discover()
  File "/.../workspace/zephyr/scripts/pylib/twister/twisterlib/testplan.py", line 197, in discover
    self.add_configurations()
  File "/.../workspace/zephyr/scripts/pylib/twister/twisterlib/testplan.py", line 410, in add_configurations
    v1_boards = list_boards.find_boards(lb_args)
  File "/.../workspace/zephyr/scripts/list_boards.py", line 117, in find_boards
    return sorted(itertools.chain(*find_arch2board_set(args).values()),
  File "/.../workspace/zephyr/scripts/list_boards.py", line 122, in find_arch2board_set
    arches = sorted(find_arches(args))
  File "/.../workspace/zephyr/scripts/list_boards.py", line 138, in find_arches
    for root in unique_paths(args.arch_roots):
  File "/.../workspace/zephyr/scripts/list_hardware.py", line 182, in unique_paths
    yield from dict.fromkeys(map(Path.resolve, paths)).keys()
  File "/usr/lib/python3.8/pathlib.py", line 1179, in resolve
    if self._closed:

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))
Copy link
Contributor

@rexut rexut Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: see arch_roots below

Suggested change
self.dts_roots.append(os.path.join(module.project, dts_root))
self.dts_roots.append(Path(os.path.join(module.project, dts_root)))

OR:

Suggested change
self.dts_roots.append(os.path.join(module.project, dts_root))
self.dts_roots.append(Path(module.project) / dts_root)

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))
Copy link
Contributor

@rexut rexut Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: see arch_roots below

Suggested change
self.soc_roots.append(os.path.join(module.project, soc_root))
self.soc_roots.append(Path(os.path.join(module.project, soc_root)))

OR:

Suggested change
self.soc_roots.append(os.path.join(module.project, soc_root))
self.soc_roots.append(Path(module.project) / soc_root)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Twister Twister Backport Backport PR and backport failure issues
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

4 participants