Commit graph zephyr/scripts
Author SHA1 Message Date
Jordan Yates
f8eb167619 scripts: ci: simple ruff formatting
Basic `ruff` format operations to allow CI to enforce from now on.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
3f77560b92 scripts: ci: test_plan: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
2186558f37 scripts: ci: coverage: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
3a165b6f5d scripts: ci: stats: merged_prs: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
764ad5562a scripts: ci: version_mgr: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
dc1c23312d scripts: ci: errno: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
f2af864712 scripts: ci: check_compliance: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Jordan Yates
4c6bbae9cc scripts: ci: guideline_check: fix ruff reports
Fix problems reported by `ruff` and remove exclusions from the config
file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-21 10:08:50 +02:00
Anas Nashif
909373f10c scripts: set_assignee: get area object before before collabs
In the manifest case, we were operating on a str instead of the area
object.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-20 06:05:26 -05:00
Lukasz Fundakowski
3a1428f957 twister: Keep pytest output formatting in log
Fixed formatting of pytest output in log by not removing
leading whitespaces.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-11-20 06:02:15 -05:00
Anas Nashif
75f69425dd ci: tags: add posix headers to posix group in tags
When posix headers change, make sure we verify the posix portability
layer.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-19 09:18:36 -05:00
Anas Nashif
c55d2eafff scripts: get_maintainer: file group pattern inherit top area patterns
File groups inherit file patterns from their parent area. A file will only
match a file group if it first matches the parent area's patterns, and then
also matches the file group's own patterns. This allows file groups to
further filter and subdivide files that are already covered by the area.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-18 17:44:53 -05:00
Anas Nashif
19cb7f031b scripts: set_assignee: request review from maintainers of changed areas
Also request reviewes from maintainers of changes areas in the
maintainer file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-18 17:44:53 -05:00
Anas Nashif
616e8d6602 scripts: move set_assignee.py into scripts/ci
Scripts only used by CI, so move it into that directory.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-18 17:44:53 -05:00
Anas Nashif
c4b9497b3d scripts: set_assignee.py: Support file groups
Deal with new section in the maintainer file defining file groups.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-18 17:44:53 -05:00
Anas Nashif
9165fb4927 scripts: get_maintainer: support file groups
This new section allows defining a group of files in an area and makes
it possible to assign collaborators to the file group being defined.

The purpose of this new section is to allow fine tuning who is added as
reviewer when files change in a group. It is especially useful in large
areas with hundreds of files, for example platform areas.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-18 17:44:53 -05:00
Mirai SHINJO
039013f8ef scripts: west_commands: patch: treat all subprocess output as text
Pass 'encoding="utf-8"' to all 'subprocess.run()' calls.
This treats the captured stdout and stderr streams as text rather than
byte sequences.

Example without this patch:
west patch apply --roll-back
ERROR: b'error: patch failed: examples/csp_server_client.py:32\n
error: examples/csp_server_client.py: patch does not apply\n'
FATAL ERROR: failed to apply patch libcsp/test.patch

Example with this patch:
west patch apply --roll-back
ERROR: error: patch failed: examples/csp_server_client.py:32
error: examples/csp_server_client.py: patch does not apply

FATAL ERROR: failed to apply patch libcsp/test.patch

Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
2025-11-17 09:27:56 +02:00
Mirai SHINJO
634b45eddd scripts: west_commands: patch: capture subprocess output in apply() method
Pass 'capture_output=True' to the 'subprocess.run()' call in the 'apply()'
method.
This ensures that stdout and stderr are captured, so 'proc.stderr'
is not 'None' when 'self.err()' is called on a failed process.

Example without this patch:
west patch apply --roll-back
error: patch failed: examples/csp_server_client.py:32
error: examples/csp_server_client.py: patch does not apply
ERROR: None
FATAL ERROR: failed to apply patch libcsp/test.patch

