Commit graph

5615 commits

Author SHA1 Message Date
Wilfried Chauveau
5ad5af3713 scripts: twisterlib: Fix warning about deprecation of truthiness
Python 3.12 warns that

> Testing an element's truth value will raise an exception in future
> versions. Use specific 'len(elem)' or 'elem is not None' test instead.
>    if elem_ts := root.find('testsuite'):

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2024-09-12 10:03:44 +02:00
Wilfried Chauveau
deeec33934 scripts: twister: Solve deprecation notice when running tests
CONF_FILE, DTC_OVERLAY_FILE and OVERLAY_CONFIG are deprecated but still
used by the tests causing warnings when running them.

This adds a test_data specific to validate the emission of the warning,
and removes the offending args from the other test_data files.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2024-09-12 10:03:44 +02:00
Wilfried Chauveau
28add0cd36 scripts: twister: check for deprecation notice for space-separated lists
Space separated lists are deprecated but this notice is not checked for.
extract_fields_from_arg_list also converts lists back to space-separated
lists causing a warning on get_scenario

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2024-09-12 10:03:44 +02:00
Tobias Pisani
73c8235881 west: runners: Implement the west rtt command for jlink
Moves the telnet client into runners/core.py as well, as this is now shared
between openocd and jlink.

Signed-off-by: Tobias Pisani <mail@topisani.dev>
2024-09-10 12:39:42 -04:00
Tobias Pisani
18f45b5f06 west: runners: Implement the west rtt command for openocd
This was non-trivial, as openocd is a bit weird to work with. Using only
commands passed with '-c' arguments, I couldn't get it to reliably resume
(or just not halt) the target when started. I tried using the 'sleep'
command, and various 'configure -event XX { resume }' events, but nothing
panned out, as it seems to always halt after all `-c` commands have been
run.

To avoid that, this waits for the TCL RPC port to be up, and sends a
resume command there. This works reliably.

Signed-off-by: Tobias Pisani <mail@topisani.dev>
2024-09-10 12:39:42 -04:00
Tobias Pisani
b3b8360f39 west: runners: Add west rtt command with pyocd implementation
This command runs separately from a debug server, instead of attaching
to a running server. This is both the easiest out of the box experience,
and also should be possible to implement consistently for most runners.

This commit includes an initial implementation for pyocd.

Signed-off-by: Tobias Pisani <mail@topisani.dev>
2024-09-10 12:39:42 -04:00
Maciej Perkowski
c743821f96 twister: fix dts path for module
Fixes twister with modules (TypeError for undefined dts_root)

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2024-09-10 11:42:51 +02:00
Dmitrii Golovanov
d9f567051e ci: elasticsearch: Upload script improvements
Multiple improvements of the `upload_test_results_es.py` script:

 * JSON objects flattening.

   This feature allows `twister.json` file preprocessing to simplify
   its Elasticsearch index structure for complex hierarhical objects,
   for example with memory footprint, or code coverage data.

   A new command line option `--flatten` is added to change testsuite data
   structure in regard of one of its list objects: either `testcases` or
   `recording`, so each item there becomes an independent data record
   inheriting all other testsuite properties, whereas the children
   object's properties are renamed with the parent object's name
   as a prefix: 'testcases_' or 'recording_' respectively.
   Only one testsuite property can be flattened this way per index upload.
   Other children objects will be treated accorging to the index structure.

   Related new command line options (with help text explanations):
    `--flatten-dict-name`,
    `--flatten-list-names`,
    `--flatten-separator`,
    `--transpose-separator`,
    `--escape-separator`

 * A new command line option `--transform` is added to allow regexp group
   parsing in string propertites extracting additional derived properties.

 * A new command line option `--exclude` is added to exclude testsuite
   properties not needed to store at Elasticsearch index.

 * Branch name `--run-branch` and Workflow ID `--run-workflow` command
   line options as additional key fields to allow data from different
   branches, workflows and triggering events in the same index.

 * A new command line option `--map-file` is added to apply
   an explicit index structure to the `twister.json` input data.

 * Add bulk operation timeout parameter for heavy/long uploads.

Other changes:
  * batch upload error handling and logging;
  * inline documentation improvements;
  * some corner case fixes on empty objects.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-09-09 15:24:26 +03:00
Jamie McCrae
9354e181d6 scripts: ci: check_compliance: Add MCUboot Kconfig
Adds a Kconfig used by MCUboot to the allow list

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-09-09 15:23:16 +03:00
Lukasz Mrugala
345eb8e94a scripts: twister: Elevate Status Error
Status errors previously logged an error, but didn't fail the running test.
This commit changes that
 and introduces a new StatusAttributeError to use there.

One test is modified so it follows proper status form.
One test for the new error has been added.

