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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Updated test to use stress testing framework instead of implementing
own framework.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Added test which can be used to verify performance of ring
buffer algorithm.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
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>
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>
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>
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>
... 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>