Commit graph

4261 commits

Author SHA1 Message Date
Gerard Marull-Paretas a4858c40ec scripts: build: elf_parser: _DEVICE_STRUCT_HANDLES_OFFSET is optional
It is only available if CONFIG_DEVICE_DEPS=y, so the ZephyrElf class
would fail to load if it does not treat _DEVICE_STRUCT_HANDLES_OFFSET as
optional.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-01 15:50:32 +02:00
Maciej Perkowski fb9a6af700 scripts: west_commands: Allow passing source dir when looking for test
Before, only following way of getting test-item build was supported:
`west build -b <BOARD> -T <PATH_TO_SOURCE/TEST_NAME>`
This commit allows to also call it by:
`west build -b <BOARD> <PATH_TO_SOURCE> -T <TEST_NAME>`

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2023-08-31 12:06:18 -07:00
Piotr Golyzniak e326015cda scripts: pytest: add Shell helper unit tests
Add unit tests dedicated for Shell helper sample class.
Add shell_simulator_script.py script to simulate shell application
behavior.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 577d421ba7 scripts: pytest: add pytester tests
Add tests which use pytester to call pytest with pytest-twister-harness
plugin on previously defined test. This gives a possibility to test
plugin in end-to-end variant.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 36e2b8e2b2 scripts: pytest: add tests to new adapters API
According to new adapters API add new tests which verify their
correctness. Introduce some minor naming changes to describe better
their role.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak eb672ddd0a scripts: pytest: improve plugin options
Add better description of available options and add actions which
should help to prevent from passing invalid options to plugin.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak a31b24372c scripts: pytest: remove logging configuration
Remove log.py and by this logging configuration from
pytest-harness-plugin. Instead use pytest options for setting verbosity
and format of printed logs. Thanks to this management of verbosity
level can be easier for users.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak ffbe257663 scripts: pytest: create helper class Shell
Create helper class Shell which can be used in tests which require
interaction with shell application.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak ceb61f38ea scripts: pytest: move helper.py to utils.py
Move helper.py file content to utils.py file in device directory,
where those helper functions are used.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 32c2be0234 scripts: pytest: divide dut fixture
Divide dut fixture into three smaller fixtures to make it easier
to user to change dut fixture scope or to write her/his own dut
fixture. Add initialize_log_files method to make it possible to
initialize log files per each test.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 967dfd97c3 scripts: pytest: pass test name to handler.log
Pass pytest test name to handler.log header to make it easier to
analyze handler.log content.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak a4a550888e scripts: pytest: add readlines_until
Add readlines_until method to DeviceAdapter class to simplify using
adapters in tests by give user possibility to read output from device
until following conditions:
- provided regex was found
- provided number of lines was already read
- timeout was occurred

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 2e333000b5 scripts: pytest: refactor FifoHandler class
Introduce changes into FifoHandler class to make it more safe
(especially to avoid blocking all program when FIFO queue is not opened
by other application).

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 9b7e64ab1a scripts: pytest: remove constants.py file
Constants variables are no longer used, so this file can be removed.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak 6ddc1431ee scripts: pytest: remove log_file.py
LogFile class is not used anymore, so there is no sense to keep it
and its unit tests.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak f22c2d6388 scripts: pytest: align adapters API
Select and place common code of three adapters (HardwareAdapter,
BinaryAdapterBase and QemuAdapter) into basic DeviceAdapter class.

Introduce new way of reading device output by run separate thread which
try to read device output and place it into internal python queue.
Thanks to this, now it is possible to create readline method for all
adapters, which can be unblock when timeout occur.

Collect all common steps which have to be done before setup device in
launch method. The same was done for teardown operations which were
placed into close method.

Additionally some protection mechanisms were introduced to prevent for
undesirable side-effects when user could try to launch to already
launched device or try to send some data to disconnected device.

iter_stdout method was replaced by two new methods: readline and
readlines. To make it possible to remove all read output from internal
buffer (queue), clear_buffer method was introduced.

