Commit Graph

254 Commits

Author SHA1 Message Date
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 6a5b88e523 scripts: west: move domains.py to a generic library folder
Since twister can make use of domains.py as well, refactor west's use
this file so that domains.py can be moved to a generic library folder.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-26 08:48:37 -04:00
Jeremy Bettis a84c271e58 twister: Fix OUTPUT: blank lines after test end
When running twister -vv many blank lines would be logged.

Fix handing of empty lines from the reader thread. Real blank likes will
be b"\n" not b"".

Change open call to use with, and logger to use %s to fix pylint
warnings.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2022-10-25 09:28:15 -04:00
Piotr Węgliński 08eb361846 ci: twisterlib: Modify the overlay regular expression
Modify the regex used to merge overlays specified for
test samples in twister tests.
Overlays without any prefixes will be merged and passed to cmake.
Overlays with prefixes won't be merged but passed to cmake as they are.

Signed-off-by: Piotr Węgliński <piotr.weglinski@nordicsemi.no>
2022-10-24 08:26:17 -04:00
Ming Shao 75914111d9 twister: fix the mis-placed drain logic.
The logic to drain the leftover logs of previous test should be
put before the monitor_serial(). It was misplaced when re-adding
this logic back.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-20 15:42:25 +02:00
Anas Nashif cc7d337ea7 twister: do not error on intentionally skipped tests
if we mark a test to be skipped, do not error in integration mode about
filter conflicts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-13 06:23:46 -04:00
Anas Nashif 6a5af72d66 twister: count errors identified during evaluation of tests
Some tests report errors based on configuration, those need to be
captured.

Fixes #51202.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-13 06:23:46 -04:00
Evgeniy Paltsev d9a64b7b23 twister: fix UnicodeDecodeError on input handling in BinaryHandler
In BinaryHandler we process input from simulator with decode('utf-8')
to convert it to string. decode has strict error handling by default -
so it raises UnicodeDecodeError exception if it can't decode input
binary sequence.

So if test start to print some junk to uart console we get
UnicodeDecodeError exception which cause the whole twister crash.

To fix that switch decode to less strict error handling when it
just replace undecoded binary sequence with unicode replacement
character.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-10-11 08:25:39 -04:00
Anas Nashif b2a95831eb Revert "twister: temporarily disable mec15xx boards"
This reverts commit b3ead37efa.

This is no longer needed, pinmux was removed and deprecated.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 07:46:39 -04:00
Cong Nguyen Huu 4d41f54d08 twister: support generate hardware map on windows
On windows, some board manufacturers have name that is "Microsoft"
instead of real its name. Need add it to manufacturer list.
Product information is missing. we can assign it "unknown" and
then add missing informations  by hand.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2022-10-06 07:23:17 -04:00
Cong Nguyen Huu 5b2b5dfec0 twister: run tests on device with twister on windows
Currently, support for Twister on Windows is only build.
The only thing that needs to be ported is that select()
cannot wait on file descriptors on Windows. Therefore
the serial monitor function needs to be reworked to
support both OSes.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2022-10-06 07:23:17 -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
Ming Shao 8b46675e2b twister: add comment about stats logic
Add comments and docstring to class  ExecutionCounter to explain
the twsiter stats logic.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-01 06:42:54 -04:00
Ming Shao 94f2d2437f twister: refine the twister test plan generation
Due to the diverse coding styles and lack of preprocessing when
scanning for test cases, there were many unintended combinations
of yaml test scenarios and C test functions with the regex-based
test case discovery, which caused an inaccurate test plan and test
result stats.

As the new ztest fx is used, the test cases of a test instance can
be accurately determined via zephyr.symbols file.

Because the zephyr.symbols file is not available until after build,
test cases determination is placed right after the build stage of
the pipeline and before the runtime test collection.

For those test instances that don't go through the build stage,
such as those with "Skip filtered" (statically filtered) reason
before entering the pipeline, they are not affected.

This patch also adjust the stats logic because the zephyr.symbols
file is generated after build. So ExecutionCounter update is split
and some must be postponed until test execution pipeline is completed.

Some concepts:

A test instance = a yaml scenario + a platform
"Test instance" and "test config" are synonyms in twister, unfortunately
excessive IMHO...

A test instance can be filtered or skipped in 3 ways.
Let's define "runtime" as "after entering the execution pipeline".

