Commit graph

89 commits

Author SHA1 Message Date
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
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
Alberto Escolar Piedras ec273d1357 twister: Fix description of relationship between filter and allow/exclude
The current description of the relationship between the tests filter
and the arch/platform allow/exclude was actually incorrect.

Let's fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-17 18:55:35 +03: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
Al Semjonovs d09fd2259f twister: move main to twisterlib/twister_main.py
This allows for ability to import main to be used
within west

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-13 15:39:04 -08:00
Al Semjonovs 067ba65e10 twister: Split up argument parsing into smaller functions
Split argument parsing into smaller functions to be leveraged
by west twister extension.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-13 15:39:04 -08:00
Anas Nashif 5fd629b48b twister: package artifacts for testing
Package artifact for later use with --test-only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-01-11 10:35:08 -05:00
Daniel DeGrasse b579a44e9c scripts: twister: update twister to support QEMU platforms with sysbuild
Update twister to support running QEMU platforms with sysbuild, by parsing
domains.yaml and executing the "run" target of the default application.
This will allow twister to test QEMU targets with sysbuild. It is assumed
that QEMU targets will add any external images they need in the build
phase

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04: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
Jeremy Bettis 562b291704 twister: Set stdin explicitly on stty calls
stty operates on the file descriptor from stdin, but we want to operate
on stdout. If stdin and stdout are not the same tty then stty prints an
error.

Redirect stdout to stdin for stty calls.

Tested by running twister -T tests/subsys/shell </dev/null

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-08-26 12:51:28 +02:00
Tristan Honscheid 4a8ffee1d8 twister: Don't run coverage report when --build-only is used
When doing a split build and test with coverage enabled, (i.e.
`twister --coverage --build-only` followed by `twister --coverage
--test-only`), Twister attempts to run coverage reports immediately
after building, which fails because tests haven't actually run yet
and causes several error messages to print in to the log.

This change causes twister to skip the call to `run_coverage()` if
`--build-only` is set and print an info message. This suppresses the
error messages from the coverage report tool complaining about missing
coverage files, but still instruments the built code for coverage data
collection. When twister is invoked again, but with `--test-only`
instead, the coverage files will be emitted and the reports
successfully generated.

 #### Testing

I ran...

```
$ zephyr/scripts/twister -T zephyr/tests/lib/cmsis_dsp/basicmath/
--coverage -p native_posix --build-only
$ zephyr/scripts/twister -T zephyr/tests/lib/cmsis_dsp/basicmath/
--coverage -p native_posix --test-only
```

... followed by a combined build and test ...

```
$ zephyr/scripts/twister -T zephyr/tests/lib/cmsis_dsp/basicmath/
--coverage -p native_posix
```

... as a control and diffed the HTML coverage reports, which were
identical other than a timestamp.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-07-28 05:58:52 -04:00
Bartosz Bilas 3322aad03b scripts: pylib: twister: twisterlib: fix typo
s/enviornment/environment

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-07-19 11:41:54 -04:00
Anas Nashif a0c3bdafbf twister: do not modify testplan on subsequent runs
Do not modify testplan.json if it already exists. Testplan is only
created once and any work in the same worskpace should not change it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif 087f1e4a63 twister: fixed various pylint issues
Fix various pylint issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 9437e6d963 twister: fix twister testsuite
Make testsuite work again.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 08caa71de7 twister: testplan: get options directly
Get options from passed environment class instead of using command line
options to the init function.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 76d5543c9b twister: fix main script returns and error handling
Propagate errors to the main routine and do not exit early in case of
errors.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 91b2cce64e twister: fix subset processing
Process subsets was done in the wrong step, so make it apply and
generarte subsets correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 79d7d0188b twister: make ninja the default
Using ninja is up to 50% faster, make it the default and add an option
to build with Make.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 57dbaa3da3 twister: move more code from main script
Move code from twister script into respective classes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif f539f1dc48 twister: move size report into size calc class
Move from main script into size_calc class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 806722cdbf twister: move device testing code
Move device handling code into hardware map class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif f7d501447d twister: move cleanup and classification of code
Move code out of the main script and use global options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 396b8574eb twister: testplan: move calls to json loading/filter into class
Move all code related to instance filtering and loading into the class
instead of having it in the main script. Simplify option passing.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif f85d1eb4e1 twister: rework testplan and main twister script
Move all testplan related code to the testplan class and cleanup main
twister script.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif b8735b3300 twister: more cleanup to option passing
Use global options rather than passing them individually.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif facc685ae9 twister: move runner code into runner class
Move all code related to test execution into runner class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 20f257a97d twister: move execution code out of testplan
Move all code related to execution into runner class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif d43e03e19e twister: isolate testplan class
Move testplan class into own file and rename the original twisterlib.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 96b9ff6b5e twister: move runner classes out
Move runners into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 1084869634 twister: minor cleanups in main script
Move code around in the main script and cleanup some of the options.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif adfa6c7777 twister: move coverage classes out
Move coverage related classes out into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 78d9dab7f3 twister: cleanup imports and move size classes out
More python import optimizations and cleanup and move size_calc class
out into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 2b213d3231 twister: split hardwaremap class out
Split hardware map class into own file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif d5424d5116 twister: split report classes out
Move report classes out into own file and split out of testplan class.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif e01cbbe31f twister: add environment class
Add environment class to discover toolchain, zephyr version and other
items.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Benjamin Gwin 3f8d5c49b3 twister: Exit with a bad status if there were build errors
Previously, twister would exit with a 0 status code if there were build
failures but no execution failures. This makes it easier to catch
build breakages when using twister in CI workflows.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2022-06-14 21:56:51 -04:00
Anas Nashif 87be2f591f twister: rework how we discard tests
Add a filter type to distinguish between testsuite filters that are
maintained in the testcase.yaml file and those provided on the command
line.

