Commit graph

12571 commits

Author SHA1 Message Date
Christopher Friedt e4b3df53dd tests: posix: pthread: identify thread ids of detached threads
Previously, the number 2 seemed to be somewhat magical. This
removes some of the mystery by labeling it.

So threads >= DETACH_THR_ID will be detached (we should not
attempt to join detached threads).

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-26 06:50:11 -05:00
Christopher Friedt dbf7003162 tests: posix + libc: qemu_x86*: use dynamic stack size of 4096
For qemu_x86 and qemu_x86_64, it would seem that
heap-allocated thread stacks, as well as thread stacks
defined via K_THREAD_STACK_ARRAY_DEFINE(), must be at least
4096 bytes in size.

Using those sizes will ensure that these tests do not
fail with stack overflows or MMU faults.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-26 06:50:11 -05:00
Christopher Friedt 77135fcbc6 posix: pthread: embed posix_thread_attr inside of posix_thread
Rather than shadowing most of the fields from pthread_attr_t
(struct posix_thread_attr) inside of struct posix_thread, just
embed the structure itself.

Additionally, use pthread_attr_init() to allocate a thread
stack and pthread_attr_destroy() to destroy a thread stack,
dramatically simplifying pthread_create().

A fair bit of rework was needed already to mitigate bitrot
issues in the testsuite. More should probably be done later.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-26 06:50:11 -05:00
Christopher Friedt 5ca0f28bb2 tests: posix: common: dedicated config for static thread stacks
The testsuite has been shifted to use dynamic thread
stacks (either statically allocated via a pool, or
dynamically allocated via the heap).

However, we definitely still need coverage for manually
specified thread stacks - but lets avoid duplicating
tests unnecessarily.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-26 06:50:11 -05:00
Christopher Friedt 5eb0bbeb54 tests: posix: pthread_attr: skip when large stack allocation fails
Rather than fail when attempting to set an extraordinarily large
pthread stack size (much larger than most Zephyr platforms have)
consider the test non-fatal and skip it.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-26 06:50:11 -05:00
Emil Gydesen 2b0e39dfa5 Bluetooth: Audio: Add bt_audio_codec unset functions
Add functions to unset, or remove, specific codec
LTV structure from codec_cfgs or codec_caps.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-26 09:43:30 +01:00
Magdalena Kasenberg 0d27dd5dd3 bluetooth: tester: Add support for CAP
Add support for CAP test cases.
Split btp_bap.c for better maintenance into unicast and broadcast.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2024-01-25 19:32:34 -05:00
Adam Wojasinski dfb6e5aa96 tests: posix: Add test cases for mq_notify()
Adds test cases testing following features:
- function error handling
- basic notification type
- thread notification type
- adding notification to non-empty queue

Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
2024-01-25 19:47:37 +01:00
Øyvind Rønningstad 223b4c372f tests: mgmt: Adapt to API changes in zcbor 0.8.0
zcbor_new_state and zcbor_tstr_put_term

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 15:09:16 +00:00
Alberto Escolar Piedras 571b647825 subsys/net/lib/lwm2m: Change how we seed the random generator
Instead of seeding the random generator from the test
itself calling into a host API, let's use the
entropy generator option to be seeded from /dev/urandom

This avoids trouble with the srandom() and time() calls
not existing depending on the chosen C library.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-25 12:28:51 +01:00
Keith Packard 4f40dd1f95 tests/strerror: Remove test for non-standard strerror_r function
Zephyr does not include this function under Rule A.4: C Standard Library
Usage Restrictions in Zephyr Kernel, hence a conforming C library need not
provide it.

Signed-off-by: Keith Packard <keithp@keithp.com>
2024-01-25 12:07:19 +01:00
Bjarki Arge Andreasen 27b0d4e3fe modem: chat: remove receive and transmit timeouts
Remove receive and transmit timeouts which are no
longer useful as the RECEIVE_READY and
TRANSMIT_IDLE events will be used to efficiently
manage timeouts between transmit/receive calls.

