Commit graph

894 commits

Author SHA1 Message Date
Chris Friedt 2d4619b13c tests: lib: hash_function: tests for sys_hash32
Add a test for `sys_hash32()`. The expectation is that hash
functions should be approximately uniform over a given field.

We can use the Kolmogorov Smirnov test to verify that our
hash function is approximately uniform over a given field.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-22 19:14:05 +01:00
Andy Sinclair 5f63fff9c2 sys: linear_range: fix return value when window is outside range
linear_range_get_win_index does not behave correctly when the
window of values is above the linear range.  It reports
-ERANGE (partial intersection) instead of -EINVAL.

Extra conditions added for edge cases and tests cases updated.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-02-20 10:43:26 +01:00
Radosław Koppel 14a1b2ffec dts: Add _STRING_UNQUOTED string and string-array
This commit adds access to the string values without a quotes.

Signed-off-by: Radosław Koppel <r.koppel@k-el.com>
Co-authored-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2023-02-20 09:49:00 +01:00
Chris Friedt 2b8ea7d700 tests: lib: thrift: add tests for the thrift module
These tests include:
* ThriftTest - an upstream exercies for all Thrift facilities

This code was merged from the following repository
at the commit specified below, with minor formatting
and coding-style modifications.

https://github.com/zephyrproject-rtos/gsoc-2022-thrift
e12e014d295918cc5ba0b4c507d1bf595a2f539a

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-09 20:30:21 +09:00
Anas Nashif 0bc4fd4cb9 tests: fix various test identifiers
lib -> libraries to be consistent with everything else.
And fix identifier for a few stray tests that were wrongly
labeled/tagged.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-06 10:06:10 +01:00
Henrik Brix Andersen 0174e0b6c1 tests: lib: devicetree: api: add tests for DT_GPIO_HOG_* macros
Add tests for the DT_GPIO_HOG_* macros.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-27 14:38:52 -08:00
Andrei Emeltchenko dcea17068d tests: mem_blocks: Remove suspicious break statement
Fixes dead code warnings form static tools.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-27 18:10:52 +09:00
Björn Stenberg 0321ac8dbf json: Increase max number of descriptor elements from 30 to 62
The limiting factor is the output bitmask that says which elements have
been filled in by the parser. This patch changes the bitmask type from int
to int64_t.

Signed-off-by: Björn Stenberg <bjorn@haxx.se>
2023-01-26 09:51:54 +00:00
Keith Packard 35e017a9ee subsys/cpp: Also run C++ tests with picolibc when possible
When the toolchain has picolibc support, run
samples/subsys/cpp/cpp_synchronization and tests/subsys/cpp/libcxx tests
using it.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-01-20 09:03:25 +01:00
Andrei Emeltchenko 8f4d8c5cce tests: spsc_pbuf: Check return code
Make check_buffer() call useful.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-17 21:50:16 +00:00
Gerard Marull-Paretas e086738b88 sys: linear_range: allow out-of-range values/windows
The existing linear_range API did not allow values or windows outside of
the linear range (returned -EINVAL). With this change values are allowed
outside of the range, being adjusted to the edge values (min/max)
instead. In the case of windows, it is allowed to have partial
intersection. In both cases, the API assigns a valid index (nearest) and
returns -ERANGE. This change is useful because the main client of the
linear range API, regulators, needs such behavior. For example, If an
application specifies a voltage range from 1.0V to 1.5V and the
regulator supports from 1.2V to 2.7V, the regulator can configure a
voltage that satisfies the condition: 1.2V.  With the current API, the
input would be refused because 1.0V lies outside of the 1.2V-2.7V range.

Also, for constant ranges, the minimum index is returned.

Tests have been updated/extended accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-01-16 16:52:35 +01:00
Stephanos Ioannidis cf211aa7af treewide: Update deprecated CONFIG_LIB_CPLUSPLUS usages
This commit updates all deprecated `CONFIG_LIB_CPLUSPLUS` usages to:

* check if the Zephyr minimal C++ library is enabled using
  `CONFIG_MINIMAL_LIBCPP` instead of relying on the
  `CONFIG_LIB_CPLUSPLUS`-based inference.

* select `CONFIG_REQUIRES_FULL_LIBCPP` when there exists a component-
  level C++ standard library dependency. This allows a component to
  declare C++ standard library dependency without designating a
  specific libray implementation.

* select the correct type of C++ standard library implementation to use
  through one of the `CONFIG_LIBCPP_IMPLEMENTATION` choices.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 404e7a9bf7 treewide: Use CONFIG_CPP_EXCEPTIONS instead of CONFIG_EXCEPTIONS