The issue was that when something is excluded deliberately on the command
line twister would report an error if that filter would filter out an
integration platform. We do not want that, because the filtering is
being done by the caller knowing that some tests would be not run, even
if those are integration platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-06-09 12:15:28 -04:00
Stephanos Ioannidis 39956ec835 twister: Add option to always force color output
Colorama, by default, strips out the color escape characters when the
output is redirected, and this may have an unintended consequence of
disabling color outputs when using a utility such as `tee` and in the
CI runners that redirect the stdout and stderr console outputs.

This commit adds a new command line option called `--force-color` to
always force the ANSI color escape sequence output even when the output
is redirected.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-25 12:48:31 +09:00
Stephanos Ioannidis aae454708d twister: Initialise Colorama during module load
This commit adds a call to the Colorama initialisation function during
the module execution so that ANSI color sequences are properly
converted to the relevant Win32 API calls on the Windows.

Note that the init function needs to be called per module, hence it is
also called in the `twisterlib.py`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-24 09:00:16 -07:00
Fabio Baltieri bd61ced760 twister: fix wrong flag name in the helpdoc
The flag --testcase-root has been renamed to --testsuite-root in

15bc98eb50 twister: rename TestCase -> TestSuite

Fix the --help text to reflect the change.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-20 19:22:20 -07:00
Anas Nashif bd1b364c2e twister: do not report filtered tests by default
Filtered tests are now not being reported by default to allow generation
of reports that are easier to parse and work with in different tools.

The complete filtered set of tests is still available in the json output
for review and verification.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 0313c5ce6f twister: hwm: rename forgotten connected_hardware -> duts
This was forgotten from an early overhaul, fix this as
connected_hardware attribute does not exist anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif d5a5cc131f twister: cleanup status and reason setting
Remove some legacy code and set status and failure/skip reason directly
without set_state and get_state.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif c820ffe18c twister: remove unused arguments in reporting functions
Remove unused arguments that became obsolete through the refactoring.
- filter_status
- only_failed
- json_report

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif dbd460fd04 twister: apply_filter: discards is not part of TestPlan
Use class member instead of local variable of discards.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 61f11536f9 twister: fix initial stats about discards
Fix discard stats in the summary.

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
Anas Nashif 7424c65779 twister: rename TestSuite -> TestPlan
Change terminology and fix usage based on the current hierarchy. A
testsuite is each test application we have in the tree. The top class is
where we detect all the test suites and create the testplan to be run
later.
Content of testplan will have to split out, so it only deals with the
plan and not the overall execution of tests. This step will be done at a
later point.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 2de0366784 twister: re-enable report filtering
Re-enable option to filter out skipped test cases as a result of
configuration or runtime filters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00