Then update the the in-tree drivers using the
modem_chat module to omit the process timeout
parameter.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-25 11:22:42 +01:00
Magdalena Kasenberg 62809d7581 bluetooth: tester: Enable BT_CTLR_ISOAL_PSN_IGNORE
Temporarily ignore the Tx ISO Data Packet Sequence Number use
as the tester app does not have yet a synchronization mechanism for
the sequence number and it constantly fails to send ISO data on time.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2024-01-25 09:04:02 +01:00
Alberto Escolar Piedras cf6a3824a0 tests/bsim host/privacy/peripheral: Minor fixes to allow equality check
Minor fixes in this test script to:
* Start with an empty flash even if there was a left over flash file
  on disk
* Not overwrite the simulation activity from the first part of the test
  in the second part of the test, to allow looking into the
  traffic and to allow rerunning the test in check mode, to ensure
  there is no radio activity changes when another change is done.
* Set the simulation id to something more unique (it was just
  "peripheral" before which is too easy to be repeated in another
  test)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-24 21:19:57 +00:00
Peter Mitsis 4c5a96ec65 tests: latency_measure: Configurable iterations
Updates the latency_measure benchmark to make the number of
iterations for which each test executes to be configurable.
This allows someone to make a tradeoff between accuracy
and execution time (can be useful for simulators).

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-01-24 21:48:56 +01:00
Hake Huang d744719eb8 test: dma: fix dma code-data_relocation failure on nxp rt platforms
NXP RT series DMA need use buffer in nocached area,
so only use memory region relocated is not enough.

fixing: #67053

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2024-01-24 17:07:29 +01:00
Talha Can Havadar 4ce0555d90 drivers: bmp581: Add BMP581 driver
This commit adds source and header files required for bmp581 I2C driver.
I have used bmp581_user.h to add more usage related definitions
but bmp581.h to add hardware related definitions.

Signed-off-by: Talha Can Havadar <havadartalha@gmail.com>
Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-01-24 09:32:34 -05:00
Jonathan Rico 6fa5d1e6a5 Bluetooth: L2CAP: fix net buf frags handling
Fix the handling of buffers with fragments. What seems to have been
broken is the metadata reference that was not passed to the next frag in
the chain.

Add a test to regression too.

The main user of this is IPSP.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-24 14:56:16 +01:00
Guillaume Gautier 7228642c72 tests: drivers: adc: adc_api: boards: st: use different acquisition time
Use different acquisition time for a board (WB55) that has individual
sampling register, and for another (WBA52) that have two common registers.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-01-24 12:44:59 +00:00
Cong Nguyen Huu 97f8ce83ef tests: drivers: can: api: wrap the code belong to CAN FD mode
To avoid build warnings when building non CAN FD mode

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2024-01-24 12:28:00 +00:00
Cong Nguyen Huu cc9d0d1c12 tests: drivers: can: api: add testcase for testing CANXL non RX FIFO
Add testcase for testing CANXL non RX FIFO

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2024-01-24 12:28:00 +00:00
Luca Burelli 938d3547d0 llext: move current test to a hello_world subdir
In preparation for multiple tests, move the current hello_world test
to its own subdirectory. Also, merge the llext compilation in the
parent CMakeLists.txt.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-01-24 10:44:48 +01:00
Luca Burelli 92a5e3ace7 llext: rework testcases to share common config
This patch reworks the YAML files for the llext samples and tests to
share a common restriction list. Also, using an arch-specific config
to disable the MPU for the ARM architecture only, there is no need
to duplicate the test cases per architecture.

Use this to enable the "writable" test case for the ARM architecture
and separate the "modules_enabled" case to test building as a module.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-01-24 10:44:48 +01:00
Luca Burelli 5697d25901 llext: fix test Kconfig module conditions
Make it so LLEXT_TEST_HELLO is enabled by default, and it is actually
compiled only when the config is enabled.