Also unit tests were rewritten to work properly with current version
of adapters.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak b5d496019f scripts: pytest: rename SimulatorAdapterBase
Change name of SimulatorAdapterBase class to more meaningful like
BinaryAdapterBase. This changes is also made to be more align with
Twister terminology.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak c54d55c2d8 scripts: pytest: rename DeviceAbstract
Change name of DeviceAbstract class to more meaningful like
DeviceAdapter.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Piotr Golyzniak b486b2acab scripts: pytest: unify timeouts
Add possibility of passing timeouts from Twister to pytest and unify
various timeouts used in adapters to point to one main timeout.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Grzegorz Chwierut 2990586b45 tests: pytest: Fix for pytest warning
PytestAssertRewriteWarning is raised when pytest-twister-harness
plugin is called from twister. Call register method to get rid
of that warning

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
2023-08-30 06:39:55 -04:00
Jeremy Bettis 1e471eb2a7 twister: Switch to a non-greedy regex
When parsing test names from symbol names, use a non-greedy match to
avoid parsing test names with __ in them.

The symbol looks like z_ztest_unit_test__SUITE__TEST. It is more likely
that a test name will contain __ than a suite name, so now something
z_ztest_unit_test__a_b__c_d__e_f will be parsed as suite:a_b
test:c_d__e_f, whereas it used to be parsed as suite:a_b__c_d test:e_f

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2023-08-29 10:27:17 +02:00
Jeremy Bettis 1d9ce862a7 twister: Don't require test_ prefix to set status
If a test doesn't start with test_, twister currently emits an error:
suite_name.test_name: Unknown status 'started'

Following the suggestion by Maksim Masalski on PR#21191, change the
regex to exclude spaces in the test name, and remove the check that the
test_ prefix exists.

See also #21162

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2023-08-29 10:27:17 +02:00
Jeremy Bettis cd265fd603 twister: Use raw string and remove pylint disable
Avoid the pylint anomalous-backslash-in-string warning by using a raw
string.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2023-08-29 10:27:17 +02:00
Anas Nashif d4b0c48892 west: build: fail early if path to test item is not valid
Fail early in case the path to the test item (--test-item) is not valid
or does not exist.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-28 09:17:42 -07:00
Iuliana Prodan 4cf9d67432 west: sign: do not make rimage configuration and platform name mandatory
Now, if the rimage target (meaning rimage configuration and platform name)
is not defined in board.cmake the sign script returns fatal error.
Change this to a warning since there are configurations that are
not using 'west sign' or is used just to glue the headers of the
final image.

Also, update the documentation accordingly.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-08-28 09:17:02 -07:00
Lukasz Mrugala 4d467af7f4 scripts: tests: twister: Black box testing
In addition to the white-box testing and unit tests,
we would like to have some black-box testing for the
console commands of twister.

This serves as a Proof of Concept for future expansion.

Special dummy tests are made for blackbox testing.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
2023-08-28 15:57:06 +02:00
Benjamin Cabé d8d5bdfdfa footprint: ci: ehl_crb board has been renamed.
Following PR #61471, ehl_crb board is now intel_ehl_crb.
Update the footprint test plan accordingly.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-28 10:28:18 +02:00
Fabio Baltieri 5e78660715 ci: assigner: fix the main operation selector check
Fix an "if" that should have been an "elif". This is currently causing
the script to fallback into the "do all unassigned PRs of the day" path
when a PR is specified.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-25 15:31:53 +01:00
Fabio Baltieri b6cbcbaa5b ci: assigner: add a function to assign issues
Add a -I option to process an issue and, if it's not assigned already,
add assignees based on the labels, matching the ones set in the
MAINTAINERS file areas.

Suggested-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-25 10:33:06 +02:00
Fabio Baltieri 9a1f4abd59 scripts: set_assignee: add an option to assign module PRs
Add a -m option to set_assignees to have the script find all unassigned
module PRs for areas that have an assignee and set the assignee on those
PRs.

This should help avoiding forgotten PRs on modules. It's implemented as
a search and meant to run periodically, so we don't have to add a
workflow for this on every individual module.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-25 10:33:06 +02:00
Carles Cufi 05467ad6c6 scripts: kconfig: Add copyright and license to kconfig.py
The file kconfig.py was originally introduced by myself in:
https://github.com/zephyrproject-rtos/zephyr/pull/5569

