Commit Graph

591 Commits

Author SHA1 Message Date
Maciej Perkowski a033ba65d2 twister: Add warning to the "-footprint-from-buildlog" flag
The flag won't work with sysbuild since there is no way to
reliably tell to a parser which data came from which image.

fixes: #74092

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2024-06-28 21:12:57 -04:00
Jordan Yates 07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Marcin Niestroj efcc0ed27f scripts: pytest: execute 'zephyr.exe' in application build directory cwd
Execute 'zephyr.exe' in application build directory as 'current working
directory' (cwd). This makes sure that native_sim specific drivers (like
flash simulator with file backend in 'flash.bin') are using unique context
for external resources with relative paths.

This fixes executing native_sim tests in twister with flash simulator.
Previously a shared 'flash.bin' was used for all executed 'zephyr.exe'
processes in twister. After this patch a unique 'flash.bin' file is used
for each tested sample, since those 'flash.bin' is placed in application
build directory instead of twister root directory.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2024-06-18 15:53:00 +02:00
Dmitrii Golovanov 1ccd972563 twister: Fix on output directory reaching backup limit
Stop Twister if there are too many backup copies of the output
directory already.
Before this fix, Twister silently kept artifacts from the last run,
unless `--clobber-output` was explicitly given.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-17 12:08:20 -04:00
Jordan Yates 25fa41c209 scripts: twisterlib: coverage: handle multiple gcov dumps
Extend the coverage tool to handle applications that generate multiple
gcov dumps in a single execution. This can happen when the application
calls `sys_reboot`.

Handling multiple dumps enables coverage testing of exception handlers.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-15 04:39:53 -04:00
Dmitrii Golovanov 68bb87bd50 twister: pytest: Log output passthrough
Pass Twister pytest plugin's log output, as well as output from
a test image running with pytest, up to Twister log irregardless
of the current verbosity level set at Twister.
This allows to collect full test output and also ensures that
recording data embedded in the test log is passed to the Twister
pytest harness for export.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-14 09:41:52 -04:00
Dmitrii Golovanov 35e313f9e5 twister: recording: Allow JSON data fields
Extend Twister Harness recording feature to allow selected data fields,
extracted from the log by a regular expression, to be parsed into JSON
objects and eventually reported in `twister.json` as `recording` list
property of the test suite.

With this extension, log records can convey layered data structures
passed from a test image as summary results, traces, statistics, etc.

This extension also allows flexible recording structure: a test image
can output different types of data records incapsulated into a fixed
set of fields, so `recording.csv` file columns are respected, whereas
some of the columns keep strings with json-encoded semi-structured data.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-14 09:41:52 -04:00
Maciej Perkowski da1066fa4b twister: Add sysbuild boolean to platform definitions
More complex platforms require sysbuild to use always, even for
such "simple" samples like hello_world. Such platforms can have
`sysbuild: true` entry in their board_name.yaml used by twister.
Using such entry will tell twister, that sysbuild must always be used
on a given platform.
Twister is aligned to have information about need of sysbuild at
instance (platform + suite) level (was only at suite level before).
Instance.sysbuild is true whenever a test suite or a platform requires
sysbuild.
Twister pytest unit tests are aligned with changes.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2024-06-13 16:46:25 -04:00
Juha Kuikka 14c2be6d9d twister: Capture qemu launch stdout and stderr
Currently we launch qemu (well, "ninja run" usually) using Popen and
request stdout and stderr to be redirected into a pipe. However we never
read that pipe so the information is not captured.

Instead log directly into files that can be inspected after a failed
to to find out why qemu run failed.

Note that this is really only useful in cases where qemu either fails to
launch or crashes.

Regular test data is still handled via the qemu fifo.

Signed-off-by: Juha Kuikka <juha.kuikka@gmail.com>
2024-06-13 08:04:07 -04:00
Anas Nashif eaafd30b56 twister: cleanup how we capture results of handlers
we use reason for a failure to indicate state and then set the status
later and reason for the failure, in case of the failure is taken from
the handler status. Clean this up by setting status and reason coming
from the handler very early, so we do not have to go through replacing
meaning later.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-06-12 21:12:13 -04:00
Lothar Felten 3334b55207 scripts: twister: help - change help text to match hwmv2
fix the twister help text, boards are now organized as:
boards/<vendor>/<board_name>

