Commit graph

7830 commits

Author SHA1 Message Date
Krzysztof Chruscinski 23c3449780 tests: logging: Add test for log backend prolong init
Add test for handling of autostarting backends which have
prolonged initialization and implements function for polling
for readiness.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-09 09:40:01 +02:00
Daniel Leung 68684f7310 tests: log_api: exclude XCC from runtime tagged argument tests
XCC does not support _Generic so it can't build the runtime tagged
argument tests. So exclude them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 09:31:42 -04:00
Jordan Yates 8eff15bab2 tests: pm: device: test pm_device_is_powered
Add tests for the function that checks whether a device is currently
powered.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-08 12:43:00 +02: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
Andy Ross 5139d052d8 tests/intel_adsp/smoke: Revert WAIT_FOR breakage
The evolution of the original WAIT_FOR trick in this test, first to
move it to a generic spot and then to make it take a delay
paramatrization, have had the unfortunate side effect of breaking the
original usage.

And... it's really not following the design intent anyway.  The idea
here was to spin hard waiting on external hardware (a python script
running on the host) to deliver an interrupt.  Both of the new tricks
(suspending the thread with a sleep and hammering the HDA wall clock
for time) can affect interrupt delivery.

Just restore the original implementation (albeit with a new name,
"AWAIT", since the original was stolen) until someone has a chance to
make this work properly with the new API.  There's no reason it can't,
it just doesn't yet.

Fixes #43828

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-06-07 18:58:00 +02:00
Mariusz Skamra 146124e7f9 tests: has: Extend tests with preset selection commands
The commands are used to change the active preset.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Emil Gydesen c513fd87e1 Bluetooth: ISO: Rename sn to seq_num
Rename the `sn` field(s) to `seq_num` to be more readable
and clear what the value covers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen 6786bbdb32 Bluetooth: ISO: Add sn and ts to bt_iso_chan_send
Add two new parameters to bt_iso_chan_send:
sn: The packet sequence number which shall be incremeted
per SDU interval.
ts: An optional timestamp value used to synchronize SDUs.

The sequence number in the API uses a 32-bit value even though
the sequence number for the HCI command is 16-bit. This is to
properly handle wrapping of sequence numbers, which is much
easier to do with additional bits allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Carlo Caione 86bb739b7b reserved_memory: Remove it and cleanup
The reserved memory mechanism (sections and regions definition) has been
entirely replaced, greatly extended and made it better by the work done
on the zephyr,memory-region compatible.

Since there is are no actual users, we can remove it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-07 09:41:57 -07:00
Daniel Leung 8f97e25645 tests: logging/log_api: add a few bits for tagged arguments
This adds a few bits to support testing for runtime tagged arguments
when CONFIG_LOG2_RUNTIME_USE_TAGGED_ARGUMENTS is enabled.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09: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
Pavel Vasilyev dc4889e8be tests: bluetooth: mesh: Test RPL fragmentation
Ensure that RPL fragmentation doesn't occur.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-06-07 11:53:31 +02:00
Ederson de Souza 3209bc1a4a soc/xtensa/intel_adsp/tools: Make cavstool.py DSP resetting more stable
When using more than one core on cavs25, some hangs were made
"persistent", as it seems not all cores were being properly reset, thus
compromising tests - if a test hangs for any reason, subsequent tests
that were not restrict to a single CPU would also fail.

This patch mitigates these issues by two changes:
  - Closely mimics SOF Linux driver way of loading the firmware. So,
    explicit stall and reset (and "unstall" and "unreset") of cores, with
    appropriate checks that states have been reached;
  - More generous sleep before resetting the stream.

