Commit graph

154 commits

Author SHA1 Message Date
Mahesh Mahadevan 41dda6938e tests: devicetree: device: Add mimxrt595_evk_cm33 exclusion
Adds mimxrt595_evk_cm33 target to the exclusion list for tests
as this board enabled i2c by default for regulator usage which
conflicts with the test.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-12-05 11:03:14 +01:00
Anas Nashif ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Pieter De Gendt 5710f609c9 tests: devicetree: add tests for DT_GPARENT/DT_INST_GPARENT
Add some coverage for the DT_GPARENT/DT_INST_GPARENT macros.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-11-17 10:18:11 -06:00
Jamie McCrae 6798f447d5 tests: devicetree: device: Add bl5340 and bt610 exclusions
Adds bt610 and bl5340_dvk_cpuapp* targets to exclusion list for tests
as these boards enabled i2c by default for GPIO usage which conflicts
with the test.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-10-19 10:46:53 +02:00
Maureen Helm 03c8deb599 devicetree: Add model name helpers based on compat
Follow up to e1e16640b5 adding model name
helpers to access generated macros based on a compatible's matching
entries in vendor prefixes.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-07 11:48:02 -07:00
Gerard Marull-Paretas b8f9d8add7 tests: devicetree: cover DT(_INST)_FOREACH_PROP_ELEM_SEP(_VARGS)
Add coverage for DT(_INST)_FOREACH_PROP_ELEM_SEP(_VARGS).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-03 10:11:18 +02:00
Daniel Leung db9d83fbb8 tests: devicetree: add bits to test multi-bus nodes
This adds a few bits to the devicetree API tests for multi-bus
nodes where a bus can support multiple protocols. This uses
I3C as basis as I3C controller can support both I2C and I3C on
the same bus, while I2C controller cannot support both. So
this needs to make sure the correct bus macros are generated
if appropriate (and not generated if not needed).

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Michał Barnaś 1ea41b34c6 ztest: improve some tests
This commit changes some tests from using zassert_equal to validate
the pointers to using the zassert_is_null and zassert_not_null.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Michał Barnaś dae8efa692 ztest: remove the obsolete NULL appended to zassert macros
This commit removes the usage of NULL parameter as message in
zassert_* macros after making it optional

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2022-09-09 07:05:38 -04:00
Gerard Marull-Paretas 3732bbfa12 tests: devicetree: add tests for DT_CHILD/DT_INST_CHILD
Add some coverage for the DT_CHILD/DT_INST_CHILD macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-06 08:45:25 -07:00
Maureen Helm e1e16640b5 devicetree: Add vendor name helpers based on vendor prefixes
Adds vendor name helpers to access generated macros based on matching
entries in the vendor prefixes file.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-09-01 14:53:55 -07:00
Gerard Marull-Paretas 18454e46f2 devicetree: add DT_INST_FOREACH_CHILD_STATUS_OKAY* macros
Add the instance version of the DT_FOREACH_CHILD_STATUS_OKAY* family of
macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Gerard Marull-Paretas fff9ecbc7f devicetree: add DT_(INST_)FOREACH_CHILD(_STATUS_OKAY)_SEP(_VARGS)
It is frequent to see in Devicetree code constructs like:

```c
 #define NAME_AND_COMMA(node_id) DT_NODE_FULL_NAME(node_id),

const char *child_names[] = {
	DT_FOREACH_CHILD(DT_NODELABEL(n), NAME_AND_COMMA)
};
```

That is, an auxiliary macro to append a separator character in
DT_FOREACH* macros. Non-DT API, e.g. FOR_EACH(), takes a separator
argument to avoid such intermediate macros.

This patch adds DT_FOREACH_CHILD_SEP (and instance/status okay/vargs
versions of it). They all take an extra argument: a separator. With this
change, the example above can be simplified to:

```c
const char *child_labels[] = {
	DT_FOREACH_CHILD(DT_NODELABEL(n), DT_NODE_FULL_NAME, (,))
};
```

Notes:
- Other DT_FOREACH* macros could/should be extended as well

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-30 16:19:57 +02:00
Kumar Gala f3ff449524 tests: devicetree: device: Rename gpio@0 to avoid name conflict
There are some platforms like the lpcxpresso54114 that utilize gpio@0
so rename gpio@0 to gpio@ffff as this is a highly unlikely to conflict
with any real device.

