Commit graph

45 commits

Author SHA1 Message Date
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
Lucas Tamborrino d65b6bc199 twister: add flash-before option
Add option to flash board before attach serial.

Current implementation performs the following sequence:

1. Open serial port to listen to board log output
2. Flash device

In case of ESP32 where it uses the same serial port
for both operations, flashing needs to come first.

This PR adds a twister option named --flash-before
which enables the process above, allowing tests to be
performed properly.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2024-03-25 18:37:49 -04:00
Filip Kokosinski 053e5f93ac twister: use enum for the arch field in Twister platform schema
This commit adds an enum to the `arch` field of the Twister platform
schema. This helps better filter boards for testcases which use
architecture-based filters, and helps maintain uniformity in naming
convetion.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2024-03-19 07:55:58 -04:00
Anas Nashif abef8bde4e twister: reuse test schema in common section
Rather than duplicating the same schema, define it only once and reuse
for both common section and tests section.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-01-17 14:42:10 +01:00
Piotr Golyzniak 8831aa60eb scripts: twister: add copying of bsim exe
To make possible to build bsim tests by Twister, it is necessary to
copy executables to BabbleSim bin directory.

Signed-off-by: Piotr Golyzniak <metody159@gmail.com>
2024-01-10 12:10:58 +01:00
Yong Cong Sin 9d314ff86d twister: implement simulation_exclude filter
This gives us the flexibility to exclude certain platforms'
simulator that's known to fail from running in Twister, but
allows real hardware to be tested.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-12-19 07:33:39 -05:00
Yong Cong Sin 2bd0c8c552 twister: change schema of platform_type to follow type
The `platform_type` was created to filter `type` so they
should have the same schema.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-12-19 07:33:39 -05:00
Dmitrii Golovanov 47da4e2e76 twister: Improve recording at Harness
The Console Harness is able to parse its log with patterns to compose
extracted fields into records in 'recording.csv' file in the test's build
directory. This feature allows to extract custom test results like
performance counters.
With this change the extracted records are also written into 'twister.json'
as a part of each test suite object. This makes easier to store
all the data collected by the test for its further processing.

Other improvements:
 - compile parsing pattern only once instead of at each input line;
 - quote fields in '.csv' to avoid unexpected field separators;
 - make 'regex' a required schema field of 'harness_config';
 - Twister documentation update.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-12-06 10:26:35 -05:00
Grzegorz Chwierut fffe0b9fad twister: pytest: Parametrize scope of the dut fixture
Added pytest_dut_scope keyword under harness_config section.
New keyword is used to determine the scope of dut and shell
fixtures in pytest-twister-harness plugin.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-10-27 13:35:14 -05:00
Anas Nashif 3966d30a4f twister: support filtering by vendor
Add a new option --vendor which allows filtering by vendors tracked in
the board/platform yaml file. The vendor string is compatible with DTS
and is what we have in dts/bindings/vendor-prefixes.txt.

Providing multiple vendors is also supported.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-22 09:29:36 +02:00
Grzegorz Chwierut 5bb3067942 twister: pytest: Allow list of pytest testpaths
Allow to specify a list of pytest directories, files or subtests
with pytest_root keyword in test yaml.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-09-18 05:59:35 -04:00
Jamie McCrae bc97d8fb1e twister: Add support for required snippets
Adds support for twister to require using snippets on tests

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-06 16:40:53 +02:00
Yong Cong Sin 9239599277 twister: add support for custom emulator in simulator
Enable the possibility for boards to implement a custom `run` target in
its board.cmake to run any arbitrary commands. This is helpful for devs
who would like to add support for proprietary simulator to their boards
that can't be upstreamed.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-08-02 17:35:26 +02:00
Michał Szprejda bdf02ff5d6 Twister: Add integration with renode-test
Add support for calling the `renode-test` command from west and twister.
Enable running Robot Framework tests suites in Renode.

Signed-off-by: Michał Szprejda <mszprejda@antmicro.com>
Signed-off-by: Mateusz Hołenko <mholenko@antmicro.com>
2023-05-26 09:43:49 -04:00
Gerard Marull-Paretas 11218baffc twister: set 'any' type for set/list fields
This allows to write both, lists or strings in the YAML file.
Unfortunately pykwalify schema language does not support multi-type
fields. JSON schema or Marshmallow could be used instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Dmitrii Golovanov f31aab58d5 twister: Add configurable flashing timeout
Use explicit flash command execution timeout at DeviceHandler
instead of the hardcoded value of 60 sec.