The check for MODULES==y and LLEXT_TEST_HELLO!=m is redundant, as the
Twister machinery already causes an error when Kconfig flags specified
in the YAML file are coerced to different values.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-01-24 10:44:48 +01:00
Seppo Takalo ec3ec8cd2a net: lwm2m: Add LWM2M_ON_INIT() macro
Add macro that allows registration of initialization functions that
are called when LwM2M engine starts.

On LwM2M engine starts up, it first executes all initialization
functions in following priority order:
1. LWM2M_PRIO_ENGINE
2. LWM2M_PRIO_CORE, this is where all LwM2M core objects are initialized
3. LWM2M_PRIO_OBJ, this is where all other objects are initialized
4. LwM2M_PRIO_APP, application initialization.

Now on the initialization phase, we could rely that certain objects have
already been registered.
For example custom objects can register callbacks to core objects.
On application phase, we can initialize sensor objects and register
their callbacks because objects have already been initialized.

This LWM2M_ON_INIT() should replace all use of SYS_INIT()
with the default CONFIG_KERNEL_INIT_PRIORITY_DEFAULT.

Priority order is actually just alphabetical order of names, so
the order is set on a linkin phase, and we don't need any
runtime checking for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-24 10:44:28 +01:00
Vinayak Kariappa Chettimada d1e4c17e6d tests: bsim: Bluetooth: Mesh: Adjust timeout for Adv Extensions use
Adjust mesh test timing and timeout value for Advertising
Extensions use/fix in Zephyr Controller. The scanning in
Zephyr Controller is delayed when using extended scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-24 10:44:12 +01:00
Bjarki Arge Andreasen 592647cf0b tests: flash: Add erase_blocks test for flash controllers
Add test suite which tests writing to and erasing all pages,
of any size defined by the page layout.

If the test is built with MCUBOOT, the test will jump into the
application, then run write/erase/boundary tests on the
bootload partition. If MCUBOOT is not selected, the test will
target the slot1 partition instead, performing the same tests.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-23 15:22:26 +00:00
Fabio Baltieri 1dd2307b3f input: gpio_qdec: add optical encoder support
Change the gpio_qdec driver to support optical encoders.

Add a property to use for defining an arbitrary number of GPIOs for the
sensing devices (typically infrared LEDs, but could also be the
biasing for the phototransistor), and one for adding a delay between
turning those on and reading the pin status.

The infrared LEDs typically consume a non negligible amount of power, so
there's also a new idle-poll-time-us property that enables two possible
modes of operation:

- if idle-poll-time-us is zero (default) the LEDs are enabled all the
  time and the driver enters polling mode using the GPIO interrupt as
  with mechanical encoders. This is usable for mains powered devices and
  has the lowest overhead on the CPU.

- if idle-poll-time-us is non zero, then the driver polls the encoder
  all the time, turning on the LEDs just before reading the state and
  shutting them off immediately after, but when the encoder is idle it
  switches the polling rate to idle-poll-time-us to save power, and only
  polls at sample-time-us when some movement is detected.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-23 09:45:57 -05:00
Yong Cong Sin 8cfff4b48f tests: devicetree: api: align DT_IRQN test
Not sure why the `DT_IRQN` tests are tabbed, fix that.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-23 06:48:16 -05:00
Yong Cong Sin 170c659292 tests: devicetree: api: test DT_IRQ_LEVEL and DT_INST_IRQ_LEVEL
Added new test for `DT_IRQ_LEVEL` and `DT_INST_IRQ_LEVEL`.

Introduced a new `vnd.cpu-intc` compatible so that we have a
root level interrupt controller that acts as level 1
aggregator, and modified `test_intc` to be level 2 aggregator,
updated test of `DT_IRQN(TEST_I2C_BUS)` accordingly.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-23 06:48:16 -05:00
Peter Mitsis 7c5a57b87b tests: latency_measure: Fix MPU fault
Fixes an MPU fault that was occurring on some ARM platforms when
executing the events portion of the latency_measure benchmark. The
fault was tracked to an attempt by a user thread to read an MMIO
register that it did not have permissions to access.