The file was a modified version of a Kconfiglib one, so it makes sense
to keep the original license (ISC).

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-08-24 22:06:07 +01:00
Benjamin Cabé ef0fd13090 scripts: size_report: fix encoding issue
Force default stdout encoding to utf-8 as otherwise ram_report/rom_report
may fail to render (ex. in CLion IDE built-in terminal).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-08-24 11:53:17 +01:00
Anas Nashif 948ab60eb3 ci: test_plan: also filter on platforms when manifest changes
Add platform filtering when generating tests for manifest modules.
In the clang workflow, we do select to run only on one platform, so this
needs to be applied as well or we end up building unwanted tests using
the wrong toolchain.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-24 06:36:00 -04:00
Sachin D Kulkarni 0399213cd5 scripts: coccinelle: Remove strtok_r symbol from checklist
strtok_r is part of GNU99, but default Zephyr is built with C99, so,
the GNU headers are not pulled in, even if we add "--std=gnu99" it
won't override the C99 standard.

As a workaround for build we redefine the prototype, but this causes a
coding guideline warning, so, for now disable this warning
for strtok_r.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Daniel Leung d90cbc79d9 scripts: gen_syscalls: rename shadow variables
The generated stubs use retval for function return value.
However, this is too generic and is going to collide with
other code. So rename those to be more specific. Note
that the double underscore is intentional to minimize
chance of being shadow variables.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-22 17:30:56 -04:00
Anas Nashif d4169c93fd ci: test_plan: add tags based on manifest change
When manifest changes, add tags based on the changed project names.t

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-22 18:08:30 +02:00
Diego Elio Pettenò d9fe63b188 twister: increase resilience when running outside of git.
While the code already includes some provisions to allow running outside
of a git checkout, attempting that right now causes a failure to generate
the XML report, as the JSON report creates a null `zephyr_version` field.