When a HW platform executes test cases right after the flash command,
the test case remaining timeout is affected by how much time the flash
operation consumes. Some simulation platforms need to spend significant
amount of time on each 'flash' cycle, usually adding the same delay on
each test case.

This improvement adds two new command line options and device map fields:

  --device-flash-timeout - for the flash operation timeout
  ('flash-timeout' device map field).

  --device-flash-with-test - to indicate that the platform flash
  command also runs a test case, so the overall timeout should be
  calculated as a sum of the flash timeout and the current test case
  timeout to receive all console output from the platform
  ('flash-with-test' device map field).

The device map field values override command line values for the
particular platform where configured.

Default behavior is backward compatible: flash operation fixed timeout
is 60 sec. not including the test case timeout.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2023-04-08 18:37:33 +02:00
Anas Nashif 14d88f8425 twister: add support for levels and test configuration
Add support test levels and the ability to assign a specific test to one
or more levels. Using command line options of twister it is then possible
to select a level and just execute the tests included in this level.

Additionally, a test configuration allows definiing level
dependencies and additional inclusion of tests into a specific level if
the test itself does not have this information already.

In the configuration file you can include complete components using
regular expressions and you can specify which test level to import from
the same file, making management of levels easier.

To help with testing outside of upstream CI infrastructure, additional
options are available in the configuration file, which can be hosted
locally. As of now, those options are available:

- Ability to ignore default platforms as defined in board definitions
  (Those are mostly emulation platforms used to run tests in upstream
  CI)
- Option to specify your own list of default platforms overriding what
  upstream defines.
- Ability to override build_onl_all options used in some testscases.
  This will treat tests or sample as any other just build for default
  platforms you specify in the configuation file or on the command line.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-03-07 15:49:16 +01:00
Tristan Honscheid 1eb0452fcb twister: Fields for Kconfig and DT overlay files in testcase.yaml
This is an implementation of issue #48334 and adds support for
specifying additional config and device tree overlays through fields in
the testcase.yaml file, which is more readable than having to cram these
in to `extra_args`.

Consider this example which shows the original and new ways to add
config and DT overlays:

```
common:
  extra_args: "CONF_FILE=a.conf;b.conf
DTC_OVERLAY_FILE=w.overlay;x.overlay OVERLAY_CONFIG=e.conf
UNRELATED=abc"
tests:
  utilities.base64:
    extra_conf_files:
      - "c.conf"
      - "d.conf"
    extra_overlay_confs:
      - "extra_overlay.conf"
    extra_dtc_overlay_files:
      - "y.overlay"
      - "z.overlay"
    extra_configs:
      - CONFIG_SAMPLE=y
    tags: base64
    type: unit
```

The new fields are `extra_conf_files`, `extra_overlay_confs,
`extra_dtc_overlay_files`. Files specified in these sections are appended
to any `CONF_FILE`, `OVERLAY_CONFIG`, or `DTC_OVERLAY_FILE` fields in
`extra_args`, causing the following args being passed in to
`self.run_cmake` at `runner.py:850`:

```
['-DUNRELATED=abc',
 '-DCONF_FILE=a.conf;b.conf;c.conf;d.conf',
 '-DDTC_OVERLAY_FILE=w.overlay;x.overlay;y.overlay;z.overlay',
 '-DOVERLAY_CONFIG=e.conf extra_overlay.conf '
 '<build_dir>/twister/testsuite_extra.conf']