Example with this patch:
west patch apply --roll-back
ERROR: b'error: patch failed: examples/csp_server_client.py:32\n
error: examples/csp_server_client.py: patch does not apply\n'
FATAL ERROR: failed to apply patch libcsp/test.patch

Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
2025-11-17 09:27:56 +02:00
Daniel Leung
fb055ea77e logging: dictionary: format scripts with ruff
Simple formatting via ruff on dictionary logging scripts.
No manual editing was done on the scripts.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-11-15 11:38:48 +01:00
Anas Nashif
95b48cd5ba west_commands: do not depend on CONFIG_SOF
Do not depend on SOF config, use RIMAGE_SCHEMA instead, defined in SOF.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-15 11:28:47 +01:00
Sebastian Bøe
70f6cf7ea0 soc: nordic: uicr: Move GEN_UICR options into the main Zephyr tree
I initially added the GEN_UICR options to the gen_uicr image's Kconfig
tree only to not pollute the main tree.

But there is a lot of useful help text in the GEN_UICR option's
Kconfig file that I would like users to be able to read/reference from
the docs.

To not increase the complexity of the Kconfig doc generator, we add
the GEN_UICR options to the main tree and have them all be disabled
for builds other than the gen_uicr image.

Being in the main tree has the added benefit of being recognzied by
the compliance checker.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2025-11-14 15:26:06 +02:00
Lukasz Fundakowski
03eff37921 twister: Remove unnecessary code
Removed some old code which is not used/needed any more.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-11-14 15:25:41 +02:00
Lukasz Fundakowski
bd187425f7 twister: Don't print full stack trace in readlines_until method
The readlines_until method is part of the testing framework
(pytest harness) and should not print a full stack trace
when the expected line isn't found. It should also raise
an AssertionError instead of a TwisterHarnessTimeoutException,
allowing users to know that a test failed because the expected
condition did not happen.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
2025-11-14 15:25:41 +02:00
Carles Cufi
ffe2028dcf scripts: runners: Enable reusing the core dry run logic
In order to avoid duplication of logic in runners, allow subclasses
of ZephyrBinaryRunner to set self.dry_run so that they can then reuse
the logic in core.py to log instead of execute.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-11-14 09:25:32 +01:00
Carles Cufi
48e0481746 scripts: runners: Generalize the --dry-run option
Move the argparse.add_argument() call to the abstract base class and
augment the RunnerCaps class with a dry_run parameter.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-11-14 09:25:32 +01:00
Grzegorz Chwierut
b33387c44a scripts: twister: Add support for passing extra serial port to pytest
Extend twister's device serial handling to support multiple serial ports
for pytest-based tests. This enables testing scenarios that require
communication with multiple UART interfaces on the same device.
This enhancement enables comprehensive testing of multi-UART devices
while maintaining backward compatibility with single serial setups.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2025-11-13 20:42:31 -05:00
Appana Durga Kedareswara rao
639739169e twister: handlers: pass platinfo to serialPTY reorder pre-script execution
This commit makes two key improvements to the DeviceHandler:

1. Pass TWISTER_PLATFORM environment variable to serial PTY scripts
   - Enables serial PTY scripts to access platform-specific configuration
   - The platform name is now available via TWISTER_PLATFORM env variable
   - Allows board-specific serial port and baudrate configuration in
     external serial forwarding scripts

2. Reorder pre-script execution before serial PTY initialization
   - Moved pre-script execution before serial PTY setup to avoid conflicts
   - Prevents race conditions when pre-script performs board power cycling
     or reset operations that might interfere with active serial
     connections

These changes enable more flexible hardware testing scenarios where:
- Serial configuration can be automatically selected based on board type
- Board initialization (power cycling, FPGA programming) completes
  before establishing serial connections

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
2025-11-13 23:19:28 +02:00
Jordan Yates
5e5ac8e078 llext: optional syscall symbol exports
Make the export of syscall symbols optional.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-13 23:19:19 +02:00
Patryk Koscik
8b20699475 west: boards: remove arch format option
HWMv2 boards do not support this field

