Commit graph

822 commits

Author SHA1 Message Date
Anas Nashif
c9daae592a twister: fix reporting of status and duration
Various fixes to reporting and filtering of results.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
eba9792a1b twister: generate unit from json
We now have all the logic for generating data suitable for reports in
one single place (json). The junit reports and in the future other
reports will be using this as input and generate reports using the json
data.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
1de0a3dc93 twister: remove release data handling
An obsolete feature that is no longer being used due to the amount of
data that is needed per release and the fact it becomes stale very fast.
Instead, point to files directly for comparison.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
3dcc038274 twister: use json instead of csv for everything
Drop CSV generation which was the standard for sharing information since
the early days and instead use json with more content to share
information across sessions and for report generation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
17b654c19f twister: rework json reports
Refine structure and accomodate more data, this report will serve as the
source for a testplan, reports and retries.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif
d5dbeb2f17 twister: improve reporting of filtered and built cases
Specify why something was skipped (either filtered or through a ztest
case) and do not report testcases that are only being built as passed,
mark those tests as skipped with the reason specified as "Build only".

Keeping --no-skipped-report for now, although it has no impact.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Al Semjonovs
ce54efaf70 twister: Add seed as argument for native_posix builds
Use the seed as arg for ZTEST_SHUFFLE enabled builds

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2022-05-11 12:14:31 -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
Maciej Perkowski
edcc85d3d5 bugfix: twister: Store run_id in csv meta file so it can be reused
A unique run_id is now also added to the twister.csv file. This
file is used to store meta-data, in particular for `--test-only`
option. The run_id is then reused in `--test-only` calls to verify
if the id from readout matches the expected one.

fixes: #45278

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-05-04 09:39:50 -05: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
Piotr Golyzniak
b029bfd65c twister: set encoding during open log file
Set the same encoding for collected CMake output and file where this
output will be saved.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-04-19 08:40:34 -04:00
Piotr Golyzniak
d54cb04fb7 twister: option to disable suite name check
Add option to disable ZTest test suite name verification.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-04-14 10:16:06 -04:00
Anas Nashif
540327ee4f twister: generate and verify test run id
Set run id (md5 of instance and a random number) for each test and match
what was set during build with the output on the screen. This will
verify that we are evaluating the same test we have uploaded and not
some previous output on the screen.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-12 08:54:41 -07:00
Piotr Golyzniak
806cc70f7c twister: harness: fix ztest detection
Decision about whether test should be considered as ztest should be made
after detection ztest testcase - not after detection ztest test suite.

Fixes: #44397

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-31 22:31:08 -04:00
Piotr Golyzniak
c459b752f5 twister: add search ZTEST_SUITE, ZTEST and ZTEST_F
New ztest API is available in those places:
subsys/testsuite/ztest/src/ztest_new.c
subsys/testsuite/ztest/include/ztest_test_new.h

This requires also changes in Twister code during parsing c files to
find properly test suites and testcases.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:59:10 -04:00
Piotr Golyzniak
e2d903fe31 twister: extend searching src directory
Extend scope of searching src directory with defined test source code.
In some cases for optimization reason src direcotry is placed in parent
directory (in relation to testcase.yaml file placement). This changes
allow to detect such situations.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:59:10 -04:00
Piotr Golyzniak
340da2ecf3 twister: verify ztest suite name in output
Test wirtten in ztest framework should print in output information about
test suite name defined in test's source code (as a first argument of
ztest_test_suite() function). This changes make it possible to find such
test names in c files. Next they are used during test execution to
verify if performed test was performed properly (verification can base
not only on existance of "PROJECT EXECUTION SUCCESSFUL" info).

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:59:10 -04:00
Piotr Golyzniak
cdfa230131 twister: change serial option existence verification
Modify serial and serial_pty option availability verification in DTU
object in device_is_available method to avoid situation when empty string
passed as serial in hardware_map.yaml cause hang up Twister in this
place.

Fixes: #41169

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-03-24 07:54:22 -04:00
Mikkel Jakobsen
646499c36e twister: fix valgrind failure handling
falures found during valgrind execution were treated as normal test
failures, so the logger would display a link to handler.log and not to
valgrind.log, leading to some confusion.