The reason for that is that the original code doesn't set `self.version`
when the subprocess returns a non-zero status (and also doesn't log.)

Instead of having to set `self.version` for all failure cases, initialize
it to the failure state, and log if it hasn't changed from that.

Signed-off-by: Diego Elio Pettenò <flameeyes@meta.com>
2023-08-22 14:42:51 +02:00
Christopher Friedt 09e4f8fada syscalls: include stdarg.h for va_list type
Include the standard `<stdarg.h>` header to get the
correct definition for `va_list`, etc.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Anas Nashif b28b6a0687 twister: print dut name when testing on hardware
When using the hardware map and testing on device, print out the name of
the dut (from the hardware map) on the script and report it in the json
output as well.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 10:14:34 +02:00
Anas Nashif b48c3cd3e3 twister: do not attempt to parse empty file
Do not attemp to parse empty file, just skip them.

Fixes #60835

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 10:14:34 +02:00
Grant Ramsay 5443703dc9 edtlib: Exclude PCI devices from some inapplicable checks
PCI devices are have some differences to regular nodes:
* node name specifies device/function e.g. "pcie@1,0"
* register address has a different meaning
* zero-sized register is allowed

This improves alignment with Linux DT for PCI devices

Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
2023-08-18 10:13:12 +02:00
Christian Marx 6a20f4b013 scripts: size_report: Fix ram_report and rom_report with anytree 2.9.0
The anytree package has introduced a breaking change in version 2.9.0 by
adding a 'size' property to the NodeMixin class. Since the TreeNode class
in size_report derives from NodeMixin and defines an attribute with the
same name, an AttributeError is raised when generating reports.
With this change, the attributes of the TreeNode class are prefixed with
an underscore to resolve the name collision and to prevent future name
collisions.

Fixes #60213.

Signed-off-by: Christian Marx <c.marx@vega.com>
2023-08-16 18:36:13 -04:00
Alberto Escolar Piedras 732b03ced6 native_sim: Update native simulator to latest and align with it
Align with the latest upstream native simulator
4c595794588f9d7f67fcf0fe05c3db02892a00f9
including:

* 4c59579 Makefile: Add option to build native part
* 910f934 Makefile: NSI_EXTRA_INCLUDES option and lots of commentary
* d9bf489 cmd line parsin: Minor header refactoring
* 02f3555 cmd line cleanup: Run as NSI_TASK instead of calling expl.
* 2c88173 Split exit call in two
* 2b989b4 CPU IF change: nsif_cpu0_cleanup() to return int
* e696228 HW scheduler: Add API to get next event time
* ae0e9e8 native irq ctrl: Miscellaneous fixes and improvements
* 3fd84cd NSI_TASK: Add compile check of valid priority
* 7e09fb8 HW events: Change internal storage

And two minor updates to the native_sim board,
to align with this updated version:
* nsif_cpu0_cleanup(void) now must return an int
* We need to explicitly tell the native simulator build we want
  the native components built

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-16 15:05:12 +02:00
Christophe Dufaza ad48c51651 devicetree: edtlib: prefixes which are not vendors are NOT vendors
In Linux, checkpatch.pl relies on the vendor-prefixes.yaml file
to validate manufacturers in compatible strings.
In addition to the vendors defined in vendor-prefixes.txt,
the YAML file includes expressions for "prefixes which are not vendors":
these expressions do NOT define special manufacturers that may appear
in compatible strings, and are never involved as such in DTS files.
We can rather see them as bulk-definitions of JSON/YAML properties
suitable for the dt-schema tools.

OTHO, in Zephyr, checkpatch.pl relies on the vendor-prefixes.txt file,
which does not include these additional prefixes, but edtlib.EDT adds
them as hard-coded special values.

This is confusing, if not incorrect:

- the fact that edtlib.EDT (and thus its client code in the
zephyr/scripts directory) actually allows these vendors
in compatible strings is buried in the source code
- checkpatch.pl (with vendor-prefixes.txt) in Zephyr behaves neither like
checkpatch.pl (with vendor-prefixes.yaml) in Linux, nor like edtlib.EDT
(with _VENDOR_PREFIX_ALLOWED)
- Zephyr should not treat these "prefixes which are not vendors" as
valid manufacturers in compatible strings to begin with

Signed-off-by: Christophe Dufaza <chris@openmarl.org>
2023-08-16 14:50:26 +02:00
Jack Rosenthal f959309fd0 scripts: zephyr_module: Tolerate symlinks
Currently, this script will blow up when given a symlink for a path (e.g.,
to a kconfig file).

This is annoying, as when wrapping the build system in a hermetic build
system like Bazel, Bazel likes to limit the input file set by creating
symlinks.

Resolve the path, if it is a file once resolved, then it's OK.

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
2023-08-11 12:01:21 +00:00
Joshua Lilly cce530cae4 scripts: build: gen_isr_tables: make bit masks configurable
Some architectures such as RISC-v support more than 255 interrupts
per aggrigator. This diff adds the ability to forgo the aggrigator
pattern and use a configurable number of bits for multilevel
interruts.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-08-10 10:55:41 -04:00
Marcin Niestroj f24dc9eab7 snippets: fix example usage of EXTRA_DTC_OVERLAY_FILE
DTC_OVERLAY_FILE was replaced with EXTRA_DTC_OVERLAY_FILE. Adjust example
usage in schema file.

Fixes: 1561a0705f ("snippets: support for EXTRA_DTC_OVERLAY_FILE and
  EXTRA_CONF_FILE")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-08-10 08:15:01 +00:00
Martí Bolívar 3f8d33ee3b scripts: restore utils/migrate_includes.py
Commit 9b30667c77
("build: drop LEGACY_INCLUDE_PATH support")
removed scripts/utils/migrate_includes.py.

This was premature. This script is still useful to users of older
versions of zephyr that are attempting to migrate to current ones.

For example, users of v2.7 LTS who are migrating to v3.4 should
still be able to run the script to migrate their code bases.

Restore it. Maybe after next LTS we can remove it. It costs
basically nothing to keep it in the tree.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
2023-08-10 08:05:54 +00:00
Chaitanya Tata 66769cf023 scripts: twister: Fix return value for size
If size is given then twister prnits the size information for the ELF
but returns one which if used in automation fails the command.

Return zero as the command is successful. Also, fix the unit test case.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-08-09 10:29:20 -04:00
Fabian Blatz 29d07d6020 scripts: ci: check_compliance: Replace dead Kconfig doc link
Update the link to the Kconfig documentation page.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
2023-08-09 12:47:12 +00:00