Commit graph

66 commits

Author SHA1 Message Date
Alberto Escolar Piedras 2c6db3b717 tests/lib: Use hwmv2 native targets identifiers
For the 64 bit targets, change identifiers to the new hwmv2 ones

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-03-15 16:13:12 +01:00
Alberto Escolar Piedras 1a3ba0ec82 tests/lib/*: Switch integration platform to native_sim
Swith integration_platforms from native_posix(_64)
to native_sim(_64).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-30 09:42:25 -05:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Anas Nashif f7456cb7cd tests: spsc_pbuf/ringbuffer: fix test meta data and components
Fix meta data and standarize components in test identifiers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-11 14:19:40 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Daniel Leung 614db9a631 tests: lib: renames shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:12 +00:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Evgeniy Paltsev a438b75395 tests: ARC: enable back tests/lib/ringbuffer on qemu_arc_hs6x
tests/lib/ringbuffer is now finally fixed with commit 15e834a687
("linker: __data_region_start equal to __data_start"), so we can enable
it back.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-10-01 09:30:07 -04:00
Krzysztof Chruscinski 8ca8280cc3 tests: lib: ringbuffer: Fix preempt_cnt not being reset
Counter was not reset between various tests which may hide the fact
that number of preemptions is less than expected.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-09-02 19:38:37 -04:00
Krzysztof Chruscinski ad6fc38b2f tests: lib: ringbuffer: Fixing tests for various platforms
Stress test that was validating thread safeness was configured to use
higher sys tick rate and targeting qemu_x86 platform. However, it was
also build for other platforms and was failing. Fixing it by extracting
stress tests to separate configuration that is run only on qemu_x86.

Modified the test to fail when number of preemptions is less than
expected only on qemu_x86.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-09-02 19:38:37 -04:00
Evgeniy Paltsev ee1bf19325 tests: disable tests/lib/ringbuffer failing on qemu_arc_hs6x
Temporary disable tests/lib/ringbuffer failing tests on
qemu_arc_hs6x until we fix the rootcause so we can enable
qemu_arc_hs6x in upstream verification.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-29 14:24:44 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Krzysztof Chruscinski 87e60fac2a tests: lib: ringbuffer: Add tests for preemption
Added test cases that validates if ring buffer handles
correctly case with single producer single consumer from
different contexts.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-08-17 19:52:08 +02:00
Christopher Friedt 6cb1e22fd4 tests: lib: ringbuffer: ring_buf_peek() and ring_buf_size_get()
Added tests for ring_buf_size_get() and ring_buf_peek().

Fixes #37147

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-07-28 07:32:28 -04:00
Jordan Yates 491fe2a64d tests: lib: ringbuffer: test discard functionality
Add tests that validate the behaviour of providing NULL as a data
pointer to discard whatever data is in the ring buffer.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-09 13:19:30 +02:00
Ningx Zhao f1e770d1db tests: ringbuffer: test concurrent operation
Add a testcase to test that read and write the
same buffer at the same time to check the
integrity of data reading and writing.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2021-04-06 10:16:48 -04:00
Andy Ross 589c781506 tests: No thread-shared/synchronized data on stack (coherence)
CONFIG_KERNEL_COHERENCE forbids synchronized data on the stack: no
spinlocks, IPC primitives, or things that contain them.  Application
code obviously doesn't have to follow these inconvenient rules, but
our test code needs to run on platforms with incoherent stack memory.

Make these things static.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Krzysztof Chruscinski 9703a78bb3 tests: lib: ringbuffer: Add performance test
Added test which can be used to verify performance of ring
buffer algorithm.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-11-11 13:17:49 +01:00
Krzysztof Chruscinski 1e46bb3bb5 lib: os: ring_buffer: Allow using full buffer capacity
Previously, ring buffer had capacity of provided buffer size - 1. This
trick was used to distinguish between empty and full states. It had one
drawback: ring buffer could not be used as a pool of equal sized buffers
(using ring_buf_put_claim and ring_buf_get_claim).
Reworked internals to use non wrapping head and tail. Since they are
non wrapping, there is no issue with distinguishing between empty and
full. Since this appraoch would be vulnerable to wrapping on 32 bit
boundary, added a mechanism which periodically reduces all indexes to
avoid 32 bit wrapping.

After this rework, buffer has one byte more capacity. Simple test shows
slight performance improvement.

Updated tests to reflect increased capacity and added test to check if
it is possible to continuesly allocated 2 buffers of half ring buffer
size.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-11-11 13:17:49 +01:00
Ningx Zhao fe2787a665 Tests: ringbuffer: Improve the description cases
The existing testcase's doxygen describes are the general
implementation idea of a function.On this basis, adding
more descriptive statements to describe which conditions
need to be preset when running the testcase, which test
techniques are applied, and describe the testcase Design
steps in detail. Make it more readable.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-10-14 07:43:39 -04:00
Tomasz Bursztyka 4b9134d8d2 tests: Apply IRQ offload API change
Switching to constant parameter.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Anas Nashif eee3ffc7b9 tests/samples: enable for integration testing
Limit execution in CI when using --integration option of sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-30 08:00:03 -04:00
Anas Nashif 0798b85d1c tests: remove obsolete doxygen boilerplate
An old doxygen biolerplate was being copied all over the tests. The
defined groups are not being used anywhere and it does not follow how we
document tests for example in the kernel and other places.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-28 08:14:23 -05:00
Ningx Zhao c42297c2f1 tests: ringbuffer modify a tesecase
Update code comments in ringbuffer/src/main.c
modify a testcase to verify the address stored by ring buffer
is contiguous, and the size of every element is equal to the size of
pointer.

Signed-off-by: Ningx Zhao <ningx.zhao@intel.com>
2020-06-16 16:55:51 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00