The solution was to move the printing of the stats averages out of
the test thread and into the main thread as the main thread always
executes at kernel/supervisor level and will always have permissions
to read that MMIO register.

Fixes #67438

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-01-23 10:02:46 +01:00
Anders Storrø 93a6ee501a Bluetooth: Mesh: Add artificial beacon delay
After removing 20ms in advertiser, all subnetwork beacons are sent as high
dense packet of frames with minimal distance between them. That might
cause collisions if beacon interval on devices will coincide.

This commit adds an artificial delay between each subnet advertsing
beacons.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-01-23 10:02:00 +01:00
Dawid Niedzwiecki ea630294d3 logging: add flag to skip source info
Add a flag to skip printing the source info.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-01-22 14:05:11 -05:00
Seppo Takalo f96c766fd8 tests: lwm2m: Rename engine to observation
"engine" directory contained tests for observation
so rename it.
There is separate "lwm2m_engine" directory that contains
tests for the engine itself.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-22 18:22:43 +01:00
Yong Cong Sin 8262766a0a tests: lib: devicetree: api: fix reg addr mismatch for test-mtd@ffeeddcc
Fix unit address and first address in 'reg' (0x0) don't match
for /test/test-mtd@ffeeddcc.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-22 15:49:53 +00:00
Henrik Brix Andersen 0875a752c1 tests: drivers: can: api: fix uninitialized variable warning.
Fix a warning about unitialized variable. The test will be skipped in this
code path.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-22 13:09:09 +01:00
Bjarki Arge Andreasen 140a510030 tests: build_all: modem: Remove net tag and clean up
Remove the net tag, allowing the modem driver tests to be built
for PRs, and limit the scope of the test suite to only build
for select emulated 32 and 64 bit boards.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-22 12:59:59 +01:00
Peter Mitsis 5573b20ec6 tests: latency_measure: tweak frdm_k64f config
The FRDM K64F board runs at 120 MHz and has a 24 bit timer.
According to its timer driver, its MAX_TICKS (which comes into
play for a tickless kernel) is calculated as ...
     CYC_PER_TICK = 120 MHz / ticks per second
     MAX_TICKS = (COUNTER_MAX / CYC_PER_TICK) - 1

To achieve a minimum value of MAX_TICKS=1, ticks per second must
be set to at least 15. Experimentation has shown that setting the
number of ticks per second below this threshhold on a tickless
kerenl leads to unreliable timestamps.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-01-22 12:59:45 +01:00
Peter Mitsis 070b07efc1 tests: latency_measure: Remove prj_user.conf
Moves the enablement of userspace from the project configuration
file to testcase.yaml.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-01-22 12:59:45 +01:00
Peter Mitsis d3a3d63afb tests: latency_measure: Increase verbosity of summary lines
Feedback from the previous summary line change has been that it
had become more difficult for people to parse and understand what
is being tested/benchmarked when the description consisted of
just using a terse tag. To improve the situation a more human
oriented description has been added to follow that tag so that
not only can tools still parse on the tag, but people can use
both tag and the extra description to understand the test/benchmark.

Summary lines for each test now consist of the following:
    1. A terse tag (for tools to parse)
    2. A more human oriented description.
    3. Number of cycles.
    4. Number of nanoseconds.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2024-01-22 12:59:45 +01:00
Emil Gydesen b857ef7f83 Bluetooth: BAP: Add ISO state callbacks
Add callbacks to the stream objects that reflects the
state of the isochronous channel. The connected callback
is called when the isochronous channel is connected, and
similarly the disconnected callback is called when it is
disconnected.

There is a special case for unicast, where if the ACL
disconnects first, then we won't get a ISO disconnect
callback. It should be assumed that the isochronous channel
is no longer valid when the BAP stream enters the idle state,
i.e. when the "released" callback is called.