This commit updates all in-tree code to use `CONFIG_CPP_EXCEPTIONS`
instead of `CONFIG_EXCEPTIONS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 4a64bfe351 treewide: Use CONFIG_CPP instead of CONFIG_CPLUSPLUS
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Stephanos Ioannidis 5c58ebe55b tests: lib: cpp: Relocate tests/subsys/cpp to tests/lib/cpp
This commit moves the C++ library tests under `tests/subsys/cpp` to
`tests/lib/cpp` now that the C++ library has been relocated to
`lib/cpp`.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2023-01-13 17:42:55 -05:00
Andrei Emeltchenko e8f0e66bc4 tests: libc: Fix "unused" type of warnings
Follow example several lines below and fix warnings from static tools.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-05 08:00:09 -05:00
Fabio Baltieri f5b4acac57 yamllint: indentation: fix files in tests/
Fix the YAML files indentation for files in tests/.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 14:23:53 +01:00
Fabio Baltieri 620bd5d817 samples, tests: fix key-duplicates in sample.yaml files
Fix few duplicate keys warnings in sample.yaml and testcase.yaml files,
this is going to enable some tests that were otherwise being
unintentionally ignored.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 10:34:18 +01:00
Fabio Baltieri 7db1d17ee3 yamllint: fix all yamllint line-length errors
Fix all line-length errors detected by yamllint:

yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
  grep '(line-length)'

Using a limit is set to 100 columns, not touching the commandlines in
GitHub workflows (at least for now).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-04 01:16:45 +09:00
Krzysztof Chruscinski 537062b110 tests: lib: mpsc_pbuf: Add qemu_x86_64
Add target which supports SMP.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Krzysztof Chruscinski f0485c7053 tests: lib: mpsc_pbuf: Add stress test
Added stress test which validates proper behavior of mpsc_pbuf
when there are 2 producing contexts and dedicated consumer
context. Various configuration are tested with consumer having
the lowest, medium and the higher priority.

Test produces random size packets at random intervals. It validates
that each produced packet is consumed or dropped.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Krzysztof Chruscinski 300f9b95e5 tests: lib: mpsc_pbuf: Add new test case
Added test case for putting words when packet is claimed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Krzysztof Chruscinski d6442ac9e1 tests: lib: mpsc_pbuf: Adapt test after changes in the module
Adapt test to the new method of buffer full detection. New
method increased buffer capacity.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Krzysztof Chruscinski b80becbb4d tests: lib: mpsc_pbuf: Add native_posix to allowed list
Add plaftorm used for integration to platform_allowed list.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-12-29 10:33:29 +01:00
Gerard Marull-Paretas adbd0603b6 lib: linear_range: fix count for ranges with step 0
Ranges with step 0, that is, multiple indices representing the same
value, need to report the count exclusively based on indices. This makes
it possible to later retrieve all values, e.g. in a group.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-27 13:12:55 +01:00
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
Yuval Peress 0433965982 dsp: move cmsis_dsp basicmath tests
Move the tests to tests/subsys/dsp/ as they'll be a part of the Zephyr
dsp subsystem.

Signed-off-by: Yuval Peress <peress@google.com>
2022-12-02 20:15:55 +01:00
Gerard Marull-Paretas 55da0217da sys: linear_range: fix index calculation when spanning across groups
When dealing with groups, the specified window in
linear_range_group_get_win_index can span across multiple groups. In the
current implementation, if maximum value was not in the same sub-window
as the minimum value the function would return -EINVAL. This patch fixes
the problem and updates test cases to cover such scenario.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-02 11:29:35 +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
Anas Nashif 808266a493 tests: use ignore_fault field instead of tags
Use dedicated field in the yaml file instead of mixing this testing
feature with tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-25 06:38:05 -05:00
Gerard Marull-Paretas 9f509f5b11 tests: lib: linear_range: add coverage
Add coverage for the linear_range API.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-24 10:16:03 +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
Francois Ramu e7a071f43c tests: lib: cmis_dsp transform requires more than 128KB of RAM
Increase the min ram configuration when running the
libraries.cmsis_dsp.transform.cf64 testcase of the
tests/lib/cmsis_dsp/transform/
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/52284

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-17 11:17:53 +01:00
Stephanos Ioannidis 3bdbc3f8a4 tests: cmsis_dsp: transform: Remove MPS2 AN521 from intg. platforms
This commit removes the `mps2_an521_remote` board from the integration
platform list of the CMSIS-DSP transform tests because this board no
longer has a sufficient code memory (FLASH) to fit these tests after
the resizing done in the PR #52052 for TF-M compatibility.

Consider adding `mps2_an386` as an integration platform for these tests
once the support for it is added to Zephyr (refer to the issue #45319).

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-11-09 23:20:06 +09:00
Keith Packard f35f44147f tests/sprintf: Enable picolibc float I/O
When built with picolibc, this test requires float I/O support

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Keith Packard e7ec39434b tests/cbprintf_package: Use minimal libc for long double tests
These tests fail because picolibc and cbprintf_package generate slightly
different results.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-11-08 10:44:36 +01:00
Francois Ramu b5d235022a tests: lib: cmsis_dsp testcases with min ram for execution
Since the new  CONFIG_ZTEST_NEW_API the ram fr execution
must be adjusted (higher)
to avoid buffer allocation failure s with some target board.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-11-03 09:07:20 +00:00
Kumar Gala ab02bbc965 tests: lib: p4workq: Convert CONFIG_MP_NUM_CPUS handling
Move runtime checks to use arch_num_cpus() and build checks
to use CONFIG_MP_MAX_NUM_CPUS.  This is to allow runtime
determination of the number of CPUs in the future.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-31 17:08:34 +01:00
Evgeniy Paltsev ac76c27af8 tests: arc: enable previously disabled tests on ARCv3 64bit platforms
Enable all cbprintf / logging related tests which were previously
disabled for qemu_arc_hs6x.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2022-10-31 11:22:12 +01:00
Kumar Gala a1195ae39b smp: Move for loops to use arch_num_cpus instead of CONFIG_MP_NUM_CPUS
Change for loops of the form:

for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
   ...

to

unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
   ...

We do the call outside of the for loop so that it only happens once,
rather than on every iteration.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-21 13:14:58 +02:00
Stephanos Ioannidis 30c5e0222b tests: cmsis_dsp: MVE correlate out-of-bounds access workaround
The MVE `arm_correlate_f32` and `arm_correlate_q31` implementations may
write to negative indices of the output buffer (refer to the upstream
CMSIS-DSP bug ARM-software/CMSIS-DSP#59).

This commit adds a workaround for the above bug by overallocating the
output buffer memory and offsetting the output buffer supplied to the
function.

Revert this commit when this bug is fixed.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-10-20 22:12:42 +09:00
Kumar Gala 4f0166088c tests: move to using CONFIG_MP_MAX_NUM_CPUS
For tests that set CONFIG_MP_NUM_CPUS, switch to using
CONFIG_MP_MAX_NUM_CPUS instead as we work to phase out
CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-20 22:04:10 +09:00
Stephanos Ioannidis 9dd570f8a2 tests: Remove explicit newlib nano override
This commit removes explicit `CONFIG_NEWLIB_LIBC_NANO=n` overrides
because the newlib nano variant is no longer enabled by default when
it is available.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-10-19 16:02:51 +02: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
Stephanos Ioannidis 44be5c941a tests: cmsis_dsp: Remove invalid mps3_an547 integration platform spec
This commit removes the `mps3_an547` board from the integration
platform list for the tests whose minimum flash size requirement exceed
the size of the flash available on the board.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-10-18 17:52:48 +09: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
Anas Nashif a5bd666f4e lib: notify: build sys-notify conditionally.
Add a new Kconfig and build this code conditionally, so we do not end up
with this file being built for each zephyr app.

Partial fix for #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-03 10:18:15 +02:00
Anas Nashif a81b322828 lib: onoff: add a config for on-off and build conditionally
Do not build this service unconditionally.

Partial fix of #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-03 10:18:15 +02: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
Andrei Emeltchenko 2e56f955db trivial: Remove empty files
Remove empty files.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-09-30 09:41:55 +00:00
Andrei Emeltchenko 1d879b93c5 trivial: tests: Remove empty file
Remove empty file.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-09-29 13:41:18 -05:00
Anas Nashif 215159c6ff tests: mem_blocks: remove board configs using dma logging
This is no longer needed and currently generating a fault with this
backend. Using the ztest delay fixes the issue and produces the complete
console output.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-26 10:53:43 +00:00
Zhao Shuai b15e64569c tests: lib: add a tag to uniquely identify mem_blocks test
To identify mem_blocks test uniquely.

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-09-26 08:11:13 +00:00
Henri Xavier 1a276d0ac6 ring_buffer: Introduce RING_BUF_ITEM_SIZEOF
Currently, to compute the 'item' size in a ring buffer, we have
`SIZE32_OF`.

Several issues with this:
- `SIZE32_OF` only works on variables, not types, due to an extra
 parenthesis pair. Indeed, `sizeof((int))` is not valid C, whereas
 `sizeof((my_var))` is.
- `SIZE32_OF` is not a proper public API
- `SIZE32_OF` rounds down if the argument size is not a multiple
 of 4 bytes.

Thus, we introduce a proper `RING_BUF_ITEM_SIZEOF`, fixing the
aforementioned issues.

Signed-off-by: Henri Xavier <datacomos@huawei.com>
2022-09-20 09:08:14 +00:00
Krzysztof Chruscinski a7224830ce lib: os: cbprintf: Mechanism for detecting %p in static package
Static packaging is using only argument types to build a package. There
is one case where analysing argument type only is not enough to
determine package content. That is %p with (unsigned) char pointer vs
%s. In case of %s a string might need to be appended to the package
and in case of %p it must be avoided. Format string analysis is required
to distinguish those two cases.
In order to speed up the runtime inspection, additional information is
added to a static package. That is index of the string argument (where
first argument has index 0). This information allows quick format string
inspection where nth format specifier is found and checked if it is a
pointer format specifier.
Inspection algorithm is added to cbprintf_package_convert() and if %p
is found then data for that argument is discarded. Additionally, log
warning is printed with suggestion to cast pointer argument to void *
to avoid confusion. It is desired to get rid of this ambiguity because
there are going to be logging configurations where strings are stripped
from a binary and runtime inspection cannot be performed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-19 10:14:23 +00:00
Enjia Mai ca5d698563 tests: lib: move the cmsis_dsp transform test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/transform to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-14 07:22:09 -04:00
Enjia Mai ccb3927233 tests: lib: move the cmsis_dsp matrix test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/matrix to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-14 07:22:09 -04:00
Enjia Mai 26b816cb5a tests: lib: move the cmsis_dsp filtering test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/filtering to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-14 07:22:09 -04:00
Enjia Mai 082e598f84 tests: lib: move the cmsis_dsp interpolation test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/interpolation to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-14 07:22:09 -04:00
Enjia Mai 63105256f7 tests: lib: move the cmsis_dsp statistics test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/statistics to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-14 07:22:09 -04:00
Enjia Mai 3e2fe17fa8 tests: lib: move the cmsis_dsp support test to new ztest API
Migrate the testsuite tests/lib/cmsis_dsp/support to the new
ztest API.

Signed-off-by: Enjia Mai <enjia.mai@intel.com>
2022-09-14 07:22:09 -04: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
Dominik Ermel d5810693ea tests: lib: gui: lvgl: Switch to FIXED_PARTITION_ macros
The commit switches flash area access from FLASH_AREA_ macros
to FIXED_PARTITION_ macros and to usage of DTS node labels,
to identify partitions, instead of label property.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-09-06 09:56:37 +02:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02: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
Ming Shao b92b8719b8 tests: use HDA logging for mem_blocks test on cavs platforms
Logging through winstream can miss logs when log output is
fast. The mem_blocks test suffer from this on CAVS platforms.
Add CAVS config overlays to use HDA logging instead.

Signed-off-by: Ming Shao <ming.shao@intel.com>
2022-09-01 10:26:52 +02: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
Krzysztof Chruscinski bb74b4f028 lib: os: cbprintf: Renamed flags used for conversion function
At some point, package copy function was extended and renamed
to cbprintf_package_convert. However, flags used by this
function were not renamed and used contained COPY idiom.
Deprecating flags with COPY and replacing them with flags
with CONVERT idiom to match function which is utilizing them.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-26 12:52:08 +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
Krzysztof Chruscinski 716fa446cd tests: lib: spsc_pbuf: Improve stress test
Improve stress tests to be more robust and demanding. Previous
implementation did not reveal race condition.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-24 17:48:50 +00:00
Krzysztof Chruscinski 4b5ff413f5 lib: os: spsc_pbuf: Fix miscalculation in the allocation
Wrong value was used for free space calculation. Updating test which
previously was hiding this bug.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-24 17:48:50 +00: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
Spoorthy Priya Yerabolu d4049e2cd6 tests: lib: sysutil: migrating lib tests to new ZTEST API
Migrating the sysutil tests to new ztest API

Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
2022-08-19 20:45:19 +00:00
Spoorthy Priya Yerabolu b341bce3a5 tests: lib: sprintf: migrating lib tests to new ZTEST API
Migrating sprintf tests to new ZTEST API.

Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
2022-08-19 20:45:19 +00: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
li biao c2c467a6ff tests: lib: move ringbuffer to new ztest API
Move test ringbuffer to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-08-18 16:08:44 +02:00
li biao b6fadd1600 tests: lib: move smf to new ztest API
Move test smf to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-08-18 11:34:50 +00:00
Katarzyna Giadla eae01f0fc5 samples: tests: Rename duplicated testcases
Names of some testcases are duplicated in another files.
This change rename duplicated testcases.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-08-17 12:11:00 +02:00
li biao ff6bf25632 tests: lib: cmsis_dsp: move svm to new ztest API
Move test svm to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-08-17 12:04:38 +02:00
li biao cbcc21e418 tests: lib: move p4workq to new ztest API
Move test lib/p4workp to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-08-17 12:04:22 +02:00
Robert Lubos 208cbffbf7 test: Add uoscore tests
Add unit tests for OSCORE library.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-12 16:17:59 +02:00
Stephanos Ioannidis 8355341c66 tests: lib: cmsis_nn: Initialise bias dimensions for depthwise convolve
This commit adds an initialisation for the `bias_dims` variable, which
is given as an input to the `arm_depthwise_conv_s8` function.

Note that the `bias_dims` parameter is currently unused by the function
implementation.

This fixes the following warning reported by the GCC 12:

  error: 'bias_dims' may be used uninitialized
  Werror=maybe-uninitialized]

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-10 12:00:18 +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
Krzysztof Chruscinski 3a369c47b3 tests: lib: spsc_pbuf: Test refactoring and improvement
Refactoring test by adding macro for total packet length
calculation and header length.

Tuning test to trigger a scenario where free space was miscalculated.
Bug was fixed in the previous commit.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-02 08:13:31 -04:00
li biao 00da7e1680 tests: lib: newlib: move thread_safety to new ztest API
Move test lib/newlib/thread_safety to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-08-01 18:04:58 +02:00
Kumar Gala 03a1fcb021 tests: gui: lvgl: Remove devicetree label
The lvgl glue code has been updated to use a devicetree label
so we can remove it from the test.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-01 18:03:01 +02: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
Stephanos Ioannidis bde270b1d5 tests: lib: notify: Fix uninitialised variable warning
This commit sets an initial value of 0 for the `res` variable, whose
pointer is passed to other functions and is not directly assigned
within the calling function.

Note that, when the test completes successfully, the value of the `res`
variable should be set to `423` (the value of `set_res`).

This fixes the "‘res’ may be used uninitialized" warning generated by
the GCC 12.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-07-29 16:44:04 +01:00
Chen Peng1 687e5a7158 tests: cmsis_dsp: bayes: set unique testcase name.
the testcase source file f16.c and f32.c might be
compiled into the final binary at the same time,
so need to set unique testcase name for each test.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-07-30 00:08:15 +09:00
Chen Peng1 cf9e548248 tests: cmsis_dsp: distance: set unique test names
the testcase source file f16.c and f32.c might be
compiled into the final binary at the same time,
so need to set unique test names for each test,
otherwise, it will report build failures "multiple
definitions".

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2022-07-30 00:08:15 +09:00
Zhao Shuai 1107a4decf tests: lib: spsc_pbuf: increase the timeout value
Increase the timeout value to avoid timeout.

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-07-28 19:46:56 +01: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
Krzysztof Chruscinski e63fc06491 tests: lib: spsc_pbuf: Increase test buffers
Test buffers must be increased to fit test data when cache
is enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-07-18 12:21:16 -04: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
li biao d233b40bf1 tests: lib: cmsis_dsp: move quaternionmath to new ztest API
Move test lib/cmsis_dsp/quaternionmath to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-15 15:35:15 +02:00
li biao 24d8223303 tests: lib: move heap_align to new ztest API
Move test lib/heap_align to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-15 06:58:57 -04:00
li biao f86a3b4b17 tests: lib: move heap to new ztest API
Move test lib/heap to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-15 06:58:57 -04: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
li biao 2bb51578dc tests: lib: move time to new ztest API
Move test lib/time to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-14 10:39:24 +02:00
Peter Mitsis 5ed73a864c tests: Add mem_blocks_stats test
The mem_blocks_stats test verifies the behaviour of the mem_blocks
runtime stats.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2022-07-12 13:59:26 +00:00
li biao 6ef33396b8 tests: lib: move notify to new ztest API
Move test lib/notify to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-12 11:19:22 +02:00
li biao e00bc8ece7 tests: lib: move onoff to new ztest API
Move test lib/onoff to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-12 11:19:22 +02:00
li biao bef88cb750 tests: lib: move fdtable to new ztest API
Move test lib/fdtable to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-08 21:12:55 -04:00
Spoorthy Priya Yerabolu a4eacf4996 tests: lib: mpsc_buf: move mpsc_buf to new ztest API
Move mpsc_buf to new ztest API.

Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
2022-07-08 21:10:05 -04:00
Spoorthy Priya Yerabolu c34edc36ce tests: lib: Move to new ztest API
Move lib tests to use new ztest API

Part of #47002 effort

Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
2022-07-08 21:10:05 -04: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
li biao 0754141de9 tests: lib: newlib: move heap_listener to new ztest API
Move test heap_listener to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-08 12:02:28 +02:00
li biao 51cb5b584b tests: lib: gui: move lvgl to new ztest API
Move test lvgl to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-08 11:58:22 +02:00
Spoorthy Priya Yerabolu fe9526313b tests: lib: cmsis_nn: move to new ztest API
Move lib tests to use new ztest API

Part of #47002 effort

Signed-off-by: Spoorthy Priya Yerabolu <spoorthy.priya.yerabolu@intel.com>
2022-07-06 20:02:19 -04:00
Anas Nashif 02f2896586 tests: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
li biao ddaee674e3 tests: lib: move json to new ztest API
Move test json to use new ztest API.

Signed-off-by: li biao <biao1x.li@intel.com>
2022-07-06 11:15:11 +02: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
Andrei Emeltchenko 669b02af8c tests: ringbuffer: Make code consistent
Refactor code to make it consistent and easier to read.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-04 22:25:03 +00:00
Andrei Emeltchenko a8cb2b74f3 tests: ringbuffer: Use defined req_len
Fixes "stored and never read" warning.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-04 22:25:03 +00:00
Andrei Emeltchenko ef6f4db7e0 tests: ringbuffer: Remove unneeded variable
Remove dead code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-07-04 22:25:03 +00:00
Christopher Friedt e08f84ab0b tests: lib: c_libc: tests for strerror, strerror_r
Add tests for strerror() and strerror_r()

Signed-off-by: Christopher Friedt <cfriedt@fb.com>
2022-07-04 22:53:36 +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
Keith Packard 7da1fca3d4 tests/c_lib: Let picolibc pick a malloc heap size
Now that picolibc's malloc arena configuration always allocates
some space, we don't need explicit allocations for tests.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-30 10:33:24 +02:00
Keith Packard a6119925c8 tests/mem_alloc: Let picolibc pick a malloc heap size
Now that picolibc's malloc arena configuration always allocates
some space, we don't need explicit allocations for tests.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-30 10:33:24 +02:00
Krzysztof Chruscinski cf19d7ef82 tests: lib: spsc_pbuf: Add test for getting maximum utilization
Add test for CONFIG_SPSC_PBUF_UTILIZATION option.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-30 10:30:49 +02:00
Krzysztof Chruscinski 1986591beb tests: lib: spsc_pbuf: Add tests for zero copy API
Extend test suite to validate zero copy API.
Add stress tests.
Add support for cache in the test. Test is not emulating cache
but ensures that buffer works correctly with cache enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-30 10:30:49 +02:00
Krzysztof Chruscinski 8c79ed2610 tests: lib: spsc_pbuf: Convert to use new ztest API
Convert test to use new API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-30 10:30:49 +02:00
Krzysztof Chruscinski fa055f743f lib: os: spsc_pbuf: Extend API with zero copy model
Added functions which allow to use zero copy model for handling
data within the packet buffer.

Additionally, added handling of cache by adding option to keep rd_idx
in different cache line than wr_idx and data.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-30 10:30:49 +02:00
Lauren Murphy ef3e66c2bc tests: lib: c_lib: ifndef out gcc pragmas
Ifndefs out GCC pragmas causing build failures for
compilers with older GNUC versions, e.g. XCC <= 2020.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2022-06-28 14:38:54 -04:00
Keith Packard 813c4e8626 tests: Add picolibc tests for cbprintf
Build the lib.cbprintf_package test using picolibc

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-27 12:47:25 +02:00
Keith Packard d0a788669e tests: Add picolibc tests
This adds picolibc-specific configurations for a couple of tests

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard 0643f00aa3 tests/mem_alloc: Make sure the "impossible" allocations actually are
The hifive_unleashed board is configured with 0xf0000000 bytes of memory,
so an allocation of 0x7fffffff should succeed. Instead, use a much larger
value to ensure that the allocation fails.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard 8bbad143ca tests/c_lib: Ignore stringop-overflow warning
One test reads too few bytes from the source to ensure nul-termination of
the result which generates a compiler warning.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard 88cfad5531 tests/c_lib: Don't assume a particular PRNG from Picolibc [v2]
The random/rand tests assume the PRNG operates in a specific fashion,
which is not true when running Picolibc.

v2:
	Call ztest_test_skip for picolibc

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard fa38fe9a21 tests/sprintf: Skip '%n' test on picolibc
Picolibc excludes %n support on purpose as it can introduce security issues
when the format string is vulnerable to manipulation.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard 92a5355e76 tests/sprintf: Adjust expected output for 5e-324
The smallest denorm is shown as 5e-324 by picolibc.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard fa496834ef tests/sprintf: Skip UB-dependent tests on Picolibc
Passing NULL as the stream to stdio functions is "UB" (undefined behavior)
in the C standard. Picolibc crashes in this case, which is valid, but not
helpful. Skip these tests in this case.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-22 13:15:55 +02:00
Keith Packard 08d4dc90a1 tests/heap_listener: Store 'malloc' value in global to avoid optimizer
When the compiler is allowed to know the semantics of malloc and free,
this test needs to be careful to not have both calls elided by not using
the result at all. Simply storing the malloc pointer in a global
variable is sufficient here.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Krzysztof Chruscinski cbc85071ee tests: lib: spsc_pbuf: Exclude ast1030_evb from test
This board has external cache enabled but fails to link when cache
API is used. Temporary disabling.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Krzysztof Chruscinski 0829610bbc lib: os: spsc_pbuf: Add option to use cache
Add flags option to init call and a flag to use cache.
Add Kconfig choice to pick how to approach cache. Cache can be
enforced in all spsc_pbuf instances, disable in all, or runtime selected
based on configuration flag. Option is added to allow memory footprint
savings.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Krzysztof Chruscinski 2f189e39a5 lib: os: Rename icmsg_buf to spsc_pbuf
Move icmsg_buf to lib/os and rename to spsc_pbuf (Single Producer
Single Consumer Packet Buffer). It is a generic module and initially
was created as internal module for ipc service.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Daniel Leung aff6e8b2f7 lib: os: cbprint: enable tagged arguments for packaging
This adds some bits to support tagged arguments to be used for
packaging. If enabled, the packaging function no longer looks at
the format strings to determine the types of arguments, but
instead, each argument is tagged with a type by preceding it
with another argument as type (integer). This allows the format
strings to be removed from the final binary to conserve space.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09: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
Stephanos Ioannidis 4735e10630 libc: minimal: Introduce CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS
This commit introduces a new configuration called
`CONFIG_MINIMAL_LIBC_NON_REENTRANT_FUNCTIONS`, which enables the
traditional non-reentrant (i.e. not thread-safe) version of the C
standard library functions such as rand() and gmtime() when the
respective configs are enabled.

The non-reentrant functions make use of the globals and require an
additional memory partition (MPU region), which is scarce on low-end
devices, when CONFIG_USERSPACE=y.

The purpose of this option is to classify the MPU resource intensive
functions as a separate category and only enable them when there is a
demand for such.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-06-01 11:03:38 +02:00
Keith Packard ced4ff29ea tests/c_lib: Set _GNU_SOURCE for qsort_r test
qsort_r is a GNU addition, so we need to #define _GNU_SOURCE to ensure
the prototype is defined in the header file.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Keith Packard 623a6d972b tests/mem_alloc: Eliminate alloc warnings. Define _BSD_SOURCE
We need to keep gcc from complaining about large calloc/malloc/realloc
sizes as that's what we're testing.

Define _BSD_SOURCE so that libraries sharing the glibc convention (like
newlib and picolibc) for controlling the API level visible to applications
will declare reallocarray(3), which is an OpenBSD extension to the C
library.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Stephanos Ioannidis 735ddeb4a8 tests: newlib: thread_safety: Add min. RAM constraint for stress tests
This commit adds a separate minimum RAM constraint for the thread-
safety stress tests because they have a significantly higher RAM
usage compared to the basic functional tests.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-26 15:11:43 -07: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
Anas Nashif 703422f742 tests: p4wq: set log level for test
Log messages from workqueue are very chatty and on some systems cause
dropping of messages coming from the tests, so set the level to not get
warnings.

Fixes #45670

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-17 20:39:25 -04:00
Guo Lixin 80b2d7722d tests: add filter of configs to avoid mismatch test running
Some test suites have different test case lists in test_main(), that
conforms to different test scenarios defined in testcase.yaml. We
use if statement to decide which test case list should run under
specific config.
But for thoses boards who do not support those configs, we will run test
cases on the other side of the if statement even if it has deviated from
the original test scenario.
So add filter to avoid test scenario running under mismatch config.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-05-16 22:49:34 -04:00
Anas Nashif a6f924db7f twister: add support for platform_type filter
Instead of relying on runtime filter to limit scope to emulation
platforms, use the type attribute for each platform and do the filtering
very early on. This will speed things up for tests where we only run on
emulation platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-14 14:49:59 -04:00
Anas Nashif 9276f30bdd tests: smf: use integration_platforms and list tests
list testcase in yaml file to workaround conditional testsuite
definition.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 8235ce6931 tests: newlib: define testcases in yaml
Define all testcases in the yaml for consistency and issue parsing
them during setup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 2a47391b3c tests: sprintf: define testcases in yaml
Define all testcases in the yaml for consistency and issue parsing
them during setup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04:00
Anas Nashif 9c15407ccc tests: c lib: define tests in yaml file
Define all testcases in the yaml for consistency and issue parsing
them during setup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-05-13 12:16:57 -04: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
Stephanos Ioannidis 84089d30eb tests: sprintf: Fix incorrect message for 1234.56789 test
This commit fixes the test message showing an incorrect input value of
-1 when the actual input value is 1234.56789.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-12 15:26:29 -04:00
Sylvio Alves 54aa7a9a56 samples: tests: exclude esp32 platform
Remove ESP32 and ESP32S2 from not working samples
and tests. Reason for not working is not enough memory
space in RAM to execute it. This can be worked out as next steps.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2022-05-11 10:47:27 +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
Stephanos Ioannidis 6a35a793b5 tests: cmsis_dsp: Add mps3_an547 as integration platform for FPU tests
This commit adds the `mps3_an547` board, a Cortex-M55 platform, as an
integration platform for all CMSIS-DSP FPU test cases so that the
M-Profile Vector Extension (MVE) vector function implementations are
tested in the CI.

With this change the FPU-enabled test coverage is as follows:

* mps2_an521_remote (Cortex-M33) tests FPU/DSP-enabled scalar function
  implementations.

* mps3_an547 (Cortex-M55) tests FPU/DSP-enabled MVE vector function
  implementations.

This also has a side effect of comprehensively exercising the M-Profile
Vector Extension support in the ARM architecture port, thereby ensuring
the arch-level FPU/DSP/MVE support is not broken.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Stephanos Ioannidis a38e68b97c tests: lib: cmsis_nn: Enable testing on mps3_an547
Zephyr SDK 0.14.1 now includes QEMU 6.2, which supports the emulation
of the MVE instructions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Stephanos Ioannidis 5790c5923f Revert "tests: lib: cmsis_dsp: Disable testing on mps3_an547"
This reverts commit 96c7f6ab75.

Zephyr SDK 0.14.1 now includes QEMU 6.2, which supports the emulation
of the MVE instructions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Stephanos Ioannidis 8c160e0d5a tests: lib: cmsis_dsp: filtering: Test vector FIR functions
This commit adds support for testing the vector implementation of the
FIR filter functions when the MVE is enabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Stephanos Ioannidis 4e379f9215 tests: lib: cmsis_dsp: filtering: Test vector Biquad functions
This commit adds support for testing the vector implementation of the
Biquad filter functions when the MVE is enabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Stephanos Ioannidis db56091560 tests: lib: cmsis_dsp: statistics: Adjust error threshold for MVE
The MVE vector version of the statistics functions are slightly less
accurate than the scalar equivalents, so allow a higher relative error
threshold when the MVE is enabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Stephanos Ioannidis f560eebd86 tests: lib: cmsis_dsp: fastmath: Adjust error threshold for MVE
The MVE vector version of the `vinverse` function is slightly less
accurate than the scalar version, so allow a higher relative error
threshold when the MVE is enabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-05 11:58:11 +09:00
Krzysztof Chruscinski 6f5cf3042d tests: lib: cbprintf_packaged: Add test for cbprintf_package_convert
Add test for the new function in the API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-04 18:56:55 -04:00
Stephanos Ioannidis 5135b9cd29 tests: lib: cmsis_nn: Fix test filter
This commit corrects the reference to a non-existent Kconfig symbol
`CPU_CORTEX_M` in the filter, which effectively disabled this test for
all platforms, to `CONFIG_CPU_CORTEX_M`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-04 21:07:15 +09:00
Tristan Honscheid 2abb2389a1 ztest API Migration: lib/cmsis_dsp
Migrate some of the unit tests at `lib/cmsis_dsp`
to the new ztest API:

  * lib/cmsis_dsp/basicmath
  * lib/cmsis_dsp/bayes
  * lib/cmsis_dsp/complexmath
  * lib/cmsis_dsp/distance
  * lib/cmsis_dsp/fastmath

`lib/cmsis_dsp/common/test_common.h` has been adapted to use the new
ztest API for the test variant macros, when enabled.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-04-26 08:41:11 -04:00
Tristan Honscheid 8283eb3b54 ztest API Migration: lib/c_lib
Migrate the unit tests at `lib/c_lib` to use the new ztest API.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-04-26 08:38:44 -04:00
Tristan Honscheid e4d24fcf3a ztest API Migration: lib/cbprintf_package
Migrate the unit tests at `lib/cbprintf_package` to use the new ztest
API.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2022-04-24 19:47:18 +02:00
Emil Obalski 3a9b082fef tests: Move icmsg_buf tests to subsys/ipc
Move ipc service backend unit test from tests/lib to
tests/subsys directory.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-04-18 23:19:32 -04:00
Emil Obalski cc57f0acb9 tests: Align buffer in icmsg_buf tests.
This change adds alignment to buffer on which icmsg_buf
is created. Some platforms run into fatal exception
when accessing unaligned addresses. Fix that by ensure
4 byte alignment.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-04-18 23:19:32 -04:00
Anas Nashif 59dbc746ed tests: sprintf: fix integration_platforms
native_posix_64 is excluded, so it should not be an integration
platform.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-04-08 09:31:01 +02:00
Marcin Szkudlinski 5a38823179 UnitTest: lib: change unit tests to handle asserts
Change negative tests to handle exceptions
instead of exit codes

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-04-05 14:29:33 -04:00
Marcin Szkudlinski 7147f1a704 UnitTests: lib mem_blocks: block_alloc_free_contiguous/free
Unit tests for mem_blocks library block_alloc_free_contiguous/free

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-04-05 14:29:33 -04:00
Marcin Szkudlinski ea1a0ff190 UnitTest: lib: test_mem_block_get test added
Unit tests for new memory_block library sys_mem_blocks_get functionality

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-04-05 14:29:33 -04:00
Marcin Szkudlinski 2cdce0ccb2 UnitTest: lib: test_mem_block_get increase num of blocks
As preparation for continous testing there 's a need to increase
number of blocks in tests

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-04-05 14:29:33 -04:00
Marcin Szkudlinski 9756914090 UnitTest: lib: mem_block: bugfix - table size
listener* tables are in fact some kind of log of all alloc/free
operations. Therefore size of the tables == NUM_BLOCKS makes
no sense and leads to table oveflows.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2022-04-05 14:29:33 -04: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
Yuval Peress 5416abfe5f util: convert wait_for macro to uppercase
This macro conflicts with C++'s std::condition_variable::wait_for
and makes it very difficult to use Zephyr with C++. Replace it with
an all uppercase name which fits the naming standard better.

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-04 09:50:28 -05: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
Krzysztof Chruscinski 50cc558924 tests: lib: cbprintf_package: Test for CBPRINTF_PACKAGE_COPY_KEEP_RO_STR
Extend test to validate CBPRINTF_PACKAGE_COPY_KEEP_RO_STR flag.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-29 23:03:35 -04:00
Krzysztof Chruscinski a33f7de86a lib: os: cbprintf: Add CBPRINTF_PACKAGE_COPY_KEEP_RO_STR flag
Add flag to copy function which indicates that read-only
string locations shall be kept in the output package.

Updated cbprintf_package test to pass.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-29 23:03:35 -04:00
Christopher Friedt d5ae42aa1d tests: lib: c_lib: add coverage for qsort_r
A user previously reported that `qsort_r()` did not have test
coverage. Prior to 845a200c1b
`qsort()` was actually just calling `qsort_r()` inline.

There is still virtually no difference between the two
sorting routines, but it would be good to add coverage.

Relates-to #44218

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2022-03-28 12:47:16 +02: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
Gerhard Jörges 4fd24a4341 libc: minimal: Add strtoll() and strtoull()
- strtoll() and strtoull() are copies of strtol() and strtoul() with
  types changed to long long instead of long.
- added tests
- added documentation
- removed stubs from civetweb sample

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2022-03-24 11:03:06 +01: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
Jordan Yates 44fdeb1dd8 tests: lib: cmsis: add CMSIS-NN integration tests
Import a selection of tests from the CMSIS-NN unit testing suite to
validate that the integration into Zephyr is working correctly.

Complete functional testing is left to the complete set of unit-tests
in the externally maintained code.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-22 12:56:02 +01:00
Emil Obalski 78aa0fce6b tests: lib: Add ipc_icmsg_buf unit tests
This commit adds unit tests for ipc_icmsg_buf library of ipc_service.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2022-03-22 12:36:39 +01:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Stephanos Ioannidis d75f00a513 tests: cmsis_dsp: matrix: Disable FP16 tests for POSIX arch
This commit disables the half-precision floating-point (FP16) tests for
the POSIX arch, because the `__fp16` type is not supported on the x86
host, which is the most common host type for the POSIX arch.

Note that the FP16 tests can technically run on the POSIX arch if the
host type is AArch64; but, since we do not have a proper configuration
scheme to resolve the host type for the POSIX arch at this time, we
simply disable these tests completely for the POSIX arch.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-03-16 07:32:19 -04:00
Stephanos Ioannidis 5040255cf9 tests: cmsis_dsp: transform: Disable FP16 tests for POSIX arch
This commit disables the half-precision floating-point (FP16) tests for
the POSIX arch, because the `__fp16` type is not supported on the x86
host, which is the most common host type for the POSIX arch.

Note that the FP16 tests can technically run on the POSIX arch if the
host type is AArch64; but, since we do not have a proper configuration
scheme to resolve the host type for the POSIX arch at this time, we
simply disable these tests completely for the POSIX arch.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-03-16 07:32:19 -04: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
Krzysztof Chruscinski 2306a97527 tests: Remove limitation from ztress and ring_buffer tests
Test were executed on single CPU only and with qemu_cortex_a9
excluded. Removing those limitations after fixes.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-15 13:19:28 -04:00
Krzysztof Chruscinski d00f9e8774 tests: lib: cbprintf_package: Add test for CBPRINTF_MUST_RUNTIME_PACKAGE
Add test for CBPRINTF_MUST_RUNTIME_PACKAGE macro.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 11:16:14 +01:00
Krzysztof Chruscinski d45d2619ce tests: lib: cbprintf_packaged: Extend test to check new modes
Extended test to check new flags added to cbprintf packaging API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 11:16:14 +01:00
Krzysztof Chruscinski c917e6c2ce lib: os: cbprintf: Extend API to support new packaging modes
Added new flags to packaging API:
- CBPRINTF_PACKAGE_ADD_RO_STR_IDXS - when set, read-only string
  locations are appended to the package
- CBPRINTF_PACKAGE_ADD_RW_STR_IDXS - when set, read-write string
  locations are appended to the package (instead of appending actual
  strings)
- CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(n) - indicate that n first strings
  are known to be read only. Ignored in runtime packaging.

Add function for copying packages with optional appending strings.

Changed CBPRINTF_MUST_RUNTIME_PACKAGE to use same flags as packaging.

Aligned logging and test to those changes.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-14 11:16:14 +01:00
Tom Burdick 3ab10f2d52 sys_util: wait_for, spin on an expression
Hardware has asynchronous actions where the expectation is to spin on
registers and expressions against those registers for completion of the
action. This provides a common macro to spin, with a delay and timeout,
on such expressions.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-03-11 09:46:47 -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 fd517ff6dc tests: lib: cbprintf_package: Hande riscv32 case
Long double test fails on riscv32 for unknown reason. Previously,
testcase.yaml was excluding whole test. Removed that and added
skipping in the code so that rest of the suite is executed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-10 14:03:52 -05:00
Krzysztof Chruscinski 7cba9f5dab tests: lib: cbprintf_package: Rework C++ test
Reworked test to use different approach for C++ testing.
Instead of hackish include of test.inc, cmake is forcing
C++ compilation on test file when C++ option is set in
test configuration.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-10 14:03:52 -05: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
Erwan Gouriou 0f038d75d5 tests/lib/devicetree: api: Add tests for DT_{INST_}PROP_HAS_NAME
Add tests for DT_PROP_HAS_NAME and DT_INST_PROP_HAS_NAME
macros

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-03-07 10:58:47 +01:00
Nicolas Pitre eee5b8e563 ring_buffer: make finish methods final
Make it possible to "finish" with fewer bytes than what was "claimed".

This was possible before on the get side, but the put side was
cummulative wrt finish. The revamp made it cummulative on both sides.
Turns out that existing users rely on the opposite behavior which is
more logical and useful. So make both sides that way.

Adjust documentation, test case and users accordingly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-28 10:52:41 +01:00
Ederson de Souza 6babbd32e1 boards/riscv: Add qemu_riscv32_smp and qemu_riscv64_smp
Based on qemu_riscv32 and qemu_riscv64, add minimal SMP support
using the "virt" machine.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-25 19:13:50 -05:00
Nicolas Pitre f4ac771f83 tests: ringbuffer: test 32-bit wrap-around conditions
The core ring buffer code presumes a 32-bit wrap-around behavior when its
head and tail indices cross the maximum value range. Make sure this is
covered by the test suite, for both 32- and 64-bit targets.

While at it, reduce stack requirement of the modified test.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre 099850e916 ring_buffer: the great simplification
This code is rather hairy. When I look at it I don't like the way it
stares back at me.

First, the rewind business looks fishy. It has to die.

And we don't have to rely on modulus either. Not even for non-power-of-2
buffers. Let's kill that distinction too and make all sizes always
"high performance".

The code is now entirely relying only on simple ALU operations (add,
sub and compare).

The key assumption: 32-bit values do wrap around after max range has
been reached. No saturation. All architectures supported by Zephyr
do that.

Some stats:

lib/os/ring_buffer.c: 62 insertions(+), 124 deletions(-)

ring_buffer.c.obj       before   after    diff
----------------------------------------------
frdm_k64f                 1224    1136     -88
m2gl025_miv               2485    2079    -406
mps2_an385                1228    1132     -96
mps2_an521                1228    1132     -96
native_posix              1546    1496     -50
native_posix_64           1598    1595      -3
nsim_hs_mpuv6             1252    1192     -60
nsim_hs_smp               1252    1192     -60
nsim_sem                  1252    1192     -60
qemu_arc_em               1324    1192    -132
qemu_arc_hs6x             1824    1620    -204
qemu_arc_hs               1252    1192     -60
qemu_cortex_a53_smp       2154    1888    -266
qemu_cortex_a53           2154    1888    -266
qemu_cortex_a9            1938    1792    -146

Before (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 52
4 byte put-get, avg cycles: 47
1 byte put claim-finish, avg cycles: 39
5 byte put claim-finish, avg cycles: 41
5 byte get claim-finish, avg cycles: 52
 PASS - test_ringbuffer_performance in 0.8 seconds

After (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 34
4 byte put-get, avg cycles: 41
1 byte put claim-finish, avg cycles: 27
5 byte put claim-finish, avg cycles: 29
5 byte get claim-finish, avg cycles: 29
 PASS - test_ringbuffer_performance in 0.4 seconds

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre c2543320d8 ring_buffer: rationalize the item-based put and get methods
Conceptually, ring_buf_item_put() and ring_buf_item_get() are specialized
versions of ring_buf_put() and ring_buf_get(). Make it so to rationalize
the code to open the way for more optimizations.

This means we need specialized wrappers on top of ring_buf_init()
accordingly, given that the core machinery is now common and byte based.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre f821a596f0 tests: ringbuffer: delete out-of-date comment
Commit 1e46bb3bb5 ("lib: os: ring_buffer: Allow using full buffer
capacity") changed the capacity test condition but left the comment
relating to the previous test condition in place.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Nicolas Pitre 4bf242725f tests: ringbuffer: remove bogus test
The removed test was bogus and pointless.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
Bartosz Golaszewski 0f09360456 lvgl: change the prefix of Zephyr-specific LVGL config options
We're now using the Kconfig copied from the upstream lvgl repository. It
uses the LV_ prefix for all options while we're using LVGL_ for
Zephyr-specific ones. Make the latter consistent with upstream but also
make sure they're distinct from lvgl's by using LV_Z_ as the prefix.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 6c190292c0 lvgl: move the lvgl glue out of the zephyr tree
Start using the upstream Kconfig from LVGL and move the glue code out
of the zephyr tree and put it under lvgl/zephyr/ in modules.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 1244a89a21 lvgl: bump version to v8.1.0
This updates the lvgl in-tree glue code to work with version v8.1.0 and
bumps the west manifest accordingly.

The following are the most significant changes:
- The logging callback has changes in lvgl and no longer provides the
  caller with an integer log level code. We now need to parse the log
  string's prefix to determine the level.
- Several Kconfig options (mostly for default values of various settings)
  have been removed because these values are no longer configurable in
  lvgl.
- The library no longer performs a deep copy of the display and input
  device driver structs, so these must no longer be allocated on the
  stack in the init func.

Other than that it's mostly about renaming of various structures and
functions and adjusting the calls if function's signatures have changed.

This patch allows all in-tree users to work correctly but it's likely
it doesn't support all new widgets and layouts added in lvgl v8. These
however can be added gradually once this is upstream.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 595131c2d0 lvgl: kill LVGL_MEM_POOL_HEAP_KERNEL and LVGL_MEM_POOL_KERNEL
Current lvgl code allows to use the kernel heap for dynamic memory
allocation. The k_heap API doesn't however provide k_realloc() which
will be needed in order to update lvgl to v8. Nico suggested there's
no good reason for lvgl to use k_heap and it should stick to either
the libc's allocator or depend on its own private sys_heap.

The alternative would be to extend the k_heap API to provide k_realloc()
but this may be tricky for several reasons and for now there would
be a single user anyway.

This removes the choice of using k_heap for lvgl and renames the user
pool to SYS_HEAP in Kconfig and makes it the default option.

The prj.conf for the lvgl sample is modifed to specify the number of
memory pool blocks instead of the total size as the default block
size is 2048 and it results in the same size of memory.

Suggested-by: Nicolas Pitre <npitre@baylibre.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bartosz Golaszewski 98665755ea tests: lvgl: drop duplicate include
lvgl.h is already included in the img.h header. Drop the duplicate.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
2022-02-24 11:51:33 +01:00
Bradley Bolen c0dd594d4d arch: arm: aarch32: Change CPU_CORTEX_R kconfig option
Change the CPU_CORTEX_R kconfig option to CPU_AARCH32_CORTEX_R to
distinguish the armv7 version from the armv8 version of Cortex-R.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2022-02-23 08:14:15 -06:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Ederson de Souza d1cdeab851 tests: Define mbox device
XCC (based on GCC 4.2) will emit undefined references to symbols that
are not used. Newer versions of GCC simply don't emit them, but for XCC,
linker will complain about those undefined references.

This patch adds a dummy definition of the mbox devices used on tests, so
that the linker is happy.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-02-21 22:17:27 -05:00
Carlo Caione 18ffcdcf74 linker: Introduce zephyr,memory-region compatible
Introduce a new "zephyr,memory-region" compatible to be used when a new
memory region must be created in the linker script from the devicetree
nodes using the compatible.

Remove also the LINKER_DT_REGION_FROM_NODE macro and add a new
LINKER_DT_REGIONS macro to cycle through all the compatible regions.

In the same PR modify the DTS files and the linker scripts.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:02:04 -05:00
Krzysztof Chruscinski 9ea5c1e510 tests: lib: mpsc_pbuf: Add test for utilization api
Add test for mpsc_pbuf_get_utilization and
mpsc_pbuf_get_max_utilization.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-21 20:41:17 -05:00
Anas Nashif 73d8a8d8ef tests: ringbuffer: increase timeout
Increae timeout from 90 to 150 to make it pass on more slow boards.

Fixes #42756

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-02-15 13:26:08 -05:00
Erwan Gouriou 2f7b5ad8ea tests/lib: devicetree: Remove references to deprecated macros
These deprecated macros are now removed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-02-05 06:26:25 -05:00
Maciej Perkowski 0c830822ae tests: lib: ring_buffer: Increase timeot
The tests from tests/lib/ringbuffer fails on all nrf platforms due
to a timeout. Increasing the timeout value solves the issue.

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-01-26 14:39:12 -05:00
Andy Ross 82bc7d0733 tests/lib/ringbuffer: Run with one CPU
The stress ('scuse me, "zstress") cases here are all written to
exercise reader/writer threads at different priority combinations.
That's defeated if the threads are allowed to run on different CPUs
(because being "low" priority doesn't matter if you have a spare CPU
to run on).

There is also extensive use of stack buffers to pass data through the
ring buffer zero copy implementation, which runs afoul of the
KERNEL_COHERENCE rules on intel_adsp platforms (where stack memory is
incoherent between CPUs and can't be shared like that).

Fix both issues by just setting CONFIG_MP_NUM_CPUS=1

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-24 12:23:46 -05:00
Gerard Marull-Paretas b768fb6f94 tests: lib: devicetree: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with
dev->data and dev->config.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Daniel Leung 8f7f62869a tests: remove @return doc for void functions
For functions returning nothing, there is no need to document
with @return, as Doxgen complains about "documented empty
return type of ...".

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-12 16:02:16 -05:00
Anas Nashif 5e05393afa tests: ztress: fix dependency on SMP
Use CONFIG_MP_NUM_CPUS=1 with ztress and do not disable SMP completely.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-01-12 14:13:21 -05:00
Krzysztof Chruscinski 902cff3d62 tests: lib: ringbuffer: Update test to use ztress
Updated test to use stress testing framework instead of implementing
own framework.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-11 18:19:44 -05:00
Daniel Leung 7d561a3ea5 tests: lib/mem_blocks: add test for heap listeners
This adds simple tests to make sure the heap listener interface
works with memory blocks allocator.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung 7f06fb4129 tests: lib/mem_blocks: add tests for multi mem_blocks allocator
This adds a few tests to make sure the multi memory blocks
allocator functions work correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung 50f8f3caea tests: add new tests for the new memory blocks allocator
This adds some new tests to make sure the new memory blocks
allocator work correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-11 16:10:53 -05:00
Daniel Leung be9779753f tests: lib/heap: add test for heap listeners
This adds test to make heap listeners are working correctly.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Daniel Leung ae415272c1 sys: heap_listener: extend to cover more events
This extends the heap_listener to cover more events,
specifically, allocation, free and realloc.

Note that typedef are used so the callback can be
documented.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00
Daniel Leung 39d17a180a sys: heap_listener: resize_cb to also take heap ID
Add a parameter to the resize callback to also take the heap ID.
This allows a single callback to be used for multiple heaps if
so desired.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-01-10 10:28:04 -05:00