Commit graph

112 commits

Author SHA1 Message Date
Benedikt Schmidt
b83681d156 twister: Fix execution of twister in makefile environment
When run by a makefile twister might fail to decode the text results of
commands, based upon the environment settings of the system. With this
change escape characters are removed before the string is passed to the
json decoder.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2021-09-01 09:09:57 -04:00
Andreas Vibeto
32fbf8e414 twister: Fix bug re-running all tests when using test-only
When using both test-only and retry-failed flags, all tests would be
added to the test queue regardless if they failed or not. This commit
updates the logic to process test-only runs similar as other runs,
by adding tests to the queue with the 'run' operation directly.

Signed-off-by: Andreas Vibeto <andreas.vibeto@nordicsemi.no>
2021-08-20 18:58:47 -04:00
Martí Bolívar
c4079e4be2 scripts: rework edtlib warnings-turned-errors
Create a "global" gen_defines.py option and edtlib.EDT constructor
kwarg that turns edtlib-specific warnings into errors. This applies to
edtlib-specific warnings only. Warnings that are just dupes of dtc
warnings are not affected.

Use it from twister to increase DT testing coverage in upstream zephyr.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-03 12:21:45 -05:00
Kentaro Sugimoto
e8ab98712c refactor: correct spells to that probably intended
Make correction on the terms "intput" appearing
in sciripts/pylib/twister/twisterlib.py to "input" for all.

This type of misspellings may cause another unnoticeable misspellings,
when propagated by code completions.

(assuming that the "intput" was intended
to have the opposite meaning of "output",
which also appear on the same areas)

Signed-off-by: Kentaro Sugimoto <tarotene@gmail.com>
2021-08-02 12:13:23 -04:00
Andrzej Głąbek
cfaee96e92 twister: Add dt_nodelabel_enabled devicetree filter function
This function takes a node label (not a label property) and returns
true if a node with such label exists and the node is enabled.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-07-28 18:41:26 -04:00
Maciej Perkowski
d87160391f twister: No error when skipping quarantined tests in integration mode
When integration mode is on, any skips on integration_platforms are
treated as errors. This patch adds an exemption for quarantined tests.
They will stay as skipped.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-07-27 17:43:12 -04:00
Piotr Golyzniak
35a052066c twister: Fix wrong error counter in report
If "Cmake build failure" is detected test instance get status "error".
Despite this in final report this error is counted as failure. It can
be fix, by set proper results of each testcase in instance from None
to "BLOCK" after found Cmake error. After this fix, error is counted
properly in final report.

Fixes #37140

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2021-07-23 18:33:18 +03:00
Erwan Gouriou
e5bf24b325 scripts: twister: Fix error in dt_label_with_parent_compat_enabled
In dt_label_with_parent_compat_enabled, it maybe that there is
no node matching expected label.
In this case don't generate error, but return False.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-24 10:24:58 -04:00
Jingru Wang
fed1c54cf2 twister: try to clean ninja zombie
sometimes ninja fails to launch qemu, the sub-thread
can't read anything from qemu pipeline, then the
corresponding testcase will timeout. Then the
sub-thread will get blocked if it call join()

set terminate as the Handler's method, then
Handler's children class can call it

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-06-23 06:10:32 -04:00
Erwan Gouriou
3e1443ccf9 scripts/pylib: expr_parser.py: Review dt_compat_enabled_with_label
Function used for filtering "dt_compat_enabled_with_label" was not
working as expected as it was not taking into account that we're
looking for a children/parent combination:
Provided "compat" with enabled status should be the one of the parent
of the node matching given label.

Function is then reworked to take this into account.
And to make it's usage clear:
- function name is changed to be clearer on the intention
- args order is reversed to be more logical wrt the intention

Users of the function are also updated to take the change into
account.

Fixes #36093

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-21 20:31:49 -04:00
Anas Nashif
0e64b877da twister: fix hardware map generation
when generating a new map, set the status of the device and whether it
is connected or now. The available key is runtime only and is not part
of the map anymore.
Adapt documentation and remove available as a key in the generated map.