Also, the status of ADSPCS (Audio DSP Control and Status) register is
logged more thoroughly to aid debugging in case new issues arise.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2022-06-07 11:51:37 +02:00
Yinfang Wang 3f69745784 tests: timer_monotonic: Enable APIC timer's TSC deadline mode on ehl_crb
ehl_crb supports HPET timer by default. Add test suite to test APIC
timer's TSC deadline mode on ehl_crb.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-06-06 22:45:58 +02:00
Marcin Niestroj 41c618dbf7 modem: simcom-sim7080: use 'gpio_dt_spec' instead of 'modem_pin'
Move away from 'modem_pin' abstraction as it has not obvious value compared
to generic 'gpio_dt_spec'.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-06 17:58:52 +02:00
Marcin Niestroj 9353b6e98a modem: ublox-sara-r4: use 'gpio_dt_spec' instead of 'modem_pin'
Move away from 'modem_pin' abstraction as it has not obvious value compared
to generic 'gpio_dt_spec'.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-06 17:58:52 +02:00
Marcin Niestroj 10ebfb3877 modem: quectel-bg9x: use 'gpio_dt_spec' instead of 'modem_pin'
Move away from 'modem_pin' abstraction as it has not obvious value compared
to generic 'gpio_dt_spec'.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-06 17:58:52 +02:00
Marcin Niestroj 9ec661b206 wifi: esp_at: use 'gpio_dt_spec' instead of 'modem_pin'
Move away from 'modem_pin' abstraction as it has not obvious value compared
to generic 'gpio_dt_spec'.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-06 17:58:52 +02:00
Juha Heiskanen 2da8df8b7e net: lwm2m: Integrate JSON lib to LwM2M 1.0 JSON
Integrated updated JSON library to LwM2M 1.0 JSON.
Removed Old Json format default choice.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
2022-06-06 12:06:43 +02:00
Aastha Grover 1c1748d579 tests: add testcases for dynamic switching logging formats.
Adding testcases for switching of logging formats at runtime.
Includes testing for log_backend_format_set,
log_format_set_all_active_backends & log_format_func_t_get
routines.

Signed-off-by: Aastha Grover <aastha.grover@intel.com>
2022-06-05 14:49:01 +02:00
Gerard Marull-Paretas 6cfdd336dd tests: kernel: context: fix soc.h include policy
Include only on platforms that are known to require it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-06-05 14:48:40 +02:00
Øyvind Rønningstad 920028e03b tests: arm_thread_swap_tz: Explicitly set the TFM_PROFILE
to NOT_SET, in case the default is changed.

Add print of failing error code for psa_hash_compute().

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2022-06-05 14:48:31 +02:00
Guo Lixin 169aacdf89 tests: cumstom_output: change output to fit twister
Since output can be cumstomized, so slightly change the output format,
so that twister can parse the output and collect the passrate correctly.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-06-05 14:48:20 +02:00
Hu Zhenyu 59357998d1 test: Remove the TC_XXX macro in tests/arch/arm/arm_runtime_nmi
As the test case is using ztest framework, so the TC_XXX macro
is never needed.

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-06-05 14:47:28 +02:00
Hu Zhenyu 312ed2526f test: Enable the GPIO tests on mec172xevb_assy6906
Enable testcases under tests/drivers/gpio/gpio_basic_api
To run in twister, "-X gpio_loopback" parameter is needed

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-06-05 14:47:21 +02:00
Alperen Sener 12e57d414c tests/bluetooth/tester: Set mesh message cache size to 10
MESH/NODE/RLY/BI-02-C case requires cache size of 10

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2022-06-05 14:45:24 +02:00
Guo Lixin fe7858bba1 tests: remove unused harness config
logging.log_syst.mipi_syst is written in ztest framework, now it has
a good method to test automatically, no need to configure the harness
as console any more, so remove it.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-06-05 14:44:35 +02:00
Mariusz Skamra 36c8324add tests: audio: Fix audio direction in test
This fixes direction that shall be BT_AUDIO_DIR_SOURCE in this
particular case.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Mariusz Skamra 33991f2dde Bluetooth: audio: Expose API methods to change the available contexts
This exposes API methods to change the available context types.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-05 14:44:21 +02:00
Damian Krolik 74e4ac0883 nvs: implement NVS cache
The NVS data lookup time grows linearly with the number of
allocation table entries to walk through, meaning that if
some data pair in the NVS changes frequently, access to
other data pairs that change rarely can take a lot of time.

It is particularly visible when the NVS is used as the
settings backend since the backend needs to perform multiple
NVS reads to find a requested key.