The purpose of the new callbacks is to provide additional
information to the application. Especially the unicast client
can use this to determine when the stream_start function
can be called again, as there can only ever be 1 outstanding
CIS connection request at a time, but there can be multiple
GATT requests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-22 12:59:11 +01:00
Christopher Friedt 7f57d5d6eb tests: posix: timer: run tests for realtime as well
Ensure that the realtime clock may also be used with
timer_create().

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-22 06:48:55 -05:00
Kamil Piszczek c16d9699a3 tests: bsim: bluetooth: host: gatt: general: improve conn ref handling
Improved the connection reference handling in the BabbleSim test
project in the Bluetooth Host category.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-01-22 10:32:41 +00:00
Christopher Friedt 0bed5dd459 tests: posix: semaphore: speed up named semaphore test
Reduce N_LOOPS from 999 to 32 by default and use a Kconfig
to encode it as CONFIG_TEST_SEM_N_LOOPS.

Running TESTSUITE semaphore
===============================================================
START - test_named_semaphore
 PASS - test_named_semaphore in 5.685 seconds
===============================================================
START - test_semaphore
 PASS - test_semaphore in 5.010 seconds
===============================================================
TESTSUITE semaphore succeeded

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-22 09:49:39 +00:00
Tomas Galbicka 554f2ba08e tests: mbox: Add test for mbox with data transfer
This commit adds extended test for mbox driver with
data transfer to verify correct mbox functionality.

Signed-off-by: Tomas Galbicka <tomas.galbicka@nxp.com>
2024-01-22 09:48:09 +00:00
Henrik Brix Andersen 3436c93387 drivers: can: remove run-time RTR filtering, add build-time RTR filter
A growing number of CAN controllers do not have support for individual RX
hardware filters based on the Remote Transmission Request (RTR) bit. This
leads to various work-arounds on the driver level mixing hardware and
software filtering.

As the use of RTR frames is discouraged by CAN in Automation (CiA) - and
not even supported by newer standards, e.g. CAN FD - this often leads to
unnecessary overhead, added complexity, and worst-case to non-portable
behavior between various CAN controller drivers.

Instead, move to a simpler approach where the ability to accept/reject RTR
frames is globally configured via Kconfig. By default, all incoming RTR
frames are rejected at the driver level, a setting which can be supported
in hardware by most in-tree CAN controllers drivers.

Legacy applications or protocol implementations, where RTR reception is
required, can now select CONFIG_CAN_ACCEPT_RTR to accept incoming RTR
frames matching added CAN filters. These applications or protocols will
need to distinguish between RTR and data frames in their respective CAN RX
frame handling routines.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-21 11:00:31 +01:00
Luca Burelli 0747cd3358 llext: define add_llext_target() for llext compilation
This patch defines a generic function that encapsulates all the
architecture-specific machinery needed to compile llexts from source
files. Current tests are updated to use this function.

Output and source files must be specified using the OUTPUT and SOURCES
arguments. Only one source file is currently supported.

Arch-specific flags will be added automatically. The C_FLAGS argument
can be used to pass additional compiler flags to the compilation of
the source file.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-01-21 10:59:49 +01:00
Jai Arora ba7b7ffff2 posix: Adds test to check getpid() is not NULL
Adds test to check getpid() function is not NULL

Signed-off-by: Jai Arora <infolinesoni@gmail.com>
2024-01-20 12:41:28 +01:00
Jai Arora b103dece67 posix: Adds test for clock_getcpuclockid()
Adds test for clock_getcpuclockid() to
make sure clock_id is equal to CLOCK_PROCESS_CPUTIME_ID
after a successful call

Fixes #59954

Signed-off-by: Jai Arora <infolinesoni@gmail.com>
2024-01-20 12:41:28 +01:00
Martin Kiepfer 5a3f53551f drivers: display: gc9a01a: Add support for SPI display controller gc9a01a
Adding driver for GC9A01A 240x240 based LCD displays.
Should be working with GC9C01 as well (untested).

Signed-off-by: Martin Kiepfer <mrmarteng@teleschirm.org>
2024-01-20 12:40:15 +01:00