1) statically filtered (before runtime)
   Such test instance is filtered by analyzing the yaml and never
   enters the execution pipeline.
2) cmake filtered (runtime)
   Such test instance enters pipeline and is filtered at cmake stage.
3) build skipped (also runtime)
   Such test instance enters pipeline and is skipped at build stage.

All the test instances that enter the execution pipeline will go
through the report stage, where ExecutionCounter is further updated.

The meaning of the fields of ExecutionCounter are:

 .skipped_configs = static filtered + cmake filtered + build skipped
 .skipped_runtime = cmake filtered + build skipped
 .skipped_filter = static filtered
 .done = instances that enter the execution pipeline
 .passed = instances that actually executed and passed

Definition of the overall stats:
total_complete = .done + .skipped_filter
total = yaml test scenario * applicable platforms
complete percentage = total_complete / total
pass rate = passed / (total - skipped_configs)

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-10-01 06:42:54 -04:00
Stephanos Ioannidis b8643cb429 twister: size_calc: Remove stale `k_mem_pool_area` reference
This commit removes the stale reference to `k_mem_pool_area` for the
memory pool API, which was removed in the v2.5.0 release.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-09-28 14:24:34 +00:00
Ming Shao 2cea5850e2 twisterlib: re-add the logic to drain the serial leftover
This logic was added before but seems to be missed during the
twister refactoring.

Some tests can cause serial leftover logs buffered somewhere.
Such leftover can interfere with the next test case because the
serial log monitoring thread is started before a board is flashed.
And the monitoring thread can be fooled by such leftover logs and
make incorrect judgement of the test result.

A simple ser.flush() is not enough to eliminate such leftovers.
So add explicit readline() to drain such logs which ensures a clean
serial context for the case that follows.

An example from reel board captured with this patch:

leftover log of previous test: b'.287 seconds\r\n'
leftover log of previous test: b' - SKIP - [...test_coredump_backend]...
leftover log of previous test: b'\r\n'
leftover log of previous test: b'------ TESTSUITE SUMMARY END ------\r\n'
leftover log of previous test: b'\r\n'
leftover log of previous test: b'=====================================...
leftover log of previous test: b'RunID: 4e93757ad...53dcab9f0f5c6\r\n'
leftover log of previous test: b'PROJECT EXECUTION SUCCESSFUL\r\n

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-09-22 15:15:55 -05:00
Fabio Baltieri 96fc137654 twister: treat imgtool image exceeded as flash overflow
Twister detects FLASH overflow and skips tests that trigger that
condition by default, but sometimes images are just on the flash size
limit and then overflows at a later stage when imgtool adds a trailer,
which gets detected as a build fail and fails the run.

This detects the imgtool flash overflow together with the normal build
ones, causing the build to be skipped on imgtool flash overflow as well.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-09-22 12:41:25 +00:00
Anas Nashif b3ead37efa twister: temporarily disable mec15xx boards
A workaround to exclude boards from twister. Other solutions do not work,
setting twister fields to false in the board yaml file is not enough,
given that this board has many associated samples and tests, so it can't
be disabled on its own.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-21 18:05:51 +00:00
Torsten Rasmussen 8d2998d4f9 cmake: rework of host tools and generic toolchain handling
Follow-up: #41301

This commit is a rework and cleanup of the tools handling in Zephyr
CMake build system.

Instead of directly loading code a CMake modules for tool lookup, the
host tools now follows the CMake `find_package()` pattern for finding
programs / tools in module mode.

This makes it more clear which modules are responsible for finding tools
and which modules provides build integration / features.

The following tools can now be found using `find_package()`:
- Zephyr-sdk        : find_package(Zephyr-sdk <version>)
- Generic host tools: find_package(HostTools)

This further allows us to decouple the `verify-toolchain` CMake script
part required by `twister` into a tool lookup module and a dedicated
CMake script which utilizes the lookup module.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-01 15:59:43 +02:00
Tristan Honscheid 52db2d8279 twister: Remove import exception handler for psutil
`handlers.py` treats the `psutil` package as optional and quietly prints
a message to stdout if it is not present, but it is actually a hard
requirement for the base `Handler` class. This try/except block is bad
as it hides the requirement until a timeout occurs and the handler
attempts to use `psutil` in the terminate method, which will crash if
the module happens to be missing.