the return code is now handled in a correct sequence.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-23 09:21:50 -04:00
Mikkel Jakobsen
78aa424f69 twister: error if valgrind executable not found
if --enable-valgrind is selected but no valgrind executable can be
found in PATH, exit with an error

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-23 09:21:50 -04:00
Mikkel Jakobsen
9314f6e527 twister: add --track-origin to valgrind execution
generate full information when looking for uninitialized variables

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-23 09:21:50 -04:00
Anas Nashif
ab9de7c6d7 twister: support retrying on build errors
Allow retries on build errors, this is now done using
--retry-build-errors. This option is useful when for example build
failures are caused by licensing issues or intermittent network issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-22 12:09:14 -04:00
Anas Nashif
becef8c83b twister: Improve counting and count at runtime
Do not wait till the end to update counters, do the counting at
realitime and reuse data for on-screen reporting.

Add a counter summary function for debugging.

This patch changes how we count and report skipped tests and the total
now has the skipped tests included.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-22 12:09:14 -04:00
Nazar Kazakov
f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Maciej Perkowski
62c7774014 twister: footprints: Move footprint calculation
Adds operation "gather_footprint" after the build stage
with minor refactoring. Before footprints were collected
only at the very end of the twister workflow
and there were situations were elf files were not available any more
(for qemu and --runtime-artifact-cleanup used).

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-03-17 18:23:59 -04:00
Andreas Pettersson
d356280b54 twister: make git describe work without tags present
Git describe should work in eg. shallow clones when there are no tags.
Has been fixed in cmake previously, but not in twister.

Signed-off-by: Andreas Pettersson <andreaspettersson95@gmail.com>
2022-03-14 14:54:40 -04:00
Chen Peng1
1246404923 twister: fix skipped count issue in xml result with --only-failed.
When running twister with --only-failed option, based on last xml
result, the new skipped count should be the last skipped count
plus current skipped count.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-03-14 14:39:42 -04:00
enjia mai
be7dabed19 Revert "twister: passing the build dir to device serial pty"
This reverts commit 919b014509.
2022-03-11 17:57:04 -05:00
Enjia Mai
919b014509 twister: passing the build dir to device serial pty
Passing the zephyr build directory to the script run by
--device-serial-pty, it makes the feature of the device serial
pty more flexible.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-03-10 13:29:06 -05:00
Anas Nashif
dd651c0323 twister: add option to ignore skipped tests in reports
With --no-skipped-report, twister will skip over all tests marked as
skipped (filtered) in the junit report.

This is useful for CI where have 1000s of filtered tests that appear in
the report and in some cases cause tools parsing the output to fail or
provide incomplete results.

Fixes #38179

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-03-03 12:12:03 -05:00
Maciej Perkowski
02f949401e twister: footprints: Fix missing memory footprints
Commit 28b2e55321 introduced a regression
into twister workflow, breaking memory footprint calculation.
The commit changed name of produced .elf files.
There is no more zephyr_prebuilt.elf and instead we have
zephyr_pre0.elf and zephyr_pre1.elf. This commit fixes a filter
telling which files to exclude when calculating memory footprints,
to match the current status.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-03-02 10:02:40 -08: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
Jingru Wang
eb614e268c scripts: twister: output error message
Sometimes custom script fails, but we can't see the
error information in twister log, because the twister
uses _ to ignore the stderr.

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2022-02-22 18:52:39 -05:00
Torsten Rasmussen
61453e4a58 cmake: Zephyr CMake package and CMake modules
Create a cmake/modules folder containing all Zephyr CMake modules.
All Zephyr cmake files that are included from boilerplate are now
converted into CMake modules which can be individually loaded.

The Zephyr CMake package is updated to support loading of individual
CMake modules using the COMPONENTS argument to `find_package(Zephyr)`.
If the COMPONENTS argument is not specified, the default Zephyr build
system will load.
If COMPONENTS is specified then, only those components and the
dependencies will be loaded.

If a Zephyr CMake module depends on another CMake module which has not
been loaded, it will automatically be loaded.

This allows us to modularize and reuse individual parts of the Zephyr
CMake build system in a more flexible way in future.

Such usage could be:
- Higher livel multi image build system
- Invocation of individual components, for example dts processing by
  twister without loading all build code
- Doc build
- Unittesting

