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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Generates an error if --coverage-formats option is supplied without
coverage tool being set to gcovr.
Signed-off-by: Jason Wright <jwright@synchron.com>
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>
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>
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>
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>