Signed-off-by: Lothar Felten <lothar.felten@gmail.com>
2024-06-11 16:18:15 +02:00
Jordan Yates b1290cb86c scripts: twisterlib: filter coverage information
When dumping logs from the `--inline-logs` option, remove any coverage
information that may be contained in those logs. Coverage dumps are
unrelated to any test failures and make it harder to find the failing
test information. In extreme cases the relevant information is lost due
to terminal scrollback limits.

If the raw dump information is required, it is still present in the
original `handler.log` file.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-11 16:37:31 +03:00
Dmitrii Golovanov eebbd5c411 twister: footprint: Add optional detailed JSON report on symbols
New Twister option `--footprint-report` is introduced to collect and
write detailed memory footprint results for symbols as an additional
JSON file. By default, the new option is disabled.

The new option implies and extends `--create-rom-ram-report`, so there
are three choices: 'ROM', 'RAM', and 'all' to select what memory area
symbols to report in `twister_footprint.json`.
In case of the custom report name, or per-platform report, it is always
composed with the rightmost '_footprint.json' suffix.

The memory footprint report has similar structure as `twister.json`
and compelements it having reduced set of test suite properties:
- instead of `testcases` it contains `footprint` object with
  `rom.json` and `ram.json` artifacts embedded there;
- other properites are limited to represent only the essential test
  suite context, thus to allow further data processing consistently
  and independently from the `twister.json`.
- 'filtered' test instances are not included into the footprint report.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-06 20:08:11 -04:00
Dmitrii Golovanov a425db20b1 twister: Add test suite filtering on twister.json compose
When Twister composes resulting twister.json reports, add optional
filtering by a test instance resulting status and/or its individual
properties to be allowed/denied on output to the JSON file.
This internal feature is introduced to facilitate JSON reports with
a custom data schema.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-06 20:08:11 -04:00
Henrik Brix Andersen 331b404185 twister: hardwaremap: avoid exceptions when generating hardware map
Avoid exceptions when generating persistent hardware maps on Linux with no
devices available.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-06-06 07:50:51 -04:00
Dmitrii Golovanov 4dc2a98d0c twister: Ensure serial-pty process termination
Make sure Twster DeviceHandler serial-pty process is terminated
with all its remaining children to avoid Twister hanging on it
infinitely.
The reolved issue occurs sometimes, for example when serial-pty
script is used for serial port tunneling over network.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-06-05 17:38:42 -05:00
Lukasz Mrugala 5f4d330db6 scripts: twister: Do not report filtered test instances by default
Filtered testcases are removed by default from Twister tests.
Older functionality is preserved via a new Twister flag:
--report-filtered.
Old tests were adjusted and a new test for that flag added.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-06-05 01:38:47 -07:00
Henrik Brix Andersen 3eb3c33096 scripts: twister: allow fixtures to contain extra configuration
Allow twister fixtures to contain extra information, which can be used for
test suite configuration. The extra information can be appended to existing
fixtures separated by a colon (i.e. <fixture>:<configuration>).

This is especially useful for the pytest harness, where a fixture of a
given type may need to refer to an instance of a particular piece of host
hardware needed by the pytest suite (e.g. a network interface, a UART, or a
CAN interface connected to the device under test).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-06-04 21:27:35 -05:00
Henrik Brix Andersen a7d55cfa13 twister: harness: pytest: list available fixtures in device config
Pass the list of supported twister fixtures for a given platform to pytest
via DeviceConfig. This allows for the pytest suites to use knowledge of the
fixtures for test suite configuration.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-06-04 21:27:35 -05:00
Anas Nashif d877d29913 twister: abort on execution and retun 0 on exceptions
When something goes wrong with execution, due to twister issues and
bugs, do not continue with execution and abort the process and report
and return an error code.

Fixes #72807

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-06-04 07:58:31 +02:00
Grzegorz Chwierut f52f08f877 twister: pytest: Sysbuild support in pytest-twister-harness
Read default domain from domains.yaml file and update
paths to proper build directory. It fixes native and qemu
pytest scenarios, when application is build with sysbuild.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-06-02 00:42:54 +02:00
Bjarki Arge Andreasen 79640aea09 drivers: console: remove uart_mux and gsm_mux
Remove the deprecated uart_mux and gsm_mux modules and all of
their configurations/dependencies across zephyr.