Fixes #35341

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 11:47:50 -04:00
Kumar Gala
92275cfa60 twister: Add ICCM/DCCM to list of overflow regions
On ARC some platforms utilize ICCM/DCCM for their "flash" and "ram"
storage.  So we might get errors about overflowing one of these regions.
So treat them similar to how we treat FLASH and SRAM.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-05-10 13:16:05 -05: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
Maciej Perkowski
d08ee92d26 twister: No skips for integration platforms in integration mode
All skips for platforms listed in the .yaml's integration_platforms
will be treated as errors in the integration mode ('-G/--integration').
This feature serves to guarantee a proper testing scope in CI as no
integration platform will be skipped silently.
Fixes #33874

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-04-22 20:10:26 +02:00
Maciej Perkowski
484ef6710d twister: Fix memory footprint reporting logic
With the previous logic memory footprint can only be saved in a report
if a given test/sample was fully executed and passed (built and run),
hence build-only tests were not providing these metrics. This commit
modifies the logic so that it is enough to have the build successful
to be able to get the memory footprint.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-04-18 21:49:21 -04:00
Jorgen Kvalvaag
36d96d2cd9 twister: Allow deep folder scan
Upon discovery of a sample/testcase.yaml file, twister will disregard
further subfolders. Given the folder structure below, the testcase.yaml
will currently not be discovered:

samples/sample1/
samples/sample1/sample.yaml
samples/sample1/tests/
samples/sample1/tests/testcase.yaml

This is desirable to allow placing test code closer to sample code.

Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
2021-04-16 15:46:09 +02: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
d590e0d18d twister: Adjust platform selection logic for platform_allow
In CI we typically build for "default" platforms.  However some
testcases that set "platform_allow" may have no overlap with the default
platforms and thus thoses testcases will not get built.

Change the platform selection logic in these cases to set the platforms
to the list of allowed platforms ("platform_allow") in the testcase.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-09 14:54:34 -04:00
Martí Bolívar
5332847644 dts: separate DT libraries from gen_defines.py
We are now in the process of extracting edtlib and dtlib into a
standalone source code library that we intend to share with other
projects.

Links related to the work making this standalone:

    https://pypi.org/project/devicetree/
    https://python-devicetree.readthedocs.io/en/latest/
    https://github.com/zephyrproject-rtos/python-devicetree

This standalone repo includes the same features as what we have in
Zephyr, but in its own 'devicetree' python package with PyPI
integration, etc.

To avoid making this a hard fork, move the code that's being made
standalone around in Zephyr into a new scripts/dts/python-devicetree
subdirectory, and handle the package and sys.path changes in the
various places in the tree that use it.

From now on, it will be possible to update the standalone repository
by just recursively copying scripts/dts/python-devicetree's contents
into it and committing the results.

This is an interim step; do NOT 'pip install devicetree' yet.
The code in the zephyr repository is still the canonical location.

(In the long term, people will get the devicetree package from PyPI
just like they do the 'yaml' package today, but that won't happen for
the foreseeable future.)

This commit is purely intended to avoid a hard fork for the standalone
code, and no functional changes besides the package structure and
location of the code itself are expected.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-04-02 08:28:12 -05:00
Maciej Perkowski
c2df1aaec6 twister: Fix removing dead code
Remove dead code from twisterlib.py which is a copy of code
from twister script. This redundancy causes pylint errors in
compliance checks.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-04-01 11:02:39 -04:00
Maciej Perkowski
e37d12e631 Twister: Refactor Test(Harness).handle()
The function `handle()` from class `Test(Harness)` had most of its
code being the direct copy of the code from
`Harness.process_test(line)`. This patch replaces the copied code
with the call for `process_test(line)` and removes repetition of
this function call.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-03-17 15:18:06 -04:00
Anas Nashif
a983a99318 twister: set verdict on tests after evaluating results
Do not set results before we finished parsing output.