```

These fields can be used in the common or scenario-specific YAML
sections and will be merged in order of least to most specific:

 1. config files extracted from common's extra_args
 2. files listed in common's {extra_conf_files or extra_overlay_confs
    or extra_dtc_overlay_files}
 3. config files extracted from test scenario's extra_args
 4. files listed in test scenario's {extra_conf_files or
    extra_overlay_confs or extra_dtc_overlay_files}

Specifying these files in extra_args now triggers a deprecation warning,
as the direct YAML fields are preferred for readability. They will still
function for now but support will be dropped in the future.  One
testcase.yaml
(`zephyr/tests/cmake/overlays/var_expansions/testcase.yaml`) is
converted to use the new fields. A follow-up PR will convert the
remaining files to the new format.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-03-01 16:52:01 -05:00
Anas Nashif 78a741f1b4 twister: schema: make tests a required key
Catch any test definitions not defining any tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 05:31:07 -05:00
Grzegorz Chwierut 0a7a61f15c twister: docs: Update twister docs with quarantine
Docs updated with changes proposed in #52179
Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Grzegorz Chwierut bac1a955d0 twister: quarantine: Added simulations field and regex to filter fields
Regex are allowed on every field, not only scenarios.
Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Grzegorz Chwierut d95eab1ce6 twister: Refactor and extend quarantine implementation in twister
Implementation ported from TwisterV2.
- quarantine handled by separate module
- multiple yaml allowed from args: --quarantine-list
- scenarios, platforms, architectures keywords in
quarantine yaml are optional, if not given - means take it all

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-01-19 06:51:00 -05:00
Tom Burdick 38385ed3ff twister: Platform key for test suites
Adds an option to inform twister a testsuite should only be built and
run for platforms with unique sets of attributes. This enables
for example keying on unique (arch, simulation) platforms to run the test
suite on.

The most common usage may be test suites configured to run once per
(arch, simulation) pair as being enough. Additional information about
platforms may enable running a test once per hardware IP block or once
per soc family or soc avoiding duplicated effort in building and running
tests when once suffices.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-12 10:30:57 -05:00
Anas Nashif 21077b7cf2 twister: support custom test binaries
Have boards define what binaries should be kept for device testing. The
purpose of this is to reduce the amount of artifacts and just keep the
binaries needed for flashing a device, reducing the size of the final
payload.

A board can have twister keep multiple binaries needed for testing when
--prep-artifacts-for-testing option is used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-11 10:35:08 -05:00
Fabio Baltieri 5c32300861 yamllint: fix all yamllint truthy errors
Fix all thruthy errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(truthy)'

This only accepts true/false for boolean properties. Seems like python
takes all sort of formats:

https://github.com/yaml/pyyaml/blob/master/lib/yaml/constructor.py#L224-L235

But the current specs only mention "true" or "false"

https://yaml.org/spec/1.2.2/#10212-boolean

Which is the standard yamllint config.

Excluding codeconv and workflow files, as some are using yes/no instead
in the respective documentation.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Anas Nashif 808266a493 tests: use ignore_fault field instead of tags
Use dedicated field in the yaml file instead of mixing this testing
feature with tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:38:05 -05:00
Anas Nashif dae4720703 boards: native: mark as simulator
Mark native_posix platform as a simulator.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Anas Nashif 3e870495f2 boards: add simulation executable for 3rd party sims
Provide the information as part of the board yaml file, this way we will
know what binary to check for.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:09:02 -05:00
Daniel DeGrasse 602b8b485d scripts: twister: add support for sysbuild
Add support for building with sysbuild using twister, via the "sysbuild"
yaml property in testsuites. This will currently disable Kconfig and
devicetree filtering.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-04 14:06:58 -04:00
Anas Nashif a6f924db7f twister: add support for platform_type filter
Instead of relying on runtime filter to limit scope to emulation
platforms, use the type attribute for each platform and do the filtering
very early on. This will speed things up for tests where we only run on
emulation platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-14 14:49:59 -04:00
Anas Nashif 8e805596d5 twister: support defining testcases in yaml file
Some complex testsuite use macros and other mean to define testcases
which makes them unparseable. This ends up in a descripency between the
testplan and the test results.

Allow adding the testcases into the yaml and use those instead of
parsing the C files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 15bc98eb50 twister: rename TestCase -> TestSuite
TestCase in the old terminology is the test application, but we have
just freed up TestSuite, so use TestSuite here to signify the test
application which consists of many test scenarios and testcases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Enjia Mai 4966de2014 twister: add a hardware map support for using serial pty
The hardware map feature can be used with serial pty mode in
this change. And also add an runner_params option for passing
more parameters from hardware map file to west runner. Note
that you need to create this map file manually because it
cannot be scanned out correctly due to pty is not a physical
HW device existing in system.

And also update doc/develop/test/twister.rst for the usage.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-05-11 05:54:23 -04:00
Evgeniy Paltsev 7353ea5886 twister: implement platform-specific test timeout management
Twister allows us to control maximum execution time for each
test with timeout value in test .yaml configuration. This
helps us to prevent slow tests from stopping by timeout.

However it's hard to choose test timeout for all platforms
as some platforms are naturally slow. It could be a HW board with
power-efficient but slow CPU or simulation platform which
can perform instruction accurate simulation but does it slowly.

As we don't want to increase test timeout infinitely to meet
the needs of the slowest platform let's introduce
platform-specific test timeout management. It's implemented as
an optional 'timeout_multiplier' field in board .yaml
configuration. Setting it to some value multiplies each test
timeout by this value. By that we can increase timeouts only
for the platforms where it's required.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-05-04 19:01:11 -04:00
Anas Nashif f429f339fc twister: allow filtering based on modules
Support new keyword in the testcase.yaml to allow filtering based on
enabled modules. This is useful when you only whitelist a limited set of
modules in your project and want to only run those samples that have
their dependencies satisfied and those modules available.

The option allows adding multiple modules, all of which need to be
enabled in the manifest.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-19 09:38:55 -04:00
Anas Nashif 43d3dfb7c5 boards: add maintainer to the platform yaml file
Each board needs to have a maintainer to allow automatic assignment and
adding reviewers when pull requests concerning the platform are being
submitted.

This is now a placeholder so we can start adding maintainers early, the
data is not being used anywhere yet.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-01 17:16:41 -04:00
Henrik Brix Andersen 7249dab0c8 scripts: twister: harness: pytest: add support for custom cmd line args
Add support for passing custom command line arguments to a pytest
harness in twister.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-28 12:18:48 -05:00
Shao Ming 4315140702 twister: fix the testcase-schema.yaml
Change the "yes/no" value to "true/false".
Otherwise pykwalify 1.8.0 will report below errors:
- Value: 'no' for required keyword must be a boolean:
  Path: '/mapping/common'>
- Value: 'yes' for required keyword must be a boolean:
  Path: '/mapping/sample/mapping/name'>

Signed-off-by: Shao Ming <ming.shao@intel.com>
2021-11-19 11:46:38 -05:00
Dennis Ruffer c714c78743 twister: Allow baud rates other than 115200
Fixes #38046
Document the changes in twister.rst
Add baud rate to debug message in twister
Add baud parameter to twister's add_device function
Set the twister baud rate from input parameters
Use 115200 as the default baud rate if not specified
Add baud to the hwmap-schema.yaml file
Add --device-serial-baud to twister arguments
Fix compliance issues
Fix mistake in parameter name from device-baud to device-serial-baud
Refactoring of the code in orded to simplify the logic
   and clear multiple definitions of the default baud rate.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Signed-off-by: Dennis Ruffer <daruffer@gmail.com>
2021-10-14 16:35:48 -04:00
YouhuaX Zhu 965c8b9888 sanitycheck: Add a feature which can handle pytest script.
1. Add a class of Pytest(Harness) which can handle pytest script
in harness.py
2. Use running_dir to store current test directory which be
used in pytest scrpt.
3. Add usage of this feature into zephyr doc.

Signed-off-by: YouhuaX Zhu <youhuax.zhu@intel.com>
2021-05-04 19:08:18 -04:00
Jaxson Han 8af11d40d0 cmake: emu: Add arm fvp emulator
Add arm fvp emulator in order to use ninja run or west build -t run.
Add armfvp in order to run twister.

Set env ARMFVP_BIN_PATH before using it,
e.g. export ARMFVP_BIN_PATH=<path/to/fvp/dir>
NOTE: ARMFVP_BIN_PATH is the dir path.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2021-04-13 07:47:44 -04:00
Maciej Perkowski 9c6dfce0c0 twister: Add quarantine feature
Adds feature allowing to use yaml file with dictionaries defining
tests to be quarantined (extra arg "--quarantine-list FILENAME").
The dictionaries are validated according to the proper schema
and loaded.

A flat list is created containing quarantined configurations
(configuration = platform + scenario). Configurations under quarantine
are skipped and get "Quarantine" as a reason in the results reports.

A "comment" can be added to a quarantine entry in the quarantine yaml
with more details (e.g. issue #) and it will be also added to
the report.

The status of tests under quarantine can be verify if
`--quarantine-verify` is used in addition to
"--quarantine-list FILENAME". Using these args will make twister skip
all tests which are not on the quarantine list.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-04-12 08:42:29 -04:00
Kumar Gala 3befd7d45f cleanup: rename sanitycheck references to twister
Cleanup references to sanitycheck that should now be twister.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-14 07:50:52 -06:00
Anas Nashif 2e4b0fad98 twister: adapt platform schema
Adapt schema to use twister instead of sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-11 14:13:02 -05:00
Anas Nashif c24bf6f183 sanitycheck: move schemas to scripts/schemas
Move yaml schemas into one single location. We have quite a few schema
used across the tree, one common place will make them easier to find and
reference.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-11 14:13:02 -05:00