Optimally uart_mux and gsm_mux would be removed in their own
respective PRs, but the two modules are directly coupled, so
to preserve bisectability, they must be removed together.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-29 10:49:08 -07:00
Michał Szprejda 7bc9a98a70 Twister: Rework integration with renode-test
Initial integration with renode-test was introduced in commit bdf02ff,
which added support for calling the `renode-test` command from both west
and twister.

This commit removes the custom run_renode_test target used for running
Robot tests with the `west build` command and makes twister call
`renode-test` directly instead.

Signed-off-by: Michał Szprejda <mszprejda@antmicro.com>
2024-05-28 12:54:52 +02:00
Mike Szczys 7eaca455fa twister: fix serial connection for flash_before
The --flash-before flag allows devices to be flashed before the serial
connection is established. However, the implementation was incomplete and
only worked if the port address already existed at the start of the run.
This is incompatible with devices that implement the USB in software
(eg: USB-CDC).

This commit fixes the implementation to delay setting up the connection
until after the device is flashed, and to retry the connection for two
seconds after flashing to give the device time to enumerate as a USB
device.

Signed-off-by: Mike Szczys <mike@golioth.io>
2024-05-22 21:39:13 -04:00
Jordan Yates 44f5a5d5d4 scripts: twisterlib: handlers: early QEMU timeout
Terminate QEMU earlier if the test finishes and no output data is
received for 1 second. This new timeout operates in parallel with the
global test timeout.

For coverage testing, this can reduce the time spent running individual
tests by up to 29 seconds, while still giving the full 30 extra seconds
to dump gcov data if needed.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-20 18:04:42 +02:00
Benjamin Gwin 723a8fcf36 twister: Add logging of stderr for BinaryHandlers
In the case where a test causes the test executor to crash, the stderr
is currently lost, making it hard to debug failures. This changes it
so that the process' stderr gets captured to 'handler_stderr.log' for
inspection.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2024-05-19 10:57:16 +03:00
Maciej Perkowski 7d3dc4e7e3 twister: Fix path to binary location for unit_testing board
PR #72100 broke execution of unit type tests. This commit fixes
it by bringing back the "old" logic for selecting a binary path
for unit type tests.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2024-05-16 14:27:06 +02:00
Dmitrii Golovanov 4efc035209 twister: Fix default command line dependency on --device-testing
Fix default command line options check dependency on `--device-testing`
when it is provided to run Twister and turn device command options
as mandatory.

Fixes after changes introduced with #72399.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-15 15:13:19 -04:00
Dmitrii Golovanov d45dbc26f0 twister: Add Twister execution options to twister.json
Store Twister command line options in twister.json report as
`environment.options` object. It allows to keep the actual
execution context for test results analysis and history comparison.

A new command line option `--report-all-options` enables to report all
command line options applied, including these set as default values.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-15 14:56:59 +02:00
Hake Huang 248b66dfe3 twister: handler: optimize handler testsuite check
in many platforms, before  the debuger flash, the former testsuite
many already executed, so we will see some old testsuite name.
and we should not compare them directly, instead if we compare in
reversed order them we can avoid such mis-judge.

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2024-05-15 14:56:24 +02:00
Grzegorz Chwierut 59212c198c twister: Allow to run sysbuild with native_sim
Fix issue 72083. Update path to zephyr.exe binary using
default domain from domains.yaml file.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2024-05-15 13:16:39 +02:00
Kamil Paszkiet a411ae93b7 twister: add --report-summary switch
Added a switch that show failed/error report from the last run.
Default shows all items found. However, you can specify the number of items
(e.g. --report-summary 15).
It also works well with the --outdir switch