Signed-off-by: Patryk Koscik <pkoscik@antmicro.com>
2025-11-13 23:14:53 +02:00
Gerhard Jörges
b7d2355dbf west: completion: change skip-rebuild to no-rebuild
the west flash --skip-rebuild option was changed to --no-rebuild in
de6b5dba60

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2025-11-13 23:13:48 +02:00
Benjamin Cabé
4a1d4b0c19 twister: harness: display_capture: drop requirements.txt
This requirements file can be confusing and will only get stale over
time. Drop it since these dependencies are actually captured in
scripts/requirements-run-test.txt

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-11-13 23:11:32 +02:00
Benjamin Cabé
dc0b225919 twister: harness: display_capture: remove duplicate code
Introduce a helper function to check if an exception is expected in
headless environment.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-11-13 23:11:32 +02:00
Benjamin Cabé
4b67237aaa twister: harness: display_capture: remove unnecessary "noqa: B007"
Properly ignore the unused loop variable

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-11-13 23:11:32 +02:00
Benjamin Cabé
53649a4f76 twister: harness: display_capture: remove unused fields from UVCCamera
This removes a few unused fields from the UVCCamera class.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-11-13 23:11:32 +02:00
Jamie McCrae
d884a097cd scripts: utils: Remove hwmv1 migration script
HWMv2 was introduced in v3.7, and HWMv1 support was removed in v4.2
so this script is no longer needed

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-11-13 23:09:55 +02:00
Yves Wang
c46454781a ci: compliance: update dts-linter to 0.3.6
Update dts-linter to 0.3.6 and dts-lsp to 0.6.7

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2025-11-11 19:47:38 +02:00
Yves Wang
14bba90725 ci: compliance: call dts linter safely under windows
subprocess run without shell requires npx shim under windows.

Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
2025-11-11 19:47:38 +02:00
Yasushi SHOJI
6d6508ae12 scripts: kconfig: gnuconfig: Ignore loc
The commit 125d0daaa1 added 'loc' to the sym.ranges tuples and fixed
kconfiglib.py but guiconfig.py is left untouched. This make menuconfig to
die with:

  Exception in Tkinter callback
  Traceback (most recent call last):
    File "/usr/lib/python3.13/tkinter/__init__.py", line 2077, in __call__
      return self.func(*args)
             ~~~~~~~~~^^^^^^^
    File ".../scripts/kconfig/guiconfig.py", line 917, in _tree_double_click
      return _tree_enter(event)
    File ".../scripts/kconfig/guiconfig.py", line 942, in _tree_enter
      _change_node(node, tree.winfo_toplevel())
      ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File ".../scripts/kconfig/guiconfig.py", line 1125, in _change_node
      s = _set_val_dialog(node, parent)
    File ".../scripts/kconfig/guiconfig.py", line 1219, in _set_val_dialog
      range_info = _range_info(sym)
    File ".../scripts/kconfig/guiconfig.py", line 1339, in _range_info
      for low, high, cond in sym.ranges:
          ^^^^^^^^^^^^^^^
  ValueError: too many values to unpack (expected 3)

This commit ignores the last element in the tuples.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2025-11-11 12:46:17 -05:00
Yasushi SHOJI
090d294ae0 scripts: kconfig: menuconfig: Ignore loc
The commit 125d0daaa1 added 'loc' to the sym.ranges tuples and fixed
kconfiglib.py but menuconfig.py is left untouched. This make menuconfig to
die with:

  Traceback (most recent call last):
    File ".../scripts/kconfig/menuconfig.py", line 3284, in <module>
      _main()
      ~~~~~^^
    File ".../scripts/kconfig/menuconfig.py", line 663, in _main
      menuconfig(standard_kconfig(__doc__))
      ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File ".../scripts/kconfig/menuconfig.py", line 732, in menuconfig
      print(curses.wrapper(_menuconfig))
            ~~~~~~~~~~~~~~^^^^^^^^^^^^^
    File "/usr/lib/python3.13/curses/__init__.py", line 94, in wrapper
      return func(stdscr, *args, **kwds)
    File ".../scripts/kconfig/menuconfig.py", line 872, in _menuconfig
      _change_node(sel_node)
      ~~~~~~~~~~~~^^^^^^^^^^
    File ".../scripts/kconfig/menuconfig.py", line 1586, in _change_node
      s, _range_info(sc))
         ~~~~~~~~~~~^^^^
    File ".../scripts/kconfig/menuconfig.py", line 3119, in _range_info
      for low, high, cond in sym.ranges:
          ^^^^^^^^^^^^^^^
  ValueError: too many values to unpack (expected 3)