With this new CMake package and CMake module scheme then direct
sourcing of boilerplate.cmake has been deprecated.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-02-22 10:02:39 -08:00
Anas Nashif
c50966ac17 twister: support xt-sim as a runnable target
Use xt-sim to run Xtensa simulator in twister.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-21 22:10:42 -05:00
Piotr Golyzniak
b618f4bf8e twister: add option to create shorter build paths
Add possibility to create shorter build paths when --short-build-path
option is enabled. This can help during run Twister on Windows OS and
building programs by CMake which has a problem when paths with building
files are too long. The solution based on symbolic links which help to
connect "traditional" long paths with shorter one like:
"twister_links/test_0".

Fixes #41929

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-02-21 19:39:32 -05:00
Piotr Golyzniak
c8862db1d9 twister: add setting skip reason
When testcase written in ztest is skipped by ztest_test_skip() function,
then "SKIP" information is printed in output data. This "SKIP" result is
set as result of performed testcase, but the information about reason is
still "Unknown". This patch fix this problem and if all test scenario
has state "passed" (so testcases have result "PASS" or "SKIP"), reason
is still set as "Unknown" and if any of testcase has result "SKIP" then
set reason as "ztest skip".

Fixes #42414

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-02-09 19:44:33 -05:00
Chen Peng1
5b102040c2 twister: ignore unencodable unicode of west flash command.
sometimes there are some unencodable unicode chars from output
of west flash command, need to ignore them rather than reporting
an error.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-01-25 08:15:17 -05:00
Marc Herbert
8a603da6cd twister: add -Werror to CMAKE_AFLAGS
This reports the warning fixed in commit 61fe69dded ("sys:
device_mmio.h replace <toolchain/common.h> with <toolchain.h>")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-11 12:32:27 -05:00
Marc Herbert
19e4e12c03 twister: remove spurious quoting of EXTRA_xFLAGS=-Werror
Testing shows cmake is invoked directly, not through a shell.

Fixes commit 5092541e2b ("sanitycheck: disable erroring on warnings").
Note EXTRA_AFLAGS was quoted only on the left side!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-11 12:32:27 -05:00
Piotr Golyzniak
483101fe36 twister: raise error for non-existing platform call
Changes will raise error and break program in following three situations:

1. Platform name pass in --platform option does not exist.
2. During using --all option, platform from platform_allow list does not
exist.
3. During using --integration option, platform from
integration_platforms list does not exist.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-01-11 09:53:40 -05:00
Piotr Golyzniak
16dbc115c7 twister: fix skip marked as pass in json report
When some testcase is skip in their source code by ztest_test_skip()
function in final json report it is marked as pass what is wrong. Due to
the changes in this commit those skips can be marked properly.

Fixes: #41440

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-01-06 07:55:16 -05:00
Anas Nashif
526ee4c74f twister: do not use deprecated arguments to nrfprog
--snr is deprecated, so use --dev-id instead.

Fixes #40449

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-15 14:09:49 -05:00
Anas Nashif
018ccd6210 twister: fix baud setting for detected devices
When generating new map we store serial_baud, but the schema has 'baud'
only, so call this baud in the class and resolve the issue of creating
new maps.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-15 14:09:49 -05:00
Anas Nashif
d1991e9952 twister: remove lock from generated hardware map
remove lock before storing yaml file.

Fixes #39179

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-12-15 14:09:49 -05:00
Piotr Golyzniak
3194f75098 twister: log error for non-existing platform call
Changes will log error message in following three situations:

1. Platform name pass in --platform option does not exist.
2. During using --all option, platform from platform_allow list does not
exist.
3. During using --integration option, platform from
integration_platforms list does not exist.

Fixes #31868

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-12-15 09:38:55 -05:00
Erwan Gouriou
82b290ef48 scripts/pylib/twister: Add sn option to stm32cubeprogrgammer runner
In order to enable use of stm32cubeprogrammer runner with twister,
add "sn" tool specific option which allows to provide target serial
number and hence select the target to flash when multiple ones are
connected to the host.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-12-13 17:20:17 -05:00
Torsten Rasmussen
41c25a2de4 twister: remove CMAKE_EXPORT_COMPILE_COMMANDS=1
The -DCMAKE_EXPORT_COMPILE_COMMANDS=1 is removed from twisterlib.py as
it is now always set by the Zephyr build system.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-11-25 10:41:28 -05:00
Piotr Golyzniak
8b773481e9 twister: reenable build samples on Windows OS
Fix few limitation which do not allow to run Twister on Windows OS.
Especially turn off "import pty" module, due to the fact, that this
module can be used only on POSIX OS.

Fixes #40007

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-11-04 07:33:39 -04:00