Fixes #49439

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-26 12:51:45 +02:00
Radosław Koppel 7614110a20 dts: Add _STRING_TOKEN and _STRING_UPPER_TOKEN to string-array
This commit adds string token versions of the values also
in items inside string-array.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Co-authored-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Co-authored-by: Kumar Gala <galak@kernel.org>
2022-08-22 13:58:30 -05:00
Radosław Koppel d493751fa1 test: devicetree: api: Limit test to native_posix and simulation
This commit limits test targets for the test to run only on native
or simulated machines.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
2022-08-22 13:58:30 -05:00
Kumar Gala c4ee3f3733 devicetree: deprecate DT_LABEL variants
Deprecate DT_LABEL and DT_INST_LABEL as we have phased out
general 'label' usage and there isn't a need to keep a specific
set of macros for 'label'.  DT_PROP(node, label) works fine for
the small handful of cases that need it now.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-19 06:49:50 -05:00
Kumar Gala 729f1ec301 tests: devicetree: device: Exclude test on bbc_microbit
The bbc_microbit boards end up enabling CONFIG_SENSOR because of
CLOCK_CONTROL_NRF_USES_TEMP_SENSOR.  This ends up enabling the I2C
bus which causes CONFIG_I2C_TEST=y.  We end up with a build conflict
betwee the i2c_test.c driver and the test case code.  So the easiest
solution is to just exclude the platforms from this test.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-19 12:08:33 +02:00
Kumar Gala 3f124ba14d tests: devicetree: device: utilize DEVICE_DT_NAME
Convert DT_LABEL to DEVICE_DT_NAME.  This lets us drop label properties
in the app.overlay.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-19 12:08:33 +02:00
Martí Bolívar 2520747f6b devicetree.h: DT_FOREACH_NODE, DT_FOREACH_STATUS_OKAY_NODE
Add two new utility macros for iterating over the entire tree, along
with tests.

I have a use case for DT_FOREACH_STATUS_OKAY_NODE() right now, but I
think it makes sense to define both of them right away for
completeness.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Jordan Yates 13f2494f4c device: symetric injected dependencies
If a device manually specifies that it depends on a second DT device,
add the first device to the second devices list of supported devices.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Jordan Yates 30795a48e6 tests: devicetree: devices: test no label
Ensure that the build system works correctly for devices without a
nodelabel.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-30 08:29:29 -05:00
Kumar Gala e8f947b975 tests: devicetree: api: Remove unnecessary label properties
Remove unused "label" properties from devicetree.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-25 12:19:01 -07:00
li biao 3e87adc8bc tests: lib: devicetree: move api_ext to new ztest API
Move test lib/devicetree/api_ext to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-19 13:00:37 -07:00
li biao dea133ac26 tests: lib: devicetree: move api to new ztest API
Move test lib/devicetree/api to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-19 13:00:37 -07:00
li biao a5129e62b3 tests: lib: devicetree: move devices to new ztest API
Move test lib/devicetree/devices to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-19 13:00:37 -07:00
Kumar Gala 357c70cfdc tests: devicetree: api: reduce DT_LABEL usage
A lot of places that DT_LABEL is used we can replace with DT_SAME_NODE
as we are just checking that the node we got from the macro is the
same as what we expect.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 09:09:13 -07:00
Kumar Gala 7bc6bc8681 dts: bindings: test: device labels are now optional
All in tree device drivers use some form of DEVICE_DT_GET
so we no longer need to require label properties.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 12:31:53 +00:00
Kumar Gala 46f4513573 devicetree: deprecate DT_BUS_LABEL variants
Deprecate DT_BUS_LABEL and DT_INST_BUS_LABEL as we phase out
'label' property usage in favor of DT_BUS and variants.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-15 11:05:12 -07:00
Kumar Gala 1fc243c73d devicetree: gpio: deprecate DT_GPIO_LABEL variants
Deprecate DT_GPIO_LABEL, DT_INST_GPIO_LABEL, DT_GPIO_LABEL_BY_IDX,
and DT_INST_GPIO_LABEL_BY_IDX as we phase out 'label' property usage
in favor of DT_GPIO_CTLR and variants.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-15 09:59:59 +02:00
Kumar Gala 78f91a1be2 devicetree: spi: deprecate DT_SPI_DEV_CS_GPIOS_LABEL variants
Deprecate DT_SPI_DEV_CS_GPIOS_LABEL and DT_INST_SPI_DEV_CS_GPIOS_LABEL
as we phase out 'label' property usage in favor of
DT_SPI_DEV_CS_GPIOS_CTLR and variants.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-15 09:59:59 +02:00
Carlo Caione d729919925 tests: memory_region: Move to new ztest API
Migrate the test to the new ztest API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-07-08 20:13:04 +00:00
Jordan Yates 245ed89590 test: lib: devices: test DEVICE_INIT_* macros
Add tests for the new `DEVICE_INIT_*` macros.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-07-06 10:44:50 +02:00
Reto Schneider 7a6c5710ff cmake: Update cmake_minimum_required to 3.20.0
As Zephyr currently requires CMake version 3.20.0, update all
occurrences of cmake_minimum_required.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2022-07-04 10:18:45 +02:00
Jordan Yates 0177a3ea23 tests: devices: test injected dependencies
Test that injected dependencies compile and appropriate API functions
work correctly.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-05 14:26:39 +02:00
Fabio Baltieri 67a0f95aed dts: fix a bunch of odd partition values dts entries
Fix various board fixed-partition definitions where the devicetree cell
has been defined oddly, such as 9 nibbles (which makes no sense since
the cells are 32 bit) or 7 nibbles where all the others are 8.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-25 14:21:04 +02:00
Jordan Yates 1772dc24a3 tests: devicetree: api: new STRING_TOKEN macros
Add tests for the new `STRING_TOKEN` macros.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-05-13 14:17:08 +02:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Carlo Caione cd51657ed1 devicetree_regions: Fix fallback on token
Fix the wrong fallback on token and add a new test to catch this kind of
errors early.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-04-04 14:02:25 -07:00
Carlo Caione 18914ccdd4 devicetree_regions: Remove path fallback and sanitize name
This patch is doing two things:

- it is removing the fallback on the path. This is not possible anymore
  since the DT binding file is now actually requiring the
  'zephyr,memory-region' property to be present from which the region
  name is obtained.

- it is sanitizing the name when CONFIG_CMAKE_LINKER_GENERATOR is used
  or not.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-31 10:29:31 +02:00
Katarzyna Giadla 681e3a16c7 tests: Change duplicated names of the test cases
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-03-30 17:42:01 -04:00
Carlo Caione b9e61d199b mbox: Move MBOX_DT_* macros
Move MBOX_DT_* macros to include/devicetree/mbox.h and use the correct
DT_MBOX_* prefix.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-03-25 16:02:09 -07:00
Martí Bolívar 869ae2b5ac devicetree.h: add DT_NODE_CHILD_IDX
It can be useful to know what a node's index is in its parent's list
of children. This information is now available to C via
gen_defines.py, but no user-facing macros are available to access it.

Add a macro which exposes this information to users via devicetree.h.

Some APIs want to build on devicetree.h by creating some derived
structure for each of a node's children. It can therefore be
convenient to use each child's index in the list of children as an
identifier for the child.

Some concrete and common examples are "gpio-keys" and "gpio-leds",
which allow you to define arbitrary numbers of keys and LEDs as child
nodes of nodes with those compatibles. Derived APIs can use a key or
LED node's index in its list of parents as a way to identify which of
several structures is relevant to a particular controlled key or LED.

These are just examples, though -- the feature added here makes no
assumptions about where it's being used.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-03-24 10:48:40 +01:00
Emil Gydesen ae55dae454 sys: util: Change return type of ARRAY_SIZE to size_t
The ARRAY_SIZE macro uses sizeof and thus the return
type should be an unsigned value. size_t is typically
the type used for sizeof and fits well for the
ARRAY_SIZE macro as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-03-23 14:09:23 +01:00
Andrei-Edward Popa a49d88ce05 tests: lib: devicetree: api: added test for reset public API
added test reset for reset public API macros

Signed-off-by: Andrei-Edward Popa <andrei.popa105@yahoo.com>
2022-03-23 12:51:39 +01:00
Henrik Brix Andersen 5e8399f84b devicetree: add devicetree/can.h
This contains accessor macros for getting the maximum bitrate supported
by a CAN controller/transceiver combination.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-15 14:32:29 -05:00
Bernardo Perez Priego 9964414655 include/devicetree.h: Add DT_STRING_TOKEN_OR macro
This macro expands to DT_STRING_TOKEN if property exists, otherwise
falls back to default value.
Helpful when a non-required enum binding doesn't mention a default
value, but a default value makes sense to be set in the code.

Including DT_INST_STRING_TOKEN_OR and test code.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-03-10 19:42:59 -08:00
Krzysztof Chruscinski 47ae656cc1 all: Deprecate UTIL_LISTIFY and replace with LISTIFY
UTIL_LISTIFY is deprecated. Replacing it with LISTIFY.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-08 11:03:30 +01:00
Erwan Gouriou 935e6752f0 tests/lib/devicetree: api: Add tests for new DT_{INST_}CLOCKS macros
Add matching tests for newly added DT_{INST_}CLOCKS macros.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-03-07 10:58:47 +01:00