Status errors now will properly mark the Instance as ERROR
and not run TestCases as SKIP.
This necessitated some code layout changes in runner.py

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-09-09 09:28:37 +02:00
Pieter De Gendt
5a3c9c914a scripts: pylib: twister: Write version to testplan.json
The twister environment version is already set, write it to the
testplan.json file.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-09-06 11:31:57 -04:00
Piotr Kosycarz
f0bfaa4c19 scripts: pylib: twister: fix missing newlines at handler.log
Keep new lines at handler.log.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2024-09-04 19:07:19 -04:00
Attie Grande
e6dc930322 bindesc: Add support for the build version values
This patch adds bindesc support for the build version values for the
kernel and application - BUILD_VERSION and APP_BUILD_VERSION.

The kernel's BUILD_VERSION can be overridden at build time.

Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
2024-09-04 07:03:47 -04:00
Grzegorz Chwierut
392304706b twister: Pass device flash timeout to pytest-harness.
Pass flashing timeout to pytest-harness and use them

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-09-03 10:41:45 +02:00
Vinicius Miguel
0492235d0d scripts: ci: Fix crash when vendor list is malformed
Also introduces friendly error message.

Signed-off-by: Vinicius Miguel <vmiguel1@gmail.com>
2024-09-02 12:03:03 +02:00
Anas Nashif
d145db01b4 twister: setup soc/arch roots based on module settings
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 <anas.nashif@intel.com>
2024-08-30 11:46:41 -04:00
Johan Hedberg
5562bb9c3a scripts: zephyr_module: Add Kconfig symbol for blobs presence
For any module that defines blobs, add a new Kconfig symbol to indicate
whether the blobs have been fetched or not. Example output for the
hal_silabs module:

   # (no blobs present)
  $ scripts/zephyr_module.py --kconfig-out=/dev/stdout \
    -m ../modules/hal/silabs
  menu "hal_silabs (../modules/hal/silabs)"
  osource "/Users/johedber/src/zephyr/modules/hal/silabs/zephyr/Kconfig"
  config ZEPHYR_HAL_SILABS_MODULE
  	bool
  	default y
  config ZEPHYR_HAL_SILABS_MODULE_BLOBS
  	bool
  endmenu
  $ west blobs fetch hal_silabs
   # (blob fetching output)
  $ scripts/zephyr_module.py --kconfig-out=/dev/stdout \
    -m ../modules/hal/silabs
  menu "hal_silabs (../modules/hal/silabs)"
  osource "/Users/johedber/src/zephyr/modules/hal/silabs/zephyr/Kconfig"
  config ZEPHYR_HAL_SILABS_MODULE
  	bool
  	default y
  	select TAINT_BLOBS

  config ZEPHYR_HAL_SILABS_MODULE_BLOBS
  	bool
  	default y
  endmenu

The generated output for modules which do not define blobs is not affected.

Having this additional symbol for blobs lets us specify Kconfig
dependencies for features which require the blobs to be present.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-08-30 11:45:56 -04:00
Andrej Butok
3f5fc42fba runners: linkserver: Add .elf support to the linkserver flash command
As the .bin & .hex build output is optional
and it can be disabled by CONFIG_BUILD_OUTPUT_BIN/HEX,
add support for the mandatory .elf build output
to the linkserver runner flash command.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-29 11:37:54 +02:00
Pieter De Gendt
2c496c094b scripts: ci: Fix clang-format compliance for additions or removals
If a diff only has added or removed lines we need to match both '-' and '+'
characters in the hunk context.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-28 16:35:20 -04:00
Anas Nashif
a5e3c0a792 ci: do not run twister on some script changes
Do not run twister on some script changes that do not require a twister
run.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-08-28 13:58:56 -04:00
Dmitrii Golovanov
87c1e2a40f twister: Group test plan reporting options
Re-arrange Twister command line options for test plan reporting
to a dedicated group with mutally-exclusive options to reflect
actual implementation and its dry-run execution mode.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-08-27 15:13:52 -04:00
Anas Nashif
4077249cc7 ci: rerun issue check on PR edit
Re-run issue check when a PR is updated, i.e. when someone adds
'Fixes...` to the PR body.

This is mostly for release branches and has no effect on main branch.

Also, add concurrency check in the workflow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-08-27 11:33:55 -04:00
Torsten Rasmussen
35e28e6315 scripts: handle auto defined ZEPHYR_<name>_MODULE settings in compliance
Update check_compliance to handle auto defined ZEPHYR_<name>_MODULE
Kconfig symbols.

check_compliance runs three levels of Kconfig check.
A basic and a full, both which uses the generated Kconfig.modules
created according to Zephyr modules present.