Signed-off-by: Kamil Paszkiet <kamilx.paszkiet@intel.com>
2024-05-15 09:29:05 +02:00
Dmitrii Golovanov 11de74c11f twister: pytest: Enable recording for Pytest Harness
Extend Pytest Harness to support 'recording' feature to parse
test log by a regular expression and collect as records the same
way as Console Harness do.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-14 18:20:12 -04:00
Dmitrii Golovanov 1230640076 twister: Refactor 'recording' feature
Refactor Twister 'recording' feature moving it from Handler class
to TestInstance class and enable it also for other Harness child
classes other than Console.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-14 18:20:12 -04:00
Dmitrii Golovanov 4d85967e09 twister: Set default coverage platform only when needed
Set options.coverage_platform only when running coverage.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-13 11:39:16 +02:00
Maciej Perkowski be682e22e1 twister: allow using west-flash with 'erase'
Using `erase` with west-flash was blocked as it was
messing with sysbuild. With #69748 the issue is fixed, hence
'erase' is no longer blocked.
Remove obsolete twister test

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2024-05-10 20:26:02 -04:00
Dmitrii Golovanov 1da6e57342 twister: Fix platform report generation called multiple times
Fix Twister to generate platform reports (`--platform-reports`)
only once for each platform instead of repeating it multiple times
for each instance executed.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-05-10 14:43:58 -05:00
Jordan Yates c0813ef1f2 scripts: twisterlib: coverage: exclude `LOG_*` branches
Disable the branch coverage calculations on the `LOG_*` family of macros.
Branch misses are due to the implementation of `Z_LOG2` and cannot be
reasonably covered in library code. The internal paths through the
`Z_LOG2` macro are not of interest when inspecting files that happen to
use the Zephyr logging API.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-10 11:50:46 +03:00
Hake Huang ccf95e8773 twister: testplan: enable runtime quarantine
sometime we need use quarantine at runtime when --test-only
add this will help to skip problematic cases in test cycle

to reenable the quarantined case you need add
--quarantine-list quarantine.yaml --quarantine-verify

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2024-05-08 15:51:36 +02:00
Hake Huang 09e0fb9376 twister: openocd hander: add LPC script CMSIS-DAP support
add LPC script CMSIS-DAP support

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2024-05-07 18:02:53 -04:00
Lukasz Mrugala b2f43210de scripts: Loader change
CSafeLoader used instead of yaml.safe_load and SafeLoader.
C implementation is faster.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-05-07 09:38:00 +02:00
Lukasz Mrugala 3d00574d33 scripts: twister: New find_v2_boards() function
Current find_v2_boards() has a lot of unnecessarry fluff.
We can make a new version of that function without it
given its use in TestPlan.add_configurations().

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-05-07 09:38:00 +02:00
Lukasz Mrugala a294a9a9ab scripts: twister: Name prefix loading
Sped up Twister via name prefix loading.
If the only thing influencing the platform selection
is the platform filter (-p), then we only load *.yaml
files that start the same way as those selected platforms.
We split the platform name to the first '/' or '@'.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-05-07 09:38:00 +02:00
Lukasz Mrugala 698df11446 scripts: twister: RegEx speedup
Replace unoptimal RegEx with a faster solution.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-05-07 09:38:00 +02:00
Pieter De Gendt f147a5fec2 spelling: Replace occurrences of "iff" with "if and only if"
Spell checking tools do not recognize "iff", replace with "if and only if".
See https://en.wikipedia.org/wiki/If_and_only_if

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-06 14:58:08 +01:00
Lukasz Mrugala ad210f7579 scripts: twister: Remove harness repeat field
Removed Harness's repeat field.

Added to schemas in e722db14ad,
together with the rest of harness_config.
Added to Harness when it was created.

Now present only in one sample -
mec15xxevb_assy6853 power management sample.

Could not find definitive proof whether it has ever been used.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-04-30 18:23:23 +02:00
Sylvio Alves 568e777b84 twister: update overflow section name regex
esp32 platforms can overflow its dram0_0_seg and dram0_1_seg.
So update current dram section to meet both cases.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-04-29 17:41:15 +01:00
Lukasz Mrugala 83db378dc5 scripts: twister: Remove Handler atavisms
Removed following fields from relevant Handlers,
as they were unused in code:

* Handler's state
* Handler's generator
* BinaryHandler's call_west_flash
* QEMUHandler's results
* QEMUWinHandler's results

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2024-04-29 17:40:06 +01:00
Katarzyna Giądła fe5a5edfc8 twister: harness: pytest: Check exist of the runner_params
Pytest harness in Twister tries to get custom parameters to
the pytest harnesses. It is required although those do not exist
(e.g. Twister uses devices without hw map). This change checks
if the custom parameters to the pytest harnesses exists.

Fixes #71817

Signed-off-by: Katarzyna Giądła <katarzyna.giadla@nordicsemi.no>
2024-04-26 16:12:48 +02:00
Declan Snyder 5edc356d96 twister: Make --list-tests respect tag filter
Make the --list-tests and --tests-tree options outputs
respect the --tag and --exclude-tag options,
so that only the tests for the specified tags are listed.

Also update the TestPlan report testcases for this change.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-04-26 16:10:25 +02:00