This commit ignores the last element in the tuples.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2025-11-11 12:46:17 -05:00
Jordan Yates
c127388eaf scripts: build: mergehex: fix --output-bin
Stop `--output-bin` from consuming the first trailing argument that
should have been in `input_files`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-07 19:23:26 +02:00
Abderrahmane JARMOUNI
5be6aa13b9 scripts: pylib: twister: expr_parser: some enhancements
Rename dt_node_prop_enabled filtering expression to
dt_nodelabel_prop_enabled as it takes a node label as a 1st argument.

Enhance dt_node_has_prop inline doc and param name.

Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
2025-11-06 15:49:28 +02:00
Mathieu Choplain
f36f8d4fb9 runners: stlink_gdbserver: expose --external-init as runner argument
3cc9a843e8 added '--external-init' to the GDB
Server command line whenever an external loader is provided, but it is not
a *necessary* argument and sometimes causes issues.

Provide a new runner argument "--external-init" (for consistency) which
controls whether or not the argument is added to command line if an
external loader is used. (It is otherwise ignored)

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-04 13:50:56 -05:00
Mathieu Choplain
f890286d8e runners: stlink_gdbserver: make it possible to disable SWD mode
The "--swd" argument had both an action='store_true' and default value of
True so it wasn't possible to disable it: providing the argument would set
its value to True, and not providing it would use the default=True!

Add a new argument "--no-swd" which shares its destination variable with
"--swd", but with action='store_false', such that either can be provided
to enable/disable SWD mode. Both arguments are placed in a mutually
exclusive group and use a common help message.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-04 13:50:56 -05:00
David Leach
01e3b167af west: blobs: fix UnicodeDecodeError on Windows
Ensure the blobs command is trying to display the license file for
click-through approval. Ensure that special characters doesn't
cause a problem in Windows by opening the file with utf-8 encoding.

Fixes #98520

Signed-off-by: David Leach <david.leach@nxp.com>
2025-11-04 07:06:08 -05:00
Chris Friedt
e4d193b5ed scripts: coccinelle: add fork as a reserved name
`fork()` is defined by POSIX and for creating a new child process.

It is the preferred method of doing so on systems with virtual memory and
the symbol should not be used outside of the context defined by the
POSIX standard.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-11-01 08:39:26 -04:00
Kyle Bonnici
d18c4db7f1 CI: dts-linter: Move package.json to ./scripts/ci
Move package.json and package-lock.json to ./scripts/ci

Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
2025-10-31 22:40:20 +02:00
Benjamin Cabé
1e8a5f7dd0 doc: twister: add/move doc for display harness
The display harness initial documentation was a separate, stale (had
references to a personal Github repo), README.rst buried in the
twister/scripts folder.
Move the docs to be a "first class" part of the Twister documentation
alongside other harnesses.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-10-31 10:36:57 -04:00
Pieter De Gendt
ed92ee5064 scripts: Bump ruff to 0.14.2
Update the ruff version to the latest 0.14.2 and update the excluded files
to match with the last checks for linter and formatting issues.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-30 15:16:25 +02:00
Carles Cufi
093bb9972c scripts: compliance: Harden the execution of npx
Instead of relying on various exceptions that can happen when one tries
to execute a program that is not installed in the system (typically
FileNotFoundError but sometimes PermissionError), use shutil.which() to
ensure the npx executable is available before running it.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-10-30 15:13:53 +02:00
WenBin Zhang
a43f48b15e twister: Enhanced Filtering Command Help
Collect filter commands into a single location and sort them in the
order: arch, vendor, platform, pattern, filter, tag. This enhances
the readability of help information and reduces the time spent
searching for filter command options.

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-10-28 20:27:20 -04:00