A Kconfig check where no Zephyr modules are sourced. This check ensures
that Zephyr Kconfig tree doesn't refer to Kconfig symbols defined in
Zephyr module's local Kconfig trees.

However, there are a few auto generated symbols which are allowed,
such as: `ZEPHYR_<name>_MODULE` and `ZEPHYR_<name>_MODULE_BLOBS`.

Therefore, when testing no blobs, filter the generated Kconfig.modules
file, so that no sourcing of extra Kconfig files are performed but
lines defining `ZEPHYR_<name>_MODULE` and `ZEPHYR_<name>_MODULE_BLOBS`
are preserved.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-08-27 10:50:08 -04:00
Sven Ginka
63f8f7ff2a scripts: RISCV instruction SEPC
In RISCV "sepc" is actually the name of an instruction.
As this prevents building. We should remove the line.

Signed-off-by: Sven Ginka <s.ginka@sensry.de>
2024-08-27 10:48:58 -04:00
Pieter De Gendt
fda5ca34c2 scripts: ci: Fix clang-format notice at file beginning/end
The clang-format check outputs a git diff with surrounding context. It
naively removed the first and last 3 lines, but this does not work if
there are less lines.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-27 12:45:21 +02:00
Andrej Butok
c1fe3150e9 runners: pyocd: Add support for .elf files to the pyocd flash command
As the .bin & .hex build output is optional
and it can be disabled by CONFIG_BUILD_OUTPUT_BIN/HEX,
add support for the mandatory .elf build output
to the pyocd runner flash command.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-27 12:44:55 +02:00
Anas Nashif
b2a9fca9c8 ci: twister: remove reference to opensearch
We have been using elasticsearch for a while now. Remove references and
old script.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-08-27 12:44:31 +02:00
Pieter De Gendt
1f7c9605cb scripts: Minimum clang-format version
Set the minimum supported clang-format version to v15.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-26 14:39:02 -04:00
Reto Schneider
7f1c3d1841 twister: runner: j-link: Fix parameter passing
To specify the serial number, JLink expects either one argument
('--dev-id=xxx') or two (e.g. '--dev-id' 'xxx'), but it can not deal
with a single one that is '--dev-id xxx'.

The problem has been introduced (or just made visible?) by commit
5ee4284320 (twister: runner: j-link: use
dev-id instead of SelectEmuBySN) in PR #76931.

How to reproduce:

1. Create a HW configuration map, e.g.:

```
$ cat zephyr-hw-map-nrf52840dk-1.yml
- connected: true
  id: '683517317'
  platform: nrf52840dk/nrf52840
  product: nRF52840 DK 1
  runner: jlink
  serial: /dev/ttyACM-nrf-dk-1
```

2. Run test `logging.dictionary` with Twister:

```
$ west twister --platform nrf52840dk/nrf52840 --device-testing \
  --hardware-map zephyr-hw-map-nrf52840dk-1.yml -s logging.dictionary
```

3. The build will fail, and the `twister_harness.log` contains:

```
10:21:24.375:DEBUG:twister_harness.device.factory: Get device type
  "hardware"
10:21:24.375:DEBUG:twister_harness.device.hardware_adapter: Opening
  serial connection for /dev/ttyACM-nrf-dk-1
10:21:24.376:DEBUG:twister_harness.device.hardware_adapter: Flashing
  device 683517317
10:21:24.376:DEBUG:twister_harness.device.hardware_adapter: Flashing
  command: <snip>/bin/west flash --skip-rebuild --build-dir
  twister-out/<snip>/tests/subsys/logging/dictionary/logging.dictionary
  --runner jlink '--dev-id 683517317'
10:21:24.590:ERROR:twister_harness.device.hardware_adapter: Could not
  flash device 683517317
10:21:24.592:DEBUG:twister_harness.device.hardware_adapter: Closed
  serial connection for /dev/ttyACM-nrf-dk-1
```
(note the '--dev-id 683517317' part)

4. Running the stated `west flash` command shows the following error
   message:

```
-- west flash: using runner jlink
FATAL ERROR: runner jlink received unknown arguments: ['--dev-id
  683517317']
```

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-08-26 17:07:40 +02:00
Grzegorz Chwierut
892b25aece twister: tests: Add unit test for readline method in handler
Check if lines from serial are processed one by one
in case when was received in one buffer from redline method.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-08-24 07:15:17 -04:00
Grzegorz Chwierut
79ef0b6b10 twister: scripts: Split lines before processing
Readline method sometimes receives more lines in buffer.
Split them to avoid misinterpreting data in harness module.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-08-24 07:15:17 -04:00
Grzegorz Chwierut
fcf17dd17e twister: pytest: Change the order or pytest-args
Use pytest-args parameters provided in command line after
parameters taken from yaml file. The last occurence is
considered by argparse, so parameters from command line
will be used.