Fixes #32514

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-17 11:28:22 +01:00
Johann Fischer
44a02c5ec5 twister: use edt.label2node in dt_compat_enabled_with_label DT filter
Use edt.label2node in dt_compat_enabled_with_label DT filter.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Co-authored-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-16 17:01:34 -05:00
Maciej Perkowski
f050a999f2 twister: Improve handling of errors while flashing device
The patch improves handling runners errors from flashing. It
add thread termination in case of process returning non 0 exit
code. Before, even though the error was returned,
a thread was not terminated and test ended
only after timeout termination. The patch also adds information about
the failure reason to the reports

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-03-16 09:05:28 -04:00
Johann Fischer
bb4749709e twister: add dt_compat_enabled_with_label DT filter function
The function returns true if the node with the referenced
node label is compatible and enabled.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-03-15 10:15:44 -04:00
Steven Huang
1413c55fbc twister: Raise exception if cmake is not found in path
Otherwise the real failure is swallowed and a TypeError exception is
raised instead.

Signed-off-by: Steven Huang <stevenhuang1995@gmail.com>
2021-03-15 08:58:34 -04:00
Anas Nashif
4bccc1db10 twister: fix integration selection
--integration without integration_platforms in the test definition is a
noop.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-12 19:50:54 -05:00
Enjia Mai
2c5e2c2394 tests: ztest: provide test execution times per ztest testcase
Add execution time for testing result of each ztest testcase as:

START - test_sem_multi_take_timeout_diff_sem
PASS - test_sem_multi_take_timeout_diff_sem in 2.54 seconds

Fix #32137.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-03-11 07:52:17 -05:00
Anas Nashif
e618a5964b twister: fix integration_platforms selection
Logic for selecting non-default platforms listed in
integration_platforms did not work. Functionality is restored in this
change.

Fixes #32835

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-11 05:48:40 -05:00
Martí Bolívar
51f55b437f twister: replace dt_compat_enabled_with_alias filter
Originally added in 7733b94224.

This filter is not well-formed. It's meant to match nodes like
/leds/led_0 in this DTS:

/ {
	aliases {
		led0 = &led0;
	};

	leds {
		compatible = "gpio-leds";
		led0: led_0 {
			gpios = <...>;
			label = "LED 0";
		};
	};
};

Uses look like this:

    filter: dt_compat_enabled_with_alias("gpio-leds", "led0")

But notice how the led_0 node doesn't have compatible "gpio-leds";
it's actually the *parent* node that has that compatible.

Replace this with a new filter, dt_enabled_alias_with_parent_compat(),
which is used like this:

    filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")

This has a name and argument order that makes the meaning of the
filter clearer.

Replace in-tree users with the new filter.

Deprecate the old filter and warn about its use using the standard
logging module.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-10 15:09:09 -05:00
Martí Bolívar
d802fc3bf0 scripts: twister: sort expr_parser.py imports
Just tidying up.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-10 15:09:09 -05:00
Andy Ross
098fce351f scripts/twister: Fix race with device-testing
CPython is sometimes described as "single threaded" due to the GIL,
but the interpreter will still "preemptively" switch between threads
(the details seem poorly documented).

So the time between checking whether acquire is 1 and decrementing the
count could result in more than one thread seeing an "available"
device, and more than one test being run (simultaneously, on the same
physical device!).  We have a big herd of threads all polling for
this, so in a large test run this would happen maybe one time out of
20-30 tries.

Use a lock.  Also remove the very similar looking
DUT.get_available_device() method, which had the same bug but appears
to be dead code.

Fixes #32679

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-04 12:39:54 -05:00
Martí Bolívar
fbd34dca1e twisterlib: add deprecated DT props to warnings_as_errors
Use EXTRA_GEN_DEFINES_ARGS to error out on deprecated devicetree
properties when warnings are treated as errors.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-03-03 10:22:36 -06:00
peng1 chen
6478735493 twister: fix the inconsistent total tests number
sometimes a test instance hasn't been boot up to execute successfully,
so the results is an empty dictionary, it will not be added into final
twister_report.xml file.
in order to include it, fill the results as BLOCK.

