Commit Graph

10680 Commits

Author SHA1 Message Date
Jonathan Rico 931a089e2c Bluetooth: host: invalidate the RPA when starting legacy adv
This fixes the failure to use a resolvable private address in this
scenario.

1. call `bt_le_oob_get_local`, will generate and mark RPA as valid
2. start connectable adv w/ IDENTITY bit
3. start connectable adv w/o IDENTITY
4. RPA is not set (in `bt_id_set_private_addr`) because RPA
   is still marked as valid

When EXT_ADV is enabled and the controller supports it, a different code
path is taken that doesn't have this issue.

Unconditionally invalidating the RPA when starting advertising works around
this issue.

Fixes #56326

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-06-17 07:36:58 -04:00
Marc Desvaux d5123bfe21 tests: drivers: i2c: i2c_target_api add nucleo_f207zg
Adds necessary overlay nucleo_f207zg in i2c_target_api test case
to enables the board.

Signed-off-by: Marc Desvaux <marc.desvaux-ext@st.com>
2023-06-17 07:35:43 -04:00
Marc Desvaux c3690a7d62 tests: drivers: i2c: i2c_target_api add nucleo_f207zg
Adds nucleo_f207zg in i2c_target_api test case
to enables the board.

Signed-off-by: Marc Desvaux <marc.desvaux-ext@st.com>
2023-06-17 07:35:43 -04:00
Donatien Garnier 477dd86b78 Bluetooth: Host: Add sending L2CAP data from connection callback test
Add BabbleSim test to make sure data can be sent immediately upon
connection from the L2CAP channel connection callback

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-06-17 07:33:11 -04:00
Florian Grandel b224a099fd net: l2: ieee802154: standardize RSSI value
The RSSI value in net_pkt (net_pkt_cb_ieee802154.rssi) was used
inconsistently across drivers. Some drivers did cast a signed dBm value
directly to net_pkt's unsigned byte value. Others were assigning the
negative value of the signed dBm value and again others were offsetting
and stretching the signed dBm value linearly onto the full unsigned byte
range.

This change standardizes net_pkt's rssi attribute to represent RSSI on
the RX path as an unsigned integer ranging from 0 (–174 dBm) to 254 (80
dBm) and lets 255 represent an "unknown RSSI" (IEEE 802.15.4-2020,
section 6.16.2.8). On the TX path the rssi attribute will always be
zero. Out-of-range values will be truncated to max/min values.

The change also introduces conversion functions to and from signed dBm
values and introduces these consistently to all existing call sites. The
"unknown RSSI" value is represented as INT16_MIN in this case.

In some cases drivers had to be changed to calculate dBm values from
internal hardware specific representations.

The conversion functions are fully covered by unit tests.

Fixes: #58494

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-06-17 07:16:32 -04:00
Théo Battrel 14200f82db Bluetooth: Tests: New bsim test for ID
Add a new BabbleSim test checking that the value of the Bluetooth
identity stored in the settings is correct.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-16 07:57:46 -04:00
Anas Nashif 9f37ae902b tests/samples: set ram/rom limits on some samples/tests
Increase RAM requirements for some test, we have many exotic platforms
failing to link due to the size of the test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04:00
Anas Nashif b835b02136 tests: cleanup metadata and filtering
- Add integration_platforms to avoid excessive filtering
- Make sure integration platforms are actually part of the filter
- Fix some tags and test meta data

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-13 09:38:27 -04:00
Pavel Vasilyev de61b25b83 tests: bluetooth: mesh_shell: Print correct command for provisioning
Provisioning commands were moved under `mesh prov` subcommand.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-13 07:05:21 -04:00
Christopher Friedt bfa0a87277 tests: posix: pthread_pressure: enable pthread barrier in twister
In some cases, when GitHub CI is running several Qemu processes,
each with heavy loads, SMP tests have shown some flakiness. This
exhibits itself as something like

```
... pthread_pressure on qemu_riscv32 failed (Timeout)
```