Implement a simple cache that stores an address of the most
recent ATE for all NVS IDs that fall into the given cache
position. CRC8/16 is used as a hash function used to
distribute NVS IDs across the cache entries.

The cache entries are only invalidated when an NVS sector
is erased as part of the garbage collector task.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2022-06-05 14:43:59 +02:00
Emil Gydesen 0eb5b3ac03 Bluetooth: Shell: Add gatt notify-mult command
Add GATT command to test the bt_gatt_notify_multiple
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-05 14:29:33 +02:00
Andriy Gelman d67a130368 tests: net: Check leaks when appending frags to a cloned packet
This test checks that new frags appended to a cloned packet are properly
freed.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-06-05 14:29:19 +02:00
Andriy Gelman f119a368a2 tests: net: Add test to detect leak in pkt shallow clone
Checks that taking a shallow of a packet does not leak buffers after the
packet and its clone are unreffed.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2022-06-05 14:29:19 +02:00
Mark Holden f32f3aead3 coredump: drivers: Add coredump device test
A test is added that uses the new device and verifies that all
desired memory is included in the core dump when a crash occurs.

Signed-off-by: Mark Holden <mholden@fb.com>
2022-06-05 14:28:34 +02:00
Sebastien Bourdelin 52ac180fe4 tests: spi: spi_loopback: rename SPI_SLAVE to SPI_SLAVE_NUMBER
As the SPI_SLAVE define is used by some HAL (e.g. the gigadevice HAL),
SPI_SLAVE has been renamed to SPI_SLAVE_NUMBER.

Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@rtone.fr>
2022-06-05 14:28:11 +02:00
Markus Rekdal 30dfcec45f net: lwm2m: Add raw CBOR content writer tests
Add unit tests for raw CBOR content encoder/decoder.

Signed-off-by: Markus Rekdal <markus.rekdal@nordicsemi.no>
2022-06-05 14:27:39 +02:00
Asbjørn Sæbø b41bc06869 Bluetooth: Audio: Media tests - remove superfluous includes
Remove #includes that are not required.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-06-05 14:27:05 +02:00
Asbjørn Sæbø 704851abb8 Bluetooth: Audio: Test - add missing newline
Add missing newline to printk().

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-06-05 14:27:05 +02:00
Asbjørn Sæbø 7daf7260e3 Bluetooth: Audio: Test - add "PASSED" output to BabbleSim tests
Redefine PASS macro to add "PASSED" to the output.  This makes passes
easier to grep for by ensuring a consistent pattern in the output.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-06-05 14:27:05 +02:00
Jordan Yates 0177a3ea23 tests: devices: test injected dependencies
Test that injected dependencies compile and appropriate API functions
work correctly.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-06-05 14:26:39 +02:00
Nickolas Lapp 9a9aeae00b i.MX NXP Boards: Add support for RT1060_EVKB
This PR adds support for the RT1060_EVKB as a variant of the RT1060 EVK.
Blinky app tested locally on RT1060_EVKB.

Signed-off-by: Nickolas Lapp <nickolaslapp@gmail.com>
2022-06-05 14:16:43 +02:00
Brandon Satrom 168f4d1d18 boards: arm: swan_r5:add Swan board support
Add support and docs for the Blues Swan, an STM32L4R5-based board

Signed-off-by: Brandon Satrom <bsatrom+gh@gmail.com>
2022-06-05 14:14:46 +02:00
Michal morsisko ddc4854d27 boards: Added E73-TBB board
This commit adds support for EBYTE E73-TBB.
This board features Nordic nRF52832 chip.
It was tested with several samples such as blinky and buttons.

Signed-off-by: Michal morsisko <morsisko@gmail.com>
2022-06-05 14:12:56 +02:00
Marcin Niestroj c4bd3f1e38 tests: net: socket: udp: verify that sent DGRAM was not fragmented
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that.

Verify that by trying to send MTU+1 bytes in case of IPv4 (as IP level
fragmentation is not implemented) and IPv6 (should fail when IPv6
fragmentation support is not enabled and succeed otherwise). In case of
IPv6 try to send "total number of network buffers + 1", so that even with
IPv6 fragmentation enabled requested datagram will not be sent. In all
tested cases when datagram is too big, check that ENOMEM error code is set.

NOTE: Tested behavior is not 100% compliant with Linux, as on Linux
EMSGSIZE error code is set when trying to send datagram bigger than MTU,
when manually disabling IP fragmentation (by setting IP_MTU_DISCOVER to
IP_PMTUDISC_DO). However, it is not trivial to implement such
behavior (EMSGSIZE error due to MTU) now and there is always a risk of
running out of buffers (and getting ENOMEM), so for now implemented tests
just assume the latter case to always happen.

Add 3rd testcase, which enables IPv6 fragmentation support, so that UDP
socket behavior can be tested in that context.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-01 11:17:07 +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
Sjors Hettinga d55c921e2f tests: net: socket: tcp: Add test for a broken link
A reproducible case to the behavior when during a connection
the link gets broken and all data is lost, the TCP connection
should properly terminate.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-30 10:30:38 +02:00
Mariusz Skamra 0492ef5bbf Bluetooth: audio: Fix call control client build
error: 'CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH' undeclared (first use
			in this function); did you mean
			'CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH'?
  292 |            CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH
etc.

This fixes build errors that were seen while building call control
client without server side (`CONFIG_BT_TBS`) enabled.
The options like BT_TBS_CLIENT_MAX_URI_LENGTH and
BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH have been removed because those
were not used in the code. In fact the client implementation used the
common options for BT_TBS_MAX_URI_LENGTH and
BT_TBS_MAX_PROVIDER_NAME_LENGTH that were moved in this patch to the
common Kconfig section.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-27 17:47:58 -07:00
Robert Lubos 3cd88c72b1 tests: net: sockets: Update packet socket tests
Fix the existing DGRAM packet socket test. The test will now specify
LL destination address and protocol type. Also, update the fake ethernet
device send handler, so that it sets the packet network interface
corretly, so that the packet is not rejected at Ethernet L2.

Additionally, add two additional test cases verifying datagram packet
sockets. Fist test will exchange packet between RAW and DGRAM socket,
making sure that net stack forwards/removes L2 header correctly. The
second test verifies that it's possible to recieve a packet on both RAW
and DGRAM socket, making sure the received data has correct format.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07: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
Keith Packard d24e975a71 tests/kernel/common: Include errno_private.h
This ensures that we have a definition of z_errno in case
that isn't pulled in with errno.h

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Keith Packard b6f51c70e2 tests/spi_loopback: Fix buffer sizes to avoid buffer overflow
The initialized test buffers tx_data and tx2_data were not given a
specific size, but were initialized with one more byte than the
uninitialized buffers they get copied to. As a result, the memcpy found
a buffer overflow. Fix this by setting the source buffer sizes to match
the destination.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-05-27 15:34:34 -07:00
Fabio Baltieri e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Vinayak Kariappa Chettimada 192e2a8f94 Bluetooth: Controller: Fix Data Length Request Cmd parameter checking
Fix Data Length Request CMD parameter checking to not
restrict invalid maximum Tx time values. This addresses
conformance test cases that provide maximum Tx time values
of 2128 us when not supporting Coded PHY in the Controller
implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-27 15:19:06 -07:00
Vinayak Kariappa Chettimada ad1aae29e5 tests: Bluetooth: EDTT: Fix incorrectly disabled legacy LLCP tests
Fix incorrectly disabled tests that had been passing on
legacy LLCP implementation in the Controller.

Regression introduced in commit f023b5f611 ("Bluetooth:
controller: push topic branch to main").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-27 15:19:06 -07:00
Daniel Leung b5509cb234 tests: log_api: workaround QEMU crashing on qemu_leon3
When running twister during logging.log2_api_immediate_printk_cpp
on qemu_leon3, it reports unexpected eof even though the tests
reported successful. This results in twister reporting the test
being failed due to "unexpected eof".

When running it using west build, QEMU quits immediately after
printing PROJECT EXECUTION SUCCESSFUL instead of simply waiting
there for Ctrl-A X.

So workaround this by changing the main stack size to 4096.

Related to #46056

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-05-27 11:45:58 -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
NingX Zhao 1bc003ad6a tests: net: Adjusting the memory buffer for ETH
The net cases failed to run on sam_e70b_xplained
platform because failed to reserve data net buffers,so
adjusting the memory buffer to fix this.

Fixes #42857

Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
2022-05-26 13:39:11 -07:00
Piotr Pryga 131c089aaf Bluetooth: Controller: llcp: Fix wrong eff time calc if PHY changed
If there is a PHY change on a connection it may happen that effective
RX and TX time changes also. That change is applied after an instant.

Implemented handling of effective time calculation is based on the
maximum PDU length, new PHY and local (default) maximum TX or RX time.

The maximum TX value is set to default one that corresponds to PHY 1M
during the Controller initialization. It can be updated by host to other
value. By default Zephyr Host updates it to max possible TX time for all
supported PHYs. If PHY CODED is enabled, it is the longest possible TX
duration 17040 us.

The maximum RX value is set to default during connection creation.
In case of use of legacy advertising, the value is also related with
PHY 1M. It can be updated by data length extension procedure.

If the maximum RX value is set to some value and there is a change
of a PHY to one that requires more time to send a PDU with the same
length, then the maximum RX value is wrongly calculated.

Function pu_calc_eff_time returns a value that is the default_time
argument. The problem is that the default_time should be adjusted
to new maximum RX time required for a new PHY.

To solve that there should be an evaluation of a new maximum RX and
TX time based on new PHY.

The commit adds missing evaluation.

The problem occurred in DF tests that check collision mitigation
between PHY update control procedure and CTE request control procedure.

There was missing CONFIG_BT_CTLR_PHY_CODED option in CTE request
unit tests. The code was working because the ULL implementation of
PHY change control procedure does not verify if PHY CODED is supported.

When missing support was enabled, tests showed wrong evaluation of
maximum RX time. It also unveiled error in CTE request unit tests
implementation. The default_tx_time was set to wrong value 2120 us
as if PHY CODED was not supported. To fix it, the value was changed
to PDU_DC_PAYLOAD_TIME_MAX_CODED.

There was also added a mock for a feature exchange procedure done
during unit tests setup step. That allows to correctly calculate
maximum TX time by ull_dle_max_time_get function.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-26 16:29:10 +02:00
Vinayak Kariappa Chettimada 59eef60665 Bluetooth: Controller: Fix filter accept list and privacy default
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-26 12:26:43 +02:00
Francois Ramu 9488727292 tests: drivers: uart stm32 run uart_async api on f746 nucleo
This sets the dts of dma for using the uart 6 asynch api.
The stm32f746 has a dma V1 with request 5 for Tx/Rx usart6
The Tx&Rx pins (PG14, PG9) of the usart6 are connected
on the nucleo_f746zg board to pass the test
The CONFIG_DCACHE=n must also be set to disable Dcache.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-05-25 11:38:05 -07:00
Francois Ramu 169bf0f612 tests: drivers: uart stm32 run uart_async api on f767 nucleo
This sets the dts of dma for using the uart 6 asynch api.
The stm32f767 has a dma V1 with request 5 for Tx/Rx usart6
The Tx&Rx pins (PG14, PG9) of the usart6 are connected
on the nucleo_f767zi board to pass the test
The CONFIG_DCACHE=n must also be set to disable Dcache.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-05-25 11:38:05 -07:00
Achatzi Julian 90236b0650 fs: fcb: Make FCB work with sectors larger than 16K
Enhance FCB to also work with sectors larger than 16K and
to handle larger flash alignment constraints correctly.

use fcb_len_in_flash when setting the offset of the data
and use buffers sizes of at least the alignment value.

The test in fcb_test_append_to_big has been altered, as it
would otherwise not come to a data length which fits the
fcb on sectors larger than 16K.

Closes: https://github.com/zephyrproject-rtos/zephyr/issues/45345

Signed-off-by: Achatzi Julian <jachatzi@baumer.com>
2022-05-25 14:57:45 +02:00
Fabio Baltieri 67a0f95aed dts: fix a bunch of odd partition values dts entries
Fix various board fixed-partition definitions where the devicetree cell
has been defined oddly, such as 9 nibbles (which makes no sense since
the cells are 32 bit) or 7 nibbles where all the others are 8.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-25 14:21:04 +02:00
Marcin Niestroj 084aca1aa4 tests: socket: tls: check sendmsg() behavior for datagrams
Datagrams (for DTLS connection) need to be sent using single API call to
mbedTLS and should not result in sending each fragment in a separate
datagram. Check if that is the case, so allow only single fragment data to
be sent and expect an error when multiple fragments were passed to
sendmsg().

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-05-25 14:20:09 +02:00
Yuval Peress 52292da328 ztest: migrate error_hook tests to new API
Update the tests to use the new ztest API.

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Yuval Peress 50fe971617 ztest: add userspace tests to base tests
Add a test that verifies that ZTEST_USER is actually being run in
user context.

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Yuval Peress 86cadf9283 ztest: Fix userspace ztests in new API
Update the new API to use K_USER as the flags for both
CONFIG_USERSPACE and CONFIG_TEST_USERSPACE. Also, fix the linker
script to properly include the suites, tests, and rules.

Fixes #44108

Signed-off-by: Yuval Peress <peress@google.com>
2022-05-25 11:20:13 +09:00
Francois Ramu aab52048f1 tests: drivers: watchdog testing on stm32 iwdg and wwdg
Configure the testcase.yaml to execute watchdog testcase
wdt_basic_api on each IWDG and WWDG on all the stm32 boards
With two generic stm32 .overlay files as extra config :
one wdg is tested when the other is disabled.
Removing from board overlay.
Giving the list of boards else non-stm32 ones could try building

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-05-24 08:55:16 -07:00
Guo Lixin 1160994dfb tests: error_hook: remove filter and define testcases in yaml file
1.Remove filter to allow platforms(e.g. qemu_x86) supporting
CONFIG_ARCH_HAS_USERSPACE run testcases when userspace is disabled.

2.Define all testcases in the yaml for consistency and issue parsing
them during setup.

Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
2022-05-24 08:54:49 -07:00
Lukasz Majewski 5a8dff59a5 stm32: Add CONFIG_DCACHE=n to stm32h7 uart API tests
As now the CONFIG_NOCACHE_MEMORY is not responsible for controlling the
data cache on STM32H7 SoC, the CONFIG_DCACHE=n must be set explicitly
to preserve previous behavior as UART driver is not using no-cache
buffers.

Considering the above comment, the CONFIG_NOCACHE_MEMORY can be safely
removed.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2022-05-24 08:47:20 -07:00
Mahesh Mahadevan a8c7f82510 tests: counter: Fix test_multiple_alarms in counter_basic_api
Skip the test_multiple_alarms() test when the settop value is
not supported. This is to avoid the case where wrap around
take a long time thereby causing test failures

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2022-05-23 08:38:59 -05:00
Yinfang Wang e19fd4d3fa tests: fpu_sharing: Fix the skipped testing on acrn_ehl_crb
acrn_ehl_crb itself supports fpu_sharing.
Enable the fpu_sharing testing on acrn_ehl_crb.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-05-20 19:24:54 -07:00
Ruibin Chang bc2f83f11c tests/kernel/sched/schedule_api: don't break the test if not divisible
When test tests/kernel/sched/schedule_api, it shows "ASSERTION FAIL:
timeslice in ticks much be divisible by two", then break and fail
the test.

Fixes #44887.

On board it8xxx2_evb, it can pass schedule_api test without
the assertion, so I add the floating part back to half_slice_cyc
when the timeslice in ticks can't be divisible by two.
After change, the time slice will be:
1.slice_ticks = (200x8192+999)/1000 = 1639 (not changed)
2.before add the deviation (not handle the floating part):
half_slice_cyc = (1639/2) * (32768/8192) = (819) * (32768/8192) = 3276,
after add the deviation:
half_slice_cyc = 3276 + (32768/8192/2) = 3278,
and it's equal (1639/2) * (32768/8192) = 3278.

Verified by test pattern:
west build -p always -b it8xxx2_evb tests/kernel/sched/schedule_api

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2022-05-20 19:23:45 -07:00
Andy Ross 4b9a8a8471 tests/kernel/common: Extend nested_irq_offload case to do a context switch
Bug #45779 discovered an edge case with nested interrupts on Xtensa
where they might select an incorrect thread context to return to
instead of the (mandatory!) return to the outer interrupt context.

Cleverly adjust the nested_irq_offload to exercise this.  It now
creates a thread that it knows it will interrupt, then suspends that
thread from within the inner/nested interrupt.  This guarantees that
_current will be different on exit from the second interrupt, which is
the case that tripped up Xtensa.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:37:59 +02:00
Krzysztof Chruscinski 2a2856e88e tests: kernel: workq: work: Fix potential race in the test
Test was setting up timer for 1 system tick and then work was
cancelled. It was assumed that work will be cancelled before
timer expires. This is the case for low frequency system clock
(e.g. qemu targets using 100Hz) but there are cases when system
clock has higher frequency (32kHz on nRF). In that case, timer
was occasionally expiring before cancellation and test was
randomly failing.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-20 12:37:18 +02:00
Andy Ross c64ac967a8 tests/kernel/fatal: Work around historical API misuse
This test was written to do a k_oops() in the main thread.  That's an
essential thread, and aborting it is actually a system panic now.  The
test was written contra the docs on this, but it worked fine for
years.

Just reflag the thread as a simple workaround rather than trying
anything fancy. This is a very simple test.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:34:30 +02:00
Andy Ross fb613594c7 kernel/sched: Panic on aborting essential threads
Documentation specifies that aborting/terminating/exiting essential
threads is a system panic condition, but we didn't actually implement
that and allowed it as for other threads. At least one app wants to
exploit this documented behavior as a "watchdog" kind of condition,
and that seems reasonable.  Do what we say we're supposed to do.

This also includes a small fix to a test, which seemed like it was
written to exercise exactly this condition.  Except that it failed to
detect whether or not a system fatal error was actually signaled and
was (incorrectly) indicating "success".  Check that we actually enter
the handler.

Fixes #45545

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-05-20 12:34:30 +02:00
Andries Kruithof c2e07a304b Bluetooth: controller: llcp: send correct collision code
Upon collision either the error code for different procedure
collision or same procedure collision must be transmitted,
which is fixed in this PR. Previously always the error code
for same procedure collision was sent

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-20 10:29:46 +02:00
Piotr Pryga b9dcc3d4e4 tests: Bluetooth: df: Add missing conn handle assignment
There was missing assignment to a global variable that stores
connection handle. The value was always the same, hence it test
were not failing. The value was passed over from setup state
done for other tests. This change makes sure there is always
correct handle stored in global variable.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga 5922b211c3 tests: Bluetooth: df: Add missing peer supported feature information
There was missing information about supported CTE response feature
by peer device. That caused a test_set_conn_cte_req_enable to fail.
The test expected that peer device supprots CTE response.

The missing information is added in a common code responsible for
connection object preparation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga f0e456dc50 tests: Bluetooth: df: Fix wrong max antenna switch pattern len config
Due to change in Kconfig CONFIG_BT_CTLR_DF_MAX_ANT_SW_PATTERN_LEN
the Kconfigs in tests were wrong and tests were not building.
The commit sets the max antenna switch pattern length to actual
maximum value.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga f35b22a541 tests: Bluetooth: llcp: cte_req: remove invalid rsp test
There is a test that verifies a behavior of CTE request control
procedure if receives LL_UNKNOWN_RSP. The expected behavior
is to terminate connection if that is response handling is
not implemented by a command. Other unexpected responses are
treated as new remote control procedures.

The CTE request has implemented handling of LL_UNKNOWN_RSP,
hence this particular test is no longer valid.

There is still open question how to handle other unexpected
reposne PDUs while waiting for LL_CTE_RSP. That is not defined
by BT 5.3. Core specification and not decided by community.

The test is removed to because it fails and blocks CI.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga 3664e6ca68 tests: Bluetooth: Add missing NTF release
There were couple of test cases where Host notification object
was not released. The commit adds missing release calls.

Also commnets related with check if RX queue is empty were
changed to describe what is verified then.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga 0dfb5fc5c8 tests: Bluetooth: cte_req: Enable not used test case
There was a test case that was never executed. It was not
added to a test suite in test_main. The commit adds the
test case.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Piotr Pryga d6dc5bd282 tests: Bluetooth: cte_req: Add tests for handling LL_UNKNOWN_RSP
Add test that verify correct behavior of the CTE request procedure
in case of reception of LL_UNKNOWN_RSP PDU from peer device.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-19 13:21:58 +02:00
Robert Lubos f49ed7a539 tests: net: socket: Add test to verify POLLOUT functionality
Add test which verifies that POLLOUT is reported correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Nicolas Pitre 92409f36de riscv: drop user stack guard area when using separate privileged stacks
A separate privileged stack is used when CONFIG_GEN_PRIV_STACKS=y. The
main stack guard area is no longer needed and can be made available to
the application upon transitioning to user mode. And that's actually
required if we want a naturally aligned power-of-two buffer to let the
PMP map a NAPOT entry on it which is the whole point of having this
CONFIG_PMP_POWER_OF_TWO_ALIGNMENT option in the first place.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +02:00
Nicolas Pitre 6051ea7d3c riscv: clarify stack size and alignment parameters
The StackGuard area is used to save the esf and run the exception code
resulting from a StackGuard trap. Size it appropriately.

Remove redundancy, clarify documentation, etc.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-05-18 10:54:53 +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
Tom Burdick 012836aeef tests: hda_log: cav15 timeout fixes
Fixes issues caused by the hda_log test for cavs15 caused by ipc
messaging issues. Wait for the ipc message to complete immediately after
sending it.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-05-17 11:12:57 -05: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
Huifeng Zhang 265080277c tests: kernel: semaphore: fix mutual exclusion test issue
Mutual exclusion test assume that the excution order of two threads like
this:
    mutual_exclusion1 -> mutual_exclusion2 -> mutual_exclusion1 ...

but some times the excution order of two threads would be this:
    mutual_exclusion1 -> mutual_exclusion2 -> mutual_exclusion2 ...

This patch increase the loop cycle, add a variable 'tmp' to store the
value of 'critical_var' before operating it.

Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
2022-05-17 11:45:16 +09:00
Jaxson Han 74d61fe744 tests: kernel: semaphore: sys_sem: Fix coherence issue
The issue is caused by multiple threads which have taken the semaphore
to increase or decrease the normal count variable. Change its type with
atomic_t.

Signed-off-by: Jaxson Han <jaxson.han@arm.com>
2022-05-17 11:45:16 +09:00
Yinfang Wang dffe3508dc tests: fpu_sharing: Fix the skipped testing on ehl_crb
ehl_crb itself supports fpu_sharing.
  Enable the fpu_sharing testing on ehl_crb.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
2022-05-16 22:42:49 -04:00
Vinayak Kariappa Chettimada f755550ec0 samples: Bluetooth: Remove explicit Ext and Periodic Adv Kconfig enable
Remove the explicit enable of Extended and Periodic
Advertising support in Controller, the feature is no
longer experimental in the Controller and is now enabled
by default when application uses them by enabling as
Host feature.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-16 18:25:14 +02:00
Sjors Hettinga c3158804d4 tests: net: socket: tcp: Add test to validate obstructed close
When there is no response from the server, a client side close
is obstructed, it should terminate and clean the context. This
tests breaks the connection after the accept and validates
this behavior.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-16 16:55:51 +02:00
Stephanos Ioannidis b744130735 tests: timer_monotonic: Use volatile for timing variables
This commit adds the `volatile` qualifier to the timing variables, in
order to ensure that the compiler does not try to optimise the test in
a way that can affect the execution time measurements.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-05-16 09:43:52 -04:00