Signed-off-by: peng1 chen <peng1.chen@intel.com>
2021-02-24 16:00:35 -05:00
Sebastian Wezel
148dbdc9fe twisterlib: checking for classname and testname
Currently duplicated testcases are only determined by the classname.
This results in testcases not beeing added to the twister.xml if the
testcases are from the same class (e.g. sample.yaml), but with different
names.

The changed check if the combination of classname and testname
already exists.

Signed-off-by: Sebastian Wezel <sebastian.wezel@nordicsemi.no>
2021-02-23 10:57:14 -05:00
Andrei Emeltchenko
10fa48dd3e twister: Include coverage support for device testing
Include coverage support for device testing. It works by switching
capture_coverage to True (as it would meet coverage data start
pattern). Then we continue tot read coverage data until we get
coverage data end pattern. Otherwise, after receiving test result
pattern, we close serial console and do not get time to find start
coverage data pattern.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2021-02-15 08:13:48 -05:00
Maciej Perkowski
b6a69aa820 twister: bugfix: Fix twister output
Fix twister output. "Test suite" used previously did not correspond
to what was counted (test scenarios). A test scenario is an entry from
testcase/sample.yaml under "tests:", which specify configuration used to
build a test. Changes in docs will follow later on. Also replace the
amount of preselectd platforms with the amount of platforms that
were not filtered out and actually tested.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2021-02-09 06:55:41 -05:00
Torsten Rasmussen
a088970bc3 scripts: using pathlib for in get_toolchain() method
Followup commit on comment in #32003.

Using pathlib to avoid mixing of `/` and `\` if twister someday will be
able to run on Windows.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-05 06:48:18 -05:00
Anas Nashif
ce954d4769 twister: fix HW map fixtures parsing
We were not parsing fixtures from hardware map, so some tests are being
skipped.

Fixes #31948

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-05 06:36:14 -05:00
Anas Nashif
2a74053558 twister: fix possible race
Fix possible race when determining available devices. Find available
device and return it in the same operation to avoid the race.

Fixes #31769

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-05 06:36:14 -05:00
Torsten Rasmussen
d162e9e1ff cmake: twister: Using common script for toolchain setting verification
Fixes: #30713

Now using the common script `verify-toolchain.cmake` for verifying
toolchain settings.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-04 20:05:05 -05:00
Anas Nashif
e8cdbe03d2 twister: remove usage of deprecated gccarmemb variant
gccarmemb was deprecated 2 years ago, so remove it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-04 11:14:44 -05:00
Eugeniy Paltsev
afb34e3d5c twister: check if output is connected to tty before 'stty sane' call
As of today we unconditionally call 'stty sane' that leads to
lots of error messages
'stty: standard input: Inappropriate ioctl for device'
when output isn't connected to tty (for example when we launch
twister in Jenkins)

Fix that by check if output is really connected to tty before
'stty sane' call.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2021-02-02 18:41:12 -05:00
Jingru Wang
99b0720303 twister: rename variable p to log_root
The variable p represents the name of a platform, it shouldn't be
reassigned

Signed-off-by: Jingru Wang <jingru@synopsys.com>
2021-01-29 10:20:10 -05:00
Anas Nashif
ec47912292 twister: generate json report on demand
Do not generate json report by default. Use --json-report to generate
the file.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-25 09:56:53 -05:00
Anas Nashif
b1080ea036 twister: remove test type from json
This is always the same, so we might as well just remove it for now and
save some space since it is the default anyways. Type can be added later
when it provides more value.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-18 08:30:49 -05:00
Anas Nashif
cd1dccf9bc twister: fix json report
Fix JSON report generation and simplify it a bit.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-18 08:30:49 -05:00
Anas Nashif
211ef41125 twister: debug which coverage tool is being used
Add more debug messages about coverage tool being used.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-18 08:30:49 -05:00
Anas Nashif
827ecb7bd0 twister: fix build_on_all configuration
Logic for scope of platforms to be checked was changed and this options
now only applies to limited scope, fix this and reset scope when a
testcase declares it needs to build on available platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-01-14 13:59:42 -05:00