That is actually not at all limited to POSIX or any particular
architecture, but is mainly to do with the host scheduler and
perhaps memory barrier operations being lost in ISA translation
by Qemu.

Collectively, we can refer to these issues as "scheduler noise".

To reduce scheduler noise in the `pthread_pressure` testsuite,
enable `CONFIG_PTHREAD_CREATE_BARRIER` in `testcase.yaml`.

Note: end-users will likely not experience the need to enable
this in `prj.conf`. E.g. the following basic test demonstrates
0 failures locallly.

```
TEST=tests/posix/pthread_pressure
twister --build-only -T $TEST &>/dev/null
FAIL=0
for ((i=0; i < 100; i++)); do
  echo "Run $((i+1))/100"
  twister --test-only -T $TEST &>/dev/null
  if [ $? -ne 0 ]; then
    FAIL=$((FAIL+1))
    echo "Failed $FAIL times"
  fi
done
echo "Failure Rate: $((FAIL))/100"
```

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-12 14:06:10 -04:00
Andrzej Głąbek 4d511cfb6a tests: timer_api: Decrease tick rate for nRF RTC timer
The default tick rate for the nRF RTC timer is 32768 Hz, so one tick
is ~30 us. This turns out to be too little for the following loop
executed in user mode on the Network core in nRF5340:
```
	do {
		t0 = k_uptime_ticks();
		rem_ticks = k_timer_remaining_ticks(&remain_timer);
		t1 = k_uptime_ticks();
	} while (t0 != t1);
```
The time between the two calls to `k_uptime_tick()` is there always
above 30 us, so the loop never ends.

This patch decreases the tick rate for all nRF platforms because on
other nRf SoCs the time mentioned above is also close to 30 us and
apparently changes in code completely unrelated to this test affect
execution time of system calls in the above loop - the test started
to fail after commit 0014dd05f0 that
changes fdtable was merged and if `fdtable.c` is for example just
temporarily excluded from the build, the test passes.

The root cause of the problem seems to be related to user space
handling and this should to be investigated further. This patch
is applied only to allow this test to pass for the time being.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-06-12 14:04:56 -04:00
Andrzej Głąbek a874fddadd tests: timer_behavior: Use bigger drift tolerance for nRF RTC timer
Use 13% instead of the default 10% when the nRF RTC timer is used
so that the allowed drift is at least one tick long (~122 us in
this case).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-06-12 14:04:42 -04:00
Carles Cufi 22f73992b2 Bluetooth: Rework the HCI header set
In order to have clean, self-contained HCI headers that do not have any
dependencies towards the Host or any other part of the system (except
types), reorganize the headers in the following way:

- Split out the macros and structs from hci.h to a new hci_types.h
- Merge the existing hci_err.h into the new hci_types.h

