Colorama needs to be initialized, and for colors to display correctly on
Windows one needs to use the `USES_TERMINAL` option in CMake.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Certain symbols do not contain a valid path, instead showing
`<built-in>` in the filename attribute. This leads to the resolve() call
failing on Windows, since the `<>` characters are not allowed in
filenames there. Fix this by catching the exception and skipping the
call in that case.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2 scripts are provided.
- find_functions.cocci (name probably sucks...)
- find_dev_usage.cocci (ditto...)
find_functions.cocci can patch files where device instance are not
const.
Then it is used to generate the function database:
./scripts/coccicheck --mode=report --jobs=1 \
--cocci=scripts/coccinelle/find_functions.cocci \
--sp-flag="--include-headers" ./
Then, find_dev_usage.cocci will check if the const qualifier is, or
might be lost in a function call.
For instance:
./scripts/coccicheck --mode=report --jobs=1 \
--cocci=scripts/coccinelle/find_dev_usage.cocci \
--sp-flag="--include-headers" drivers/i2c
Which will output a WARNING on non-zephyr functions calls with a device:
./drivers/i2c/i2c_cc13xx_cc26xx.c:393:5-8: WARNING: in i2c_cc13xx_cc26xx_pm_control calling cb param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_mcux_lpi2c.c:205:40-43: WARNING: in mcux_lpi2c_init calling LPI2C_MasterTransferCreateHandle param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_nrfx_twi.c:258:5-8: WARNING: in twi_nrfx_pm_control calling cb param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_nrfx_twi.c:202:22-25: WARNING: in init_twi calling nrfx_twi_init param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_mcux.c:187:38-41: WARNING: in i2c_mcux_init calling I2C_MasterTransferCreateHandle param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_mcux_flexcomm.c:184:43-46: WARNING: in mcux_flexcomm_init calling I2C_MasterTransferCreateHandle param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_nrfx_twim.c:232:5-8: WARNING: in twim_nrfx_pm_control calling cb param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_nrfx_twim.c:174:8-11: WARNING: in init_twim calling nrfx_twim_init param with dev, check if const qualifier is not lost
./drivers/i2c/i2c_rv32m1_lpi2c.c:246:6-9: WARNING: in rv32m1_lpi2c_init calling LPI2C_MasterTransferCreateHandle param with dev, check if const qualifier is not lost
Or:
./scripts/coccicheck --mode=report --jobs=1 \
--cocci=scripts/coccinelle/find_dev_usage.cocci \
--sp-flag="--include-headers" drivers/ieee802154
Which will output an ERROR on using a zephyr function that looses the
const qualifier:
drivers/ieee802154/ieee802154_rf2xx.c:778:3-6: ERROR: in rf2xx_init calling k_thread_create param with dev, loosing const qualifier, please wrap
drivers/ieee802154/ieee802154_nrf5.c:477:19-22: ERROR: in nrf5_init calling k_thread_create param with dev, loosing const qualifier, please wrap
drivers/ieee802154/ieee802154_cc1200.c:819:3-6: ERROR: in cc1200_init calling k_thread_create param with dev, loosing const qualifier, please wrap
drivers/ieee802154/ieee802154_mcr20a.c:1443:3-6: ERROR: in mcr20a_init calling k_thread_create param with dev, loosing const qualifier, please wrap
drivers/ieee802154/ieee802154_cc2520.c:1116:3-6: ERROR: in cc2520_init calling k_thread_create param with dev, loosing const qualifier, please wrap
drivers/ieee802154/ieee802154_cc13xx_cc26xx.c:439:32-35: ERROR: in ieee802154_cc13xx_cc26xx_data_init calling k_thread_create param with dev, loosing const qualifier, please wrap
ISSUE:
- Is it possible to run a set of rules first on all the code, and then
another set, both sets being in the same .cocci file?
Would be nice to have all at once.
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The k_object API associates mutable state structures with known kernel
objects to support userspace. The kernel objects themselves are not
modified by the API, and in some cases (e.g. device structures) may be
const-qualified. Update the API so that pointers to these const
kernel objects can be passed without casting away the const qualifier.
Fixes#27399
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fix the case where we have no ztest test_* testcases and reports were
missed. This now makes sure we do not report the parent testcase when
there are individual test_* results.
Fixes#27765
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
add argument --pre-script to specify a pre script. This will be
executed before device handler open serial port and invoke runner.
Currently, pre_script can only get from hardware.map file. just like:
./scripts/sanitycheck --hardware-map xxx.map
and set pre_script in xxx.map file.
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
In some cases it might be a good idea to reset the board for real to
make sure it is completely recovered from some failed state (simple
re-loading of the application binary or even Elf file contents doesn't
affect most of internal CPU states so doesn't help in recovery,
see https://github.com/zephyrproject-rtos/zephyr/issues/25022 &
https://github.com/zephyrproject-rtos/zephyr/issues/26665).
And so we may want to utilize some external utility which triggers the
hard reset (in case of ARC boards it is
https://github.com/foss-for-synopsys-dwc-arc-processors/rff-ftdi-reset).
So we need to have a way to execute an external command before each and
every test.
Now given we already have quite some call-backs we try to use them
before re-inventing the wheel. And pre_script seem to be a good option
with just on minor note - it is called after serial port gets open.
And while in some cases it might be OK if serial port on the board is
not affected by the board's reset, if it is affected we'll be losing
connection on reset (and that's the case with ARC boards BTW as the
FTDI USB-to-Serial IC is also wired to the reset signal on most of
the boards). That said we just move invocation of pre_script before
opening the serial port and everything should be good now.
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
By default show reports based on last release. Fix a few other issues
where we had 0 values and were dividing by zero.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit improves Zephyr modules support in CMake.
All Zephyr modules will now have a corresponding
`ZEPHYR_${module_name}_MODULE_DIR` set, regardless of whether they
define a cmake folder in module.yml.
This results in:
`ZEPHYR_${module_name}_MODULE_DIR` defined for all modules and refers to
the root of the modle.
`ZEPHYR_${module_name}_CMAKE_DIR` defined for modules that specifies
cmake in module.yml, or is having both a CMakeLists.txt and Kconfig file
in the zephyr folder.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit has no functional changes but is simply a cleanup so that
flake8 will pass without warnings.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This will only build/run on emulation platforms.
The decision is made based on the value of the 'simulation' key in the
platform yaml file.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This is needed for sanitycheck hardware maps which take the serial
number directly from USB metadata.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
Adds some code to allow QEMU to crash without failing the test.
This is required for testing coredump code as it will certainly
cause QEMU to crash.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
There is a potential that QEMUHandler.handle() returns before
the testing harness finishes processing all the output from QEMU.
Simply wait for the harness thread to finish before returning.
Also, fix the return code in the debug message as it should be
the return code from Popen().
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds the necessary bits in arch code, and Python scripts
to enable coredump support for ARM Cortex-M.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This adds a very primitive coredump mechanism under subsys/debug
where during fatal error, register and memory content can be
dumped to coredump backend. One such backend utilizing log
module for output is included. Once the coredump log is converted
to a binary file, it can be used with the ELF output file as
inputs to an overly simplified implementation of a GDB server.
This GDB server can be attached via the target remote command of
GDB and will be serving register and memory content. This allows
using GDB to examine stack and memory where the fatal error
occurred.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Commit 8d7bb8ffd8 refactored
device structures which changed some of the linker sections:
"devconfig" was removed, and "devices" was added. However,
the list in sanitycheck's size calculator was not updated,
which results in sanitycheck complaining about unrecognized
sections when doing footprint.
Also, a few sections have been renamed (with added suffix
"_area") due to introduction of Z_ITERABLE_SECTION_RAM/ROM
macros. There are also some missing section names.
Fixes the issue by adding the missing sections names, and
updating existing ones.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When MCUBoot is built using the swap-move strategy, the secondary slot
can be one sector smaller than the primary slot, because the primary
slot's last "useful" image sector must be "reserved" for the move
operation; this impacts the generation of padded images, so when
signing an image, the proper size to use is the secondary slot's,
unless a secondary image is not defined which is the case when using
single image DFU.
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
The extra empty line broke the "ninja hardenconfig" on my machine with
Python 3.7.5, it complains:
"
... ...
File "/home/zephyrproject/zephyr/scripts/kconfig/hardenconfig.py",
line 46, in compare_with_hardened_conf
name = row[0]
IndexError: list index out of range
FAILED: CMakeFiles/hardenconfig
"
The csv.reader reads this empty line and gets an empty list which will
not be successfully "de-referenced". Removing it to improve the
out-of-box experience when pepople try out the hardening options.
Signed-off-by: Wenbo Yang <wenbo.yangcn@gmail.com>
This squashes and applies the Linux diffs to scripts/checkpatch.pl
between Linux commit 16fbf79b0f83bc75 ("Linux 5.6-rc7") and
9123e3a74ec7b93 ("Linux 5.9-rc1") except for commits identified below.
The last 1000 commits to Zephyr master were compared for checkpatch
output differences between the previous Zephyr version and this
version. One new diagnostic about function declarations with an empty
parameter-list was introduced (FUNCTION_WITHOUT_ARGS). The text of an
existing diagnostic was changed (DT_SPLIT_BINDING_PATCH). The text of
LONG_LINE diagnostics was enhanced to provide the actual line length.
Linux commit dfa05c28ca7ffc0a ("checkpatch: remove email address
comment from email address comparisons") was removed because
differences in the scripts resulted in false signed-off-by check
diagnostics when a full name included characters not in Basic Latin,
due to changes in how the author name was extracted. Earlier upstream
changes not integrated into Zephyr may be required.
Linux commit b95692f8b3000166 ("checkpatch: prefer fallthrough; over
fallthrough comments") was removed because Zephyr doesn't support the
upstream pseudo keyword.
Linux commit bdc48fa11e46f867 ("checkpatch/coding-style: deprecate
80-column warning") was edited to not actually change the 80-column
maximum line limit as this change has not been mooted for Zephyr.
Linux commit ced69da1db0b57bb ("checkpatch: fix CONST_STRUCT when
const_structs.checkpatch is missing") was edited to the CONST_STRUCT
file as that's not supported in Zephyr.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Add support for the J-Link Commander "-NoGui 1" command line parameter
in the West J-Link runner.
This command line parameter suppresses GUI dialogs (except for license
dialogs) in J-Link Commander starting from v6.80.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
If a runner supports the --erase option, make it so that the user can
add --no-erase to the command line to explicitly disable it.
Add a diagnostic at info() level whenever this option is requested.
The intent of this commit is to make it more obvious when a mass erase
was requested, especially in situations (like MCUboot with
CONFIG_MCUBOOT_TRY_MASS_ERASE=y) where this option may be turned on by
default.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fixes: #27375
This is a cleanup of the Zephyr CMake package export.
The code has been simplified so that the export now happens through a
CMake script. This avoids several generated CMake build files compared
to previous export mode, and thus removes the need for a CMake pristine
script.
A benefit of this cleanup is that it also fixes#27375.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This patch should improve couting and reporting of the number
of passed/skipped tests.
Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Avoid use of the cached_runner_config() helper, which we have a TODO
item to get rid of. Adjust the output and do some other minor
improvements.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Rolling yet another parser turns out to be the best way to let west
extensions respond to Kconfig values. See source code comments in the
patch for details.
The sanitylib library has some similar functionality but it isn't
exactly the same, and it gets strings wrong. For example, that parser
can't handle this option:
CONFIG_FOO="he said \"no\" to me"
This one can, and it has a couple of other features we'll find useful
for west extensions eventually besides.
(Not to mention that sanitylib also rolled its own CMake cache parser,
which also exists in west_commands.)
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Use anytree module to display tree and to allow easy exporting into
json.
Add option to export results into a json file.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
In DWARF 4, e.g. ARC Metaware toolchain, DW_AT_count is
used not DW_AT_upper_bound. We should consider this corner
case.
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
When running with --test-only we get:
Traceback (most recent call last):
File "./scripts/sanitycheck", line 1168, in <module>
main()
File "./scripts/sanitycheck", line 1160, in main
options.only_failed)
File "scripts/sanity_chk/sanitylib.py", line 2543, in save_reports
self.xunit_report(filename + ".xml", full_report=False, append=only_failed)
File "scripts/sanity_chk/sanitylib.py", line 3220, in xunit_report
return fails, passes, errors, skips
UnboundLocalError: local variable 'fails' referenced before assignment
This is due to the fact that selected_platforms was not set.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
In the junit output the attribute containing the number of skipped tests
must be named "skipped" instead of "skip".
See e.g. https://github.com/junit-team/junit5/blob/main/platform-tests/
src/test/resources/jenkins-junit.xsd#L95
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
The extra empty line broke the "ninja hardenconfig" on my machine with
Python 3.7.5, it complains:
"
... ...
File "/home/zephyrproject/zephyr/scripts/kconfig/hardenconfig.py",
line 46, in compare_with_hardened_conf
name = row[0]
IndexError: list index out of range
FAILED: CMakeFiles/hardenconfig
"
The csv.reader reads this empty line and gets an empty list which will
not be successfully "de-referenced". Adding extra check to skip the
empty lines.
Signed-off-by: Wenbo Yang <wenbo.yangcn@gmail.com>
Running check_compliance on a PR before submitting it can avert
embarrassing mistakes. Ensure the packages needed to do so are
installed along with all the others.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Currently '--coverage-tool gcovr' results in using lcov. Fix that to use
gcovr, as requested by user.
Fixes: f6462a3a8c ("sanitycheck: get rid of global VERBOSE")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Sanitycheck discards test instances if a set of given coditions
is not fulfilled. This leads to empty test results for these
instances. This can introduce ambiguity with results that are
missing due to some bugs in the framework. This commit fills
the results for skipped tests with 'skipped' states and provides
the reason for filtering them out in the msg field. The commit
also fixes the way sanitycheck counts and reports tests/test cases
Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
Fixes: #25215
This commit introduces the possibility of defining ROOTs in a Zephyr
module and have it automatically appended to list of other ROOTs.
Supported with this commit:
- BOARD_ROOT
- SOC_ROOT
- DTS_ROOT
- ARCH_ROOT
In order to support this in Zephyr module files, the detection of west
has been moved to dedicated west.cmake file and included immediately
after python.cmake.
Also the inclusion of zephyr_modules.cmake has moved before first use
of BOARD_ROOT.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit introduces support for multiple SOC_ROOT.
This means that additional SOC_ROOTs specified using -DSOC_ROOT as
argument to CMake will be forming a list together with ${ZEPHYR_BASE}.
This allows for greater flexibility, as developers can now specify
multiple out-of-tree SoCs and not worry about the SoC used for the
board they compile for.
Also it avoid code, such as:
if(BOARD STREQUAL my_board_using_out_of_tree_soc)
set(SOC_ROOT some/out/of/tree/soc/path)
endif()
in application CMakeLists.txt.
Finally, allowing multiple SOC_ROOTs prepares for specifying SOC_ROOTs
in Zephyr modules.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
When passing a using --hardware-map, sanitycheck would ignore extra
args passed via --west-flash, such as --west-flash="--erase".
This is because the command with the extra args was overwritten by the
command with the runner info from the hardware map.
This patch merges those code paths so they are aware of each other and
of --west-runner.
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
Before sanitycehck was removing all `test_` chars in test cases'
names. This test has to be modify to work with the improved behavior
Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>