Fixes: #77319

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-08-23 15:50:19 +01:00
Rubin Gerritsen
fb745f610f arch posix: Implement arch_thread_name_set()
This will update the posix thread names to match
the zephyr thread names.

This will simplify debugging as the debugger will
recognize the thread names.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-08-23 08:01:33 -04:00
Yuval Peress
bfb893a0c5 gtest: Add support for gtest 1.15.0
The gtest 1.15 has slightly different output from the original one that
was used to set up the harness. With this change we support both output
formats.

Fixes #72318

Signed-off-by: Yuval Peress <peress@google.com>
2024-08-23 09:54:41 +02:00
Emanuele Di Santo
b511704dd8 scripts: west: runners: add initial nRF92 support
Add initial support flashing and erasing the application and
radio cores of the nRF9280.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2024-08-22 14:24:38 -04:00
Benjamin Cabé
a0287cac7f scripts: coccinelle: add errno as a reserved name
errno is defined by the ISO C standard to be a modifiable lvalue of type
int, and **must not be explicitly declared**

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-08-22 14:21:53 -04:00
Anas Nashif
420ffdd8a8 ci: compliance: in case of too many errors, send as a single failure
Do not try to format each single failure, this will take too long to
process and will run for hours and spam GH.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-08-22 14:20:50 -04:00
Arkadiusz Cholewinski
65051c8a24 Coverage Analysis: Update Test Case Status
Modify the condition in the parse_testplan
function to align with the changes in the Status class.

Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
2024-08-22 08:49:28 -04:00
TOKITA Hiroshi
eb675eb281 scripts: west_commands: completion: zsh: Add minimum support for sdk
Add minimum support for the `west sdk` command.
This only provides completion for the `sdk` command itself.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-08-21 16:54:56 -04:00
TOKITA Hiroshi
85ffd1e031 scripts: west_commands: completion: fash: Add support for west sdk
Add a feature for completion of the `west sdk` command.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-08-21 16:54:56 -04:00
TOKITA Hiroshi
af5850d44a scripts: west_commands: completion: bash: Add support for west sdk
Add a feature for completion of the `west sdk` command.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-08-21 16:54:56 -04:00
TOKITA Hiroshi
b68071dc71 commands: add the 'sdk' command to manage SDK.
This command can list and install SDK.

Run 'west sdk install' to install the SDK.
Run without any parameter, installing
specified by SDK_VERSION in the source tree.
'west sdk' to show installed SDK information.

This command is just a wrapper for SDK's setup command,
but it simplifies the installation process. It will be a good
improvement for onboarding first-time users.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-08-21 16:54:56 -04:00
Pieter De Gendt
8fcccf1aad scripts: ci: Fix clang-format compliance on Windows
Clang-format installs an exe instead of a python script.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-21 18:29:24 +01:00
Pieter De Gendt
dde46a94ba scripts: ci: compliance: ClangFormat only check .c/.h files
The clang format compliance check should only be applied to .c and .h
files.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-20 19:07:48 -04:00
Andrej Butok
e767ac0703 runners: jlink: Add support for .elf files to the jlink flash command
The .bin & .hex build output is optional and can be disabled by
CONFIG_BUILD_OUTPUT_BIN/HEX.
Add support for the mandatory .elf build output
to the jlink runner flash command.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-20 18:59:26 -04:00
Pieter De Gendt
862c16aa5b scripts: Remove duplicate clang-format pip package
clang-format runs in CI and is needed for compliance.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-08-20 18:57:57 -04:00
Michael Arnold
5ee4284320 twister: runner: j-link: use dev-id instead of SelectEmuBySN
The serial number for debugger selection over USB
can be selected with the dev-id. This change
reflects also more the workflow of west flash
with J-Link.
The usage of SelectEmuBySN breaks the support for
J-Link over IP with twister.

Signed-off-by: Michael Arnold <marnold@baumer.com>
2024-08-20 14:52:48 -04:00
Tomi Fontanilles
4ea0e88687 scripts: ci: check_compliance: allow Kconfig references with '(' and '.'
For regexes such as `CONFIG_DEBUG_(OPTIMIZATIONS|INFO)` and
to be able to use `.*` as this syntax is used in the Kconfig search.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-08-19 21:50:10 -04:00
Arkadiusz Cholewinski
150a7cd810 twister: Add Nuvoton to manufacturer
Expand manufacturer table in hardwarempa.py to include Nuvoton.

Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
2024-08-19 17:22:42 -04:00
Grzegorz Chwierut
7cca59c81a twister: pytest: Allow using pytest-args from command file and yaml
Extend pytest-args from configuration yaml file with args
from command line instead of overwriting.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-08-19 10:00:47 -04:00