This PR removes the try/except guard so missing `psutil` will cause
twister to immediately fail. `psutil` is already specified in the
`requirements.txt` file, so this should only affect users who
unwittingly have an outdated/incorrect environment.

Also update the Github Action for twister tests to install from
requirements files.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-09-01 06:22:04 -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
Martí Bolívar 88aa873fbc twister: improve logging of cmake commands
With verbose output enabled, twister logs the cmake arguments as a
python array whenever it invokes cmake to generate a build system.

This is clunky output for manual reproduction, because it forces the
developer to manually join the arguments together for consumption by
the shell.

As an enhancement for this use case, use the standard library
shlex.join() function to produce a string that can be copy/pasted
directly into the shell on POSIX platforms.

We should use this function instead of str.join, because it correctly
handles things like shell quoting for options with spaces in them.

This function is not available on Windows, so we fall back on behavior
that is similar to the old one there.

The main difference on Windows is that the output now includes the
path to cmake as well, and not just its arguments. (This is the same
on POSIX, and is intended to help debug if multiple cmakes are
installed on the same machine.)

We are running cmake from a couple of different places, so doing this
cleanly requires adding a shared module with the platform abstraction.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-26 08:53:14 +02:00
Kumar Gala f16e2a9d80 twister: Add esp32 section name to overflow check
esp32 platforms can overflow their dram0_1_seg so add that section name
to the overflow check in twister.  We were seeing this with the
samples/arch/smp/pi/sample.smp.pi test and would get:

 zephyr_pre0.elf section `noinit' will not fit in region `dram0_1_seg'
 region `dram0_1_seg' overflowed by 17456 bytes

Fixes #49164

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-22 12:04:24 -04:00
Daniel Leung 835680f0e7 twister: enhance support for board@revision as platform name
This adds an extra layer to match the revision part where this
needs to be of permitted patterns as described in.
cmake/modules/extensions.cmake. Without this, the matching
may produce undesirable results. For example, if there is
a file named qemu_x86_tiny_1.conf, the testplan will create
a board name qemu_x86@tiny.1 (which is definitely not correct).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-18 17:23:18 +02:00
Andy Ross e05d0132fd scripts/twister: Kill qemus with SIGKILL, not SIGTERM
On qemu_cortex_a53 with icount enabled, the qemu process will spin
hard at the end of its run (common with icount), but will also ignore
the SIGTERM twister is sending to terminate the (successful!) test
run.  The resulting zombie spinning processes end up accumulating and
poisoning the test run.

Just use a hard KILL instead of trying to be a good citizen (and in
lieu of fixing the upstream qemu bug).  I can't see why this should be
a problem.

Signed-off-by: Andy Ross <andyross@google.com>
2022-08-18 10:19:19 +02:00
Enjia Mai a2160efed3 twister: fix the hanging up on an exception happens during west flash
Fix the missing logic of setting the flash_error flag when
caught the exceptions. And we should let the serial thread
can be run first if flash error. Otherwise the twister will
hang up while an exception happens on closing serial, after
the #47820 got merged. This mostly happens on frdm_k64f.

Fixes #49086

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-17 15:24:13 -05:00
Enjia Mai e33fd73546 soc: xtensa: add support for specifying the service port
Add specifying the port for the remote cavstool remote service.
Ex.

    west flash --remote-host {host}:{port} \
               --pty {host}:{port}

Specify the port is optional when running west.

And another major change is now we have to specify the remote log
service by --pty to make it output the log message immediately.
Previously it will output directly. Why we make this change is
because this is more close to the behavior we use west flash.

Fixes. #46865

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-08-16 22:51:53 -07:00
Guo Lixin 0ea346009f twister: avoid monitor serial when flash error
Currently, twister keeps on monitoring serial output until timeout
even if we have a flash error. And the error reason will be reported
as 'No Console Output(Timeout)', which is not accurate.
So add a flash_error flag to control if we need to monitor the output.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-08-13 08:52:03 -04:00
Anas Nashif f28a8d2240 twister: fix bug retrieving subtests
During the recent overhaul, some code was left retrieving cases the old
way.

Fixes #48897

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-12 17:39:35 +02:00
Carles Cufi a580b3d174 west: Fix handling of modules in the boards command
The boards command was not properly using the zephyr_module
functionality to obtain the board roots of all modules. Fix that by
moving the functionality required to the core zephyr_module file and
reuse it from external scripts.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-09 16:07:51 +02:00
Chen Peng1 7f105cea87 twister: support board@revision in platform filter
support to use board@revision as platform filter when running
twister, like "twister -p nucleo_f030r8@1 ...".

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-08-09 08:45:55 -04:00
Piotr Golyzniak 4484f68d02 twister: verify platform names from quarantine
Add verification of platform name from quarantine list.

Fixes: #43450

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-08-01 09:29:03 -04:00
Anas Nashif c0317fba1f twister: handler quotes in extra_args
Escape quotes provided in extra arguments on the command line.

example: ... -x "CONFIG_COMPILER_OPT=\"-fanalyzer\""

Fixes #46382

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-29 05:58:15 -04:00
Piotr Golyzniak 7ce914b7f4 twister: verify all platform names
Fix bug in verify_platforms_existence method - make it possible to
verify all platform names from list - not only first.

Fixes: #48321

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2022-07-26 20:42:20 -04:00
Stephanos Ioannidis 0f9588e51f scripts: twisterlib: Fix default value for --ninja argument
This commit makes the `--ninja` argument default to `true` when neither
`-k` nor `--make` is specified (i.e. when Make generator is not
selected).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-26 20:17:59 -04:00
Stephanos Ioannidis 1f81d2cd97 scripts: twisterlib: Fix --short-build-path argument handling
When `--short-build-path` argument is specified to the twister, the
following error message is displayed because the Python argparse module
does not allow specifying a mutually exclusive argument as required:

  ValueError: mutually exclusive arguments must be optional

This commit removes the `required` parameter when adding the `--ninja`
argument, which is a mutually exclusive argument, and adds a manual
check to validate this condition instead.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-26 20:17:59 -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
Jason Wright c6c7dde969 scripts: better logging for --coverage-formats option
Adds additional log messages for coverage reports
beyond HTML format.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-07-18 15:03:13 -04:00
Jason Wright 60c4d20548 scripts: restrict --coverage-formats option to gcovr
Generates an error if --coverage-formats option is supplied without
coverage tool being set to gcovr.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-07-18 15:03:13 -04:00
Jason Wright 786f28f162 scripts: add --coverage-formats option for use with gcovr
Adds optional twister flag to support gcovr output report formats.

Signed-off-by: Jason Wright <jwright@synchron.com>
2022-07-18 15:03:13 -04:00
Chen Peng1 e7088743df scripts: twister: only load connected hardwares.
only load hardwares with connected is true in
hardware map files.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-07-13 06:18:08 -04:00
Chen Peng1 1d5c37ab96 script: twister: fix hardware runner_params parsing.
The specific hardware instance is already got from
device_is_available function, we don't need to
iterate all hardwares again.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-07-13 06:18:08 -04:00
Anas Nashif a2fbb783dd twister: fix new ztest parsing
Somehow this change was dropped (rebase?), this is needed to parse new
ztest test correctly, otherwise will have many tests missing from the
plan.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif 5f146dcaf9 twister: prep for device testing
Add option to prepare for device testing by only building and storing
the needed data that can then later be executed and run on DUT using
--test-only.

This adds --prep-artifacts-for-testing which is the same as --build-only
and --device-testing and other options that were needed to make this
operational and produce the right binaries and files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif 68a8613a92 twister: fix --build-only argument help
Minor fix to the --build-only option help.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif 398e9902b8 twister: rename argument group: serial -> device
using serial as the group name is misleading, so call it 'device' which
is what all those options about.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-13 10:13:28 +02:00
Anas Nashif e1e43015ec twister: also parse cpp files in app root
Fix wildcard to also scan cpp files in root folder of test application.

Fixes #47220

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-12 23:24:41 -04:00
Anas Nashif 9e3d697f15 twister: fix calculation of testsuite names
We were omitting one element of the path by mistake.
Also fix some naming issues in the testsuite.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 15:07:35 -04:00
Anas Nashif 1463f4bdc5 twister: rework testsuite parsing
Move testsuite setup and parsing to the testsuite class. Simplify
reading data from yaml.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00
Anas Nashif 4789f07a8f twister: fixups to various files
Various fixups, will be folded in correct commits eventually.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-05 12:06:27 -04:00