Fixes #58214.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Emil Gydesen b0d6437653 Bluetooth: Audio: Shell: Increase number of streams for unicast client
Increase CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT to match
CONFIG_BT_ISO_MAX_CHAN.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:59 -04:00
Emil Gydesen 9ed72eb0e6 tests: Bluetooth: CAP: BSIM: Set initiator as d=0 and acceptor as d=1
Typically the client is the first device in our babblesim tests, so
reordered the initiator and acceptor for the CAP tests to conform to
that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Emil Gydesen b635a47c70 tests: Bluetooth: CAP: Add bsim test for unicast_audio_cancel
Add test of the unicast audio cancel that can cancel any pending
procedures. This is done by adding a new blocking behavior in the
cap acceptor.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-10 05:16:39 -04:00
Christopher Friedt d9bae7ce65 tests: posix: improvements to pthread_pressure test
* allow `qemu_cortex_a53`
* disallow `qemu_leon3
* remove `TEST_DURATION_S` range
* additional report formatting

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-09 12:27:04 -04:00
Christopher Friedt f35fb33b94 posix: pthread: reimplement pthread_barrier using zephyr objects
Previously pthread_barrier_t was implemented in terms of wait
queues and internal scheduler functions.

This introduced some obstacles and inconsistency. In order
to be more consistent, rely only on Zephyr's public API and
reuse as many concepts as possible.

Deprecate `PTHREAD_BARRIER_DEFINE()` since it's non-standard.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-09 12:27:04 -04:00
Carlo Caione edd3437826 riscv: Rename Kconfig symbol to *_PRIVILEGED
Rename SOC_FAMILY_RISCV_PRIVILEGE to SOC_FAMILY_RISCV_PRIVILEGED because
the spec is "privileged".

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-09 11:46:29 -04:00
Emil Gydesen 8eaeb73753 tests: Bluetooth: Split CAP initiator tests to unicast and broadcast
Split the cap_initiator_test.c to two new files
cap_initiator_broadcast_test.c and
cap_initiator_unicast_test.c as the two barely had any
common functionality, and the file was getting too large.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-09 11:42:39 -04:00
Francois Ramu 433114edca tests: drivers: dac loopback on stm32 boards fix pinout
Change the pinout for ADC/DAC loopback testing on the stm32 boards
nucleo_l073rz: adc_in0_pa0/dac_out1_pa4 --> A0 to A2 on arduino CN8
nucleo_g071rb: adc1_in0_pa0/dac1_out1_pa4 --> A0 to A2 on arduino CN8
stm32l562e_dk: adc1_in13_pc4/dac1_out1_pa4 --> A2 to A4 on arduino CN19
Adjust the ACQuisition time to the MAX value because the default (=0)
is too low for several boards.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-06-08 11:48:22 -04:00
Carles Cufi bcd0e8c175 tests: bluetooth: tester: Fix ATT max attr size assert
ATT attributes can be up to 512 bytes long, so the comparisong needed
fixing.

See spec v5.4, Vol 3, Part F, 3.2.9.

Fixes #57930.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-08 09:34:10 -04:00
Francois Ramu c908aead77 tests: drivers: dac channel structure has a buffered parameter boolean
Add the '.buffered' field to the dac_channel_cfg structure
when testing the DAC.
This boolean parameter is initialised to 'true' to PASS the test.
It follows the https://github.com/zephyrproject-rtos/zephyr/pull/57730
Also changed for the samples/drivers/dac

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-06-08 09:33:11 -04:00
Henrik Brix Andersen 98ba1175fd tests: drivers: can: api: fix test_set_timing_data_while_started test
Change the test_set_timing_data_while_started test to actually attempt to
set the data phase timing parameters instead of attempting to set the
nominal/arbitration timing parameters.

Update test descriptions to explicitly mention data phase timing.

Fixes: #59046

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-06-08 06:50:14 -04:00
Vinayak Kariappa Chettimada 273e233d60 tests: bsim: Bluetooth: Fix BIS test ISO Tx Buffers in Controller
Fix BIS test for ISO Tx Buffers in Controller to be 2 for
ISO TX MTU size of 502 bytes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:48 -04:00
Vinayak Kariappa Chettimada 5f38c4ba71 Bluetooth: Controller: Fix Tx ISO SDUs dropped due to strict SN check
Introduce a Kconfig BT_CTLR_ISOAL_SN_STRICT to relax the Tx
ISO Data SDUs being dropped due to strict check of sequence
numbers in ISOAL, i.e. dropped when ISO Data SDUs are
delayed from upper layer with respect to the current
payload number in the ISO radio events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 06:47:25 -04:00
Vinayak Kariappa Chettimada 54aa6f1075 Bluetooth: Controller: Fix ISOAL sink create role for ISO Receiver
Fix ISOAL sink create role for ISO Receiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-08 12:25:31 +02:00
Théo Battrel 24ea25827c Bluetooth: Tests: Check CCC Update
Check that if a bonded peer subscribed to a CCC, a non-bonded peer with
the same address cannot update the CCC.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-08 04:10:58 -04:00
Théo Battrel f5ff886260 Bluetooth: Tests: Remove usage of `BT_DEBUG_LOG`
Remove usage of Kconfig symbol `CONFIG_BT_DEBUG_LOG` from tests. It has
been deprecated since this PR:
https://github.com/zephyrproject-rtos/zephyr/pull/56183

The Kconfig symbols has been replaced by `CONFIG_LOG=y` on most of the
cases. Or it has been removed when not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-07 13:56:55 -04:00
Evgeniy Paltsev e9b0b6ae07 test: ARC: skip div-by-zero test in case of SW div implementation
The SW div implementation from libgcc doesn't handle division by
zero case, so the HW exception isn't triggered.

So, skip this test case (as we are already doing for some other
ARC targets).

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2023-06-07 05:46:40 -04:00
Anas Nashif 7eea4b514a tests: mcumgr: update tags
add mcumgr as a tag for mcumgr tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-07 05:41:31 -04:00
Nirosharn Amarasinghe 97935bb0dc tests: Bluetooth: controller: updated ISO-AL tests for lost SDUs
-- Updated test cases to include missing / lost SDUs.
-- Included tests for receiving only framed padding PDUs.
-- Removed tests linked to sink and source configuration params as these
   were unused and removed.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Nirosharn Amarasinghe f0434254fb tests: bluetooth: controller: Release SDU as missing RX unf. padding
Testing:
-- Receiving only padding PDUs for an SDU
-- Receiving leading padding PDUs (not an expected use case)

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-06-06 13:34:45 +02:00
Anas Nashif 1a526a63c7 tests: ignore benchmark on some qemu platforms
Do not run benchmarks on some special qemu platforms. Those were
previously ignored, but due to tag changes, they started running again.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-05 20:53:02 -04:00
Carlo Caione 7a043d6f19 tests: arm_runtime_nmi: Add barriers
Testing NMI on emulated QEMU platforms brings some interesting and wrong
results like:

  START - test_arm_runtime_nmi
  Trigger NMI in 10s: 0 s
  Trigger NMI in 10s: 1 s
  Trigger NMI in 10s: 2 s
  Trigger NMI in 10s: 3 s
  Trigger NMI in 10s: 4 s
  Trigger NMI in 10s: 5 s
  Trigger NMI in 10s: 6 s
  Trigger NMI in 10s: 7 s
  Trigger NMI in 10s: 8 s
  Trigger NMI in 10s: 9 s
  NMI triggered (test_handler_isr)!
      Assertion failed at ... arm_runtime_nmi_fn_test_arm_runtime_nmi:
        (nmi_triggered is false)
  Isr not triggered!

where the NMI handler is correctly called, see `NMI triggered`, but the
assert still fails on `nmi_triggered` being false.

This is due to a limitation in the emulation but also in the test not
being strictly architecturally compliant (you need a DSB;ISB sequence
after writing to SCB).

Add the proper barriers after writing to `SCB->ISCR` to make it
compliant and making it pass on QEMU as well.

Also reduce the timing to 2 sec.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-06-05 20:20:54 -04:00
Christopher Friedt 2d4874dd65 tests: posix: stress test for pthread_create and pthread_join
Recently, a race condition was discovered in `pthread_create()`
and `pthread_join()` that would trigger an assertion in
`kernel/sched.c` of the form below.
```
aborted _current back from dead
```

This was mainly observed in Qemu. Unfortunately, Qemu SMP
platforms exhibit a real and measurable "scheduler noise"
which makes testing rather difficult.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 19:48:39 -04:00
Christopher Friedt 15ea0412e4 tests: posix: common: add a small delay in pthread_descriptor_leak
The `aborted _current back from dead` error may appear in this
particular test under Qemu (and in particular Qemu SMP) systems.

A small delay between `pthread_create()` and `pthread_join()`
is sufficient to mitigate the issue.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 19:48:39 -04:00
Christopher Friedt d95ecab47e Revert "tests: posix: pthread: init pthread_attr_t on each iteration"
This reverts commit 7c17bda3c2.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-05 19:48:39 -04:00
Théo Battrel cb48626399 Bluetooth: Test: Update `ccc_store` bsim test
Update `ccc_store` bsim test to remove the 'expected failure'. The issue
being fixed in the following commit.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-05 13:54:37 -04:00
Aleksander Wasaznik 75bb62ad24 Bluetooth: Host: Test: `bt_addr_from_str`
Some basic tests for `bt_addr_from_str`. This proves a bug.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-05 08:31:06 -04:00
Declan Snyder 4c8b18920a tests: posix headers: RT1015 increase RAM
RT1015 needs more RAM to do this test, increase size of Zephyr SRAM
by switching zephyr,sram to the OCRAM allocation of the FLEXRAM.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-06-05 10:35:38 +02:00
Alvaro Garcia 4d854a562c drivers: fixed div by zero when reading max17048
Avoid divsion by zero when current rate is zero

Signed-off-by: Alvaro Garcia <maxpowel@gmail.com>
2023-06-02 18:51:25 -04:00
Daniel DeGrasse d5792abbcf tests: drivers: adc: adc_dma: increase sampling interval for MCUX ADC16
Increase hardware sampling interval to 30ms for MCUX ADC16. The ADC
callback in the repeated_samplings test takes roughly 27ms to execute,
so a sampling frequency of this interval still allows the ADC test to
verify the ADC is being sampled at a given interval, while avoiding the
pitfalls that result from a kernel timer shorter than the duration the
ADC callback takes to run.

Fixes #58467

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-06-02 18:49:22 -04:00
Christopher Friedt 386f6c7006 tests: posix: eventfd: add stress test
This test simply counts how many times `eventfd_read()`
and `eventfd_write()` can be called on an
`eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK)` file
descriptor.

Prior to the recent changes in `eventfd`, we were seeing
approximately < 1000 writes / s. However, the previous
`eventfd` implementation would fail this test with the
result that the number of successful reads was far greater
than the number of successful writes.

This should be impossible, and with the recent `eventfd`
changes that was fixed. Additionally, we are seeing an
increase in over 40x for non-blocking eventfd reads and
writes.

```
START - test_stress
I: BOARD: qemu_riscv64_smp
I: TEST_DURATION_S: 5
I: UPDATE_INTERVAL_S: 1
I: avg: 48537 reads/s
I: avg: 48575 writes/s
PASS - test_stress in 5.002 seconds
```

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt d370361fe5 tests: eventfd: blocking read-write test for deadlock bug
Previously, the prototypical use case for `eventfd()` was not
possible in Zephyr due to a deadlock associated with the
`fdtable.c` `k_mutex`.

The prototypical use case for `eventfd()` is to make a
blocking call to `eventfd_read()` from one thread, and then
from another thread, call `eventfd_write()` to "wake up" the
reading thread.

This additional test case ensures that Zephyr supports the
prototypical `eventfd()` use case.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Christopher Friedt cf7c404aeb tests: posix: eventfd: use reopen in test_write_then_read
Use `reopen()` in one additional place in the eventfd
testsuite.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-02 18:45:46 -04:00
Peter Mitsis d26d3f9fd4 test: Change loop calibration count initialization
The kernel/context test_timer_interrupts() test has a loop calibration
phase to estimate the number of loops needed for 1 system tick.
By initializing this calibration to 1 instead of 0, we can avoid an
edge condition where the calibration phase indicates 0 loops are
required (a case that could happen when running on a slow simulator).

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-06-02 17:43:59 -04:00
Anas Nashif 0064b6e8b6 tests: samples: cleanup test tags, add integration_platforms
Use integration platforms and sanitize tags.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-02 04:47:06 -04:00
Anas Nashif db4a5f11ea tests: add kernel tag to all benchmarks and samples
All those benchmarks are kernel related, so add the kernel tag to avoid
building them when non kernel changes are being submitted.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-02 04:47:06 -04:00
Anas Nashif fa98745a10 tests: remove linker_generator sub tests from kernel
Kernel is being built the same way for all those tests and there is not
much related to the linker generator in any of those tests. Just keep a
small set of tests to have needed coverage in the kernel.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-06-02 04:47:06 -04:00