Commit graph

5615 commits

Author SHA1 Message Date
Grzegorz Swiderski
f0646d3da4 edtlib: Express Node.matching_compat and Node.binding_path as @property
This simplifies the code and makes it clearer that both properties are
defined in terms of the Binding object matched to a given DT node.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
2024-11-25 08:31:18 +01:00
Yong Cong Sin
b1def7145f arch: deprecate _current
`_current` is now functionally equals to `arch_curr_thread()`, remove
its usage in-tree and deprecate it instead of removing it outright,
as it has been with us since forever.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-11-23 20:12:24 -05:00
Pieter De Gendt
86a8dacaa1 scripts: west_commands: Fix MissingProgram import
MissingProgram should be exported in __all__.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-23 15:28:33 +01:00
Josuah Demangeon
d6b8912ad9 scripts: ci: check_compliance: ruff: avoid mixing stdout and stderr
The python subprocess call had a stdout=subprocess.PIPE parameter that
redirects standard output to a pipe, and a stderr=subprocess.STDOUT
parameter that redirected stderr to the pipe. This mixed JSON and
non-JSON output together, and issued an exception. Fixing with
stderr=subprocess.DEVNULL to ignore standard error and only keep the
JSON output.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2024-11-23 02:01:28 +01:00
Pieter De Gendt
336c7dadac scripts: west_commands: runners: Fix line-too-long (E501)
Wrap long lines to max 100 characters.

See https://docs.astral.sh/ruff/rules/line-too-long/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
775db0e63a scripts: west_commands: runners: Fix f-string (UP032)
Replace .format() calls with f-strings.

See https://docs.astral.sh/ruff/rules/f-string/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
bf7f41d880 scripts: west_commands: runners: Sort and format imports (I001)
Apply sorting and formatting rules on imports.

See
https://docs.astral.sh/ruff/rules/unsorted-imports/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
93457b42f9 scripts: west_commands: runners: Fix unused/deprecated imports (F401/UP035)
Remove some imports that are no longer needed.

See
https://docs.astral.sh/ruff/rules/unused-import/
https://docs.astral.sh/ruff/rules/deprecated-import/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
acb2eaacbd scripts: west_commands: runners: Fix non-pep604-annotation (UP007)
Replace Optional types with the | operator.

https://docs.astral.sh/ruff/rules/non-pep604-annotation/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
907a0db599 scripts: west_commands: runners: Fix non-pep585-annotation (UP006)
Use standard library variants for list, dict, tuple, set

See https://docs.astral.sh/ruff/rules/non-pep585-annotation/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
523015b6ef scripts: west_commands: runners: raise-without-from-inside-except (B904)
Pass exceptions up the chain.

See https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
f7902bc817 scripts: west_commands: runners: Fix bare except (E722 & B904)
Catch explicit exceptions and pass them them to the ValueError

See
https://docs.astral.sh/ruff/rules/bare-except/
https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
1e1c7f7c16 scripts: west_commands: runners: Fix mutable-argument-default (B006)
Do not use mutable default arguments.

See https://docs.astral.sh/ruff/rules/mutable-argument-default/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
8055145ad3 scripts: west_commands: runners: Fix super-call-with-parameters (UP008)
Simplify super() calls.

See https://docs.astral.sh/ruff/rules/super-call-with-parameters/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
07342d9b81 scripts: west_commands: runners: Fix if-with-same-arms (SIM114)
Simplify if statements with same arms.

See https://docs.astral.sh/ruff/rules/if-with-same-arms/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
cd02de5df9 scripts: west_commands: runners: Fix reimplemented-builtin (SIM110)
Convert for loop to use any().

See https://docs.astral.sh/ruff/rules/reimplemented-builtin/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
0f54805faa scripts: west_commands: runners: Fix suppressible-exception (SIM105)
Use contextlib to suppress an error.

See https://docs.astral.sh/ruff/rules/suppressible-exception/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
df794b5493 scripts: west_commands: runners: Conditional import
Convert except: pass statement so the conditional import results in a
NoneType.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
7f72dd3a0f scripts: west_commands: runners: Fix f-string-missing-placeholders (F541)
Constant strings should not be f-strings.

See https://docs.astral.sh/ruff/rules/f-string-missing-placeholders/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
c0d08e5212 scripts: west_commands: runners: Fix not-is-test (E714)
Make the "not is" more readable.

See https://docs.astral.sh/ruff/rules/not-is-test/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
02fac6e1c0 scripts: west_commands: runners: Fix multiple statements on one line (E701)
Place if and conditional statements on separate lines.

https://docs.astral.sh/ruff/rules/multiple-statements-on-one-line-colon/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
3a55e8a52f scripts: west_commands: runners: Fix set-attr-with-constant (B010)
Do not use setattr for constants.

See https://docs.astral.sh/ruff/rules/set-attr-with-constant/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
e42d30ef6c scripts: west_commands: runners: Fix printf-string-formatting (UP031)
Replace printf-style string format.

See https://docs.astral.sh/ruff/rules/printf-string-formatting/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
d562731096 scripts: west_commands: runners: Fix redundant-open-modes (UP015)
Don't pass default open mode.

See https://docs.astral.sh/ruff/rules/redundant-open-modes/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
fc5286fe25 scripts: west_commands: runners: Fix useless-object-inheritance (UP004)
Remove object inheritance.

See https://docs.astral.sh/ruff/rules/useless-object-inheritance/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
dbaf01ef28 scripts: west_commands: runners: Ignore open file without ctx (SIM115)
Add noqa to a complex statement with multiple open/close statements.

See https://docs.astral.sh/ruff/rules/open-file-with-context-handler/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
2e39674344 scripts: west_commands: runners: Fix needless-bool (SIM103)
Return the result instead of the if statements.

See https://docs.astral.sh/ruff/rules/needless-bool/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
d397b01338 scripts: west_commands: runners: Fix collapsible-if (SIM102)
Combine multiple nested if statements.

See https://docs.astral.sh/ruff/rules/collapsible-if/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
133665e55a scripts: west_commands: runners: Fix unused-import (F401)
Removed unused import.

See https://docs.astral.sh/ruff/rules/unused-import/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
ddbba0ef4c scripts: west_commands: runners: Fix mixed-spaces-and-tabs (E101)
Use spaces for indentation.

See https://docs.astral.sh/ruff/rules/mixed-spaces-and-tabs/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
a48e37608f scripts: west_commands: runners: Ignore missing abstract decorator (B027)
The empty function is intentional.

https://docs.astral.sh/ruff/rules/empty-method-without-abstract-decorator/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
e8294b4590 scripts: west_commands: runners: Fix assert-false (B011)
Prefer AssertionError instead of assert False.

See https://docs.astral.sh/ruff/rules/assert-false/

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
25be1501ab scripts: west_commands: runners: Fix pylint unbound issues
Variables are possibly unbound, initialize to None.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Pieter De Gendt
aae018be87 scripts: west_commands: runners: Remove obsolete pylint ignores
These ignores were added with an older version of pylint and are
either removed or ignored by default.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-22 17:40:37 +01:00
Dmitrii Golovanov
e11aecaed5 twister: fix Ztest C++ test names extraction from ELF
Fix Ztest test function name extraction from ELF symbols
for C++ compiled binaries where symbol names need additional
'demangling' to match with corresponding test names.

The `c++filt` utility (part of binutils) is called for
demangling when it is needed.

Twister test suite extension and adjustment.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-11-22 08:26:59 -05:00
Dmitrii Golovanov
a72244f2d0 twister: ztest: harness: Fix missed TestCase statuses
Fix a problem of Ztest suite names not taken into account by Twister
to identify a TestCase, so in some situations a Ztest test's status
was not assigned to the proper TestCase and it remains 'None'
whereas the actual status value lost, eventually the resulting total
execution counters not correct.

The issue was observed in these situations:
 * Ztest application with multiple test suites having same test names.
 * Ztest suite is 'skipped' entirely on execution with all its tests.

The proposed solution extends Twister test case name for Ztest to
include Ztest suite name, so the resulting identifier looks like:
   `<test_scenario_name>.<ztest_suite_name>.<ztest_name>`

The above naming scheme now requires ztest_suite_name part to be
provided for `--sub-test` command line option.

Testcase identifiers in twister.json and testplan.json will also
include ztest_suite_name component.

The Twister Ztest(Test) Harness is improved to track all state changes
known from the test application's log for Ztest suites and test cases,
so now it parses log output from a Ztest application more scurpulously.
Regular expressions to match log records are extended and optimized
to compile them only once and, in some cases, fixed (suite summary).

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-11-22 08:26:59 -05:00
Pieter De Gendt
f05deb1aa4 python: Format trivial files where only newlines were missing
Apply formatting on files that only needed adding newlines.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-21 20:10:51 +01:00
Grzegorz Chwierut
e0bd7e7c87 twister: Allow sharing hardware platform between variants
Extended hardware map to share a single board between variants.
To run tests for different variants on the same board
without re-configuring the hardware map file for each variant,
one can use a `platform` atribute as a list of names.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-11-21 14:48:03 +01:00
Chris Friedt
b85e1981c3 west: runners: update the rtt implementation for openocd
Previously, rtt start would always fail because the target
(i.e. firmware) had not been started.

```
Info : rtt: Searching for control block 'SEGGER RTT'
Info : rtt: No control block found
```

When the command is 'rtt', run the binary via gdb before calling
'rtt start'. Firmware calls `SEGGER_RTT_Init()` shortly after
init which allows OpenOCD to find the RTT control block.

Similarly, only start the 'rtt server' after calling
'rtt start' to avoid any potential race conditions
internally within OpenOCD.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-11-21 11:01:55 +00:00
Chris Friedt
9a8ae21a3c west: runners: openocd: mitigate pylint R0201 warning
Previously, there was a warning that the to_num() method can
(and probably should) be unbound from OpenOcdBinaryRunner.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-11-21 11:01:55 +00:00
Chris Friedt
c71e339773 west: runners: jlink: print RTT server port
Similar to how print_gdbserver_message() prints GDB server info
when "west debug" is run, print RTT server info when "west rtt"
is run.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-11-21 11:01:55 +00:00
Chris Friedt
d6f32bb339 cmake: flash: update cmake to support rtt target
Add support for the rtt target so that users can run

`west build -p auto -b <board> -t rtt <app>`

similarly to the way that users can now do so with the debug
target, since the rtt target is supposed to be used in a similar
way.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-11-21 11:01:55 +00:00
Anas Nashif
c3b2f44173 ci: testplan: do not deal with arch changes
This is generating lots of duplication and unnecessary builds when
multiple arches are being changed. Let's stick to basic coverage which
should be enough for PRs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-11-19 22:25:18 -05:00
Pieter De Gendt
1be5c157d9 scripts: ci: check_compliance: Add python lint/format check
Add a compliance test using ruff, for both linting and formatting of
newly added python files.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-19 18:36:54 -05:00
Pieter De Gendt
4db97b5bb6 scripts: Add helper scripts for ruff baseline excludes
Add simple scripts to convert ruff check and ruff format output to
toml exclude sections.

These sections can be used to ignore baseline violations for an existing
codebase.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-19 18:36:54 -05:00
Pieter De Gendt
05c6517fc9 scripts: ci: check_compliance: Add support for end line and column
Reporting or annotating issues can be done on a range rather than a
single line.

Add support for end line and end column.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-19 18:36:54 -05:00
DineshKumar Kalva
eb9eff7018 west: sign: add support for AMD acp_6_0_adsp board.
Add support for signing acp_6_0 SOF with Zephyr images with rimage.

Signed-off-by: DineshKumar Kalva <DineshKumar.Kalva@amd.com>
2024-11-19 17:53:11 -05:00
Anas Nashif
01ff1de91a ci: testplan: resolve board files when testing with targets
When using the -p option, changes to boards are irrelevant. This is true
in the clang workflow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-11-19 09:54:28 -05:00
Florian Grandel
becd9e5b92 scripts: dts: edtlib: fix type docs
The return type of 'uint8-array' properties was not yet documented.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2024-11-18 19:30:57 -05:00
Florian Grandel
be4acee09a scripts: dts: edtlib: type hints
Adds type hints to functions that were not yet typed.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2024-11-18 19:30:57 -05:00