Commit graph

14120 commits

Author SHA1 Message Date
Fabian Pflug
055800ba76 net: l2: ieee802154: test association permit bit
Beacon frames can be received with association permit bit set or not,
but the correct information should be in the data given to the
application.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
2024-07-31 10:08:03 +02:00
Fabian Pflug
240223971f net: l2: ieee802154: decrease time for testcase
When trying to implement a testcase for the previous commit, an error
occoured, that stopped the test from executing.

As the tests require a full IPv6 stack, the usual router solicitation
(RS) messages will be scheduled by the net stack. To avoid conflict
with RS messages the active scan test must be kept shorter than one
second, otherwise a race condition with additional packages being
reported by the fake driver might occur.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
2024-07-31 10:08:03 +02:00
Robert Lubos
3eafc19835 tests: net: http_server: Remove harness requirement
The HTTP server tests are self-contained, they do not require network
environment to execute, hence should not specify "harness: net".

The consequence of specifying the harness was that HTTP server tests in
the CI were only built, and not executed, which doesn't make much sense.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-30 18:30:36 +01:00
Rubin Gerritsen
063cf397ed bluetooth: controller: Enable data length update in ctrl_collision test
The test expects this feature to be enabled.
We should therefore enable explicitly instead of relying on
default values.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-30 18:30:22 +01:00
Anke Xiao
ef10a9b23b tests: drivers: gpio: gpio_basic_api: add ke17z overlay file
Add frdm_ke17z_fgpio.overlay to add fgpio configuration, and
add update testcase.yml to add FGPIO driver test for frdm_ke17z
and frdm_ke17z512 platforms.
Updated ke17z512 gpio test pins to avoid conflicts with I2C pin.

Signed-off-by: Anke Xiao <anke.xiao@nxp.com>
2024-07-30 18:28:43 +01:00
Pieter De Gendt
0b453c6cdc tests: drivers: uart: uart_emul: Add device emulation test
Add an emulated UART device test case. Demonstrate using the
zephyr,uart-emul bus for passing data to an emulated implementation for a
UART device driver.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-30 18:28:17 +01:00
Pieter De Gendt
8bbb88999b tests: drivers: uart: uart_emul: Fix RX remaining check
The UART interrupt emulation test checks the wrong variable for remaining
RX bytes.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-30 18:28:17 +01:00
Pieter De Gendt
92019b1dac emul: Support UART device emulation
Add support to the existing UART emulated bus, to have a client device
emulator.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-30 18:28:17 +01:00
Rubin Gerritsen
bfc0cdc905 Bluetooth: Conditionally print out HCI error codes as strings
When developing Bluetooth applications, you typically run into
some errors. If you are an experienced Bluetooth developer,
you would typically have an HCI error lookup table in your memory.
Others might not.

This commit utilizes defines CONFIG_BT_DEBUG_HCI_ERR_TO_STR
and utilizes bt_hci_err_to_str() to print out HCI error strings
when enabled to improve the user experience.

Several alternatives where considered. This approach was chosen
as it had the best balance between readability, code size, and
implementation complexity.

The alternatives are listed below as a reference.

1. Macro defined format specifier:

```c
  #define HCI_ERR_FMT "%s"
  #define BT_HCI_ERR_TO_STR(err) (err)
  #define HCI_ERR_FMT "%d"
  #define BT_HCI_ERR_TO_STR(err) bt_hci_err_to_str((err))

LOG_INF("The event contained " HCI_ERR_FMT " as status",
	BT_HCI_ERR_TO_STR(err));
```
Advantage: Space efficient: Code size does not increase
Disadvantage: Code becomes hard to read

2. Format specifier to always include both integer and string:

```c
static inline const char bt_hci_err_to_str(err)
{
	return "";
}

LOG_INF("The event contained %s(0x%02x) as status",
	bt_hci_err_to_str(err), err);
```

Advantage: Simple to use, implement, and read,
Disadvantage: Increases code size when CONFIG_BT_DEBUG_HCI_ERR_TO_STR
is disabled. The compiler seems unable to optimize away the unused
format specifier. Note: The size increase is only present when
logging is enabled.

3. Always print as string, allocate a stack variable when printing:

```c
const char *bt_hci_err_to_str(char *dst, size_t dst_size, uint8_t err)
{
  snprintf(dst, dst_size, 0x%02x, err);
  return dst;
}

LOG_INF("The event contained %s as status", BT_HCI_ERR_TO_STR(err));
```

Advantage: Very easy to read.
Disadvantage: Printing error codes becomes slow as it involves calling
snprint.

4. Implement a custom printf specifier, for example E.

   This requires a global CONFIG_ERR_AS_STR as I assume we cannot have
   one specifier for each type of error code.
   Also, I assume we cannot start adding specifiers for each subsystem.

```c
  #define BT_HCI_ERR_TO_STR(err) (err)
  #define BT_HCI_ERR_TO_STR(err) bt_hci_err_to_str((err))

LOG_INF("The event contained %E as status", BT_HCI_ERR_TO_STR(err));
```

Advantage: Both efficient code and readable code.
Disadvantage: This requires a global CONFIG_ERR_AS_STR as I assume
we cannot have one specifier for each type of error code.
Also, I assume we cannot start adding specifiers for each subsystem.
That is, this approach is hard to implement correctly in a scalable
way.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-30 18:25:56 +01:00
Emil Gydesen
a94bfe03a4 tests: Bluetooth: Audio: Move role specific mocks files
For the LE Audio unittests there exists a few mock files
that implement mock versions, or callbacks, for some of the
roles and features tested.

These have been moved to where they are actually used,
reducing the scope of these files.

This both allows the individual tests to implement their own
versions of it, but more importantly it prevents issues when
adding tests for these roles. For example, due to the
bap_unicast_client.c mock file, it is impossible to implement
unit tests for the unicast client, as the functions are already
defined.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-30 18:25:47 +01:00
Tomi Fontanilles
48d69b4e7e tests: modem: cmux: add missing timeout param
Add the missing timeout parameter to `modem_pipe_open()` and
`modem_pipe_close()` calls.
10 seconds is the default value used in the Zephyr tree.

Fixes a regression introduced in
https://github.com/zephyrproject-rtos/zephyr/pull/74325.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-07-30 11:44:04 +02:00
Dominik Ermel
1b5f986404 tests/stream_flash: Replace one-line config overlays with extra_configs
The commit removes one-line overlay files, when copyrights excluded,
with direct Kconfig options selection inside testcase.yaml.
The overlays have been removed.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-29 14:23:11 +02:00
Miguel Gazquez
26be1da3e7 drivers: sensor: add driver for lsm9ds1 sensor
The LSM9DS1 is a system-in-package featuring
a 3D digital linear acceleration sensor, a 3D digital angular rate
sensor and a 3D digital magnetic sensor.

This driver implements only the linear acceleration sensor and the
angular rate sensor, on the I2C bus.

This driver is without trigger support.

The driver is based on the stmemsc HAL.

link: https://www.st.com/resource/en/datasheet/lsm9ds1.pdf

Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
2024-07-29 14:21:24 +02:00
Bjarki Arge Andreasen
372c7183ef modem: pipe: Add explicit timeout to sync APIs
The modem pipe APIs include synchronous calls to open/close,
which internally use a fixed timeout of 10 seconds. The timeout
should be configurable through the APIs, anywhere from K_NO_WAIT
to K_FOREVER.

This commit adds timeout parameters to the open/close APIs, and
updates in-tree usage of the open/close APIs to explicitly
provide the previously implicit timeout of 10 seconds.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-07-29 14:14:42 +02:00
Yong Cong Sin
def7f37c83 tests: posix: unistd_h: mark fsync() & ftruncate() as supported
These functions have been supported, update the test
accordingly.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-07-29 14:14:33 +02:00
Yong Cong Sin
91abf0e329 posix: fs: implement fdatasync()
`fdatasync()` is basically equivalent to `fsync()` according
to the standards.

Added test for it.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-07-29 14:14:33 +02:00
Patryk Kuniecki
c227ff3d63 tests: exclude drivers/watchdog/wdt_basic_api from running on it8xxx2_evb
There is problem with running this test in validation,
because of DBGR mode watchdog can't reset board by itself,
and it needs cold reset. This proves that test is not automated,
and should be exluded on this board.

Signed-off-by: Patryk Kuniecki <patryk.kuniecki@intel.com>
2024-07-29 14:13:21 +02:00
Piotr Kosycarz
0225e0e488 tests: boards: nrf: qdec: add tests for qdec for nrf
Expand testing for QDEC at nrf platforms.
It uses general sensor API,
however there are also nrf driver specific assumptions.

Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
2024-07-28 07:31:15 +03:00
Emil Gydesen
38d09af445 Bluetooth: BAP: Scan delegator add src without PA sync
Modify the bt_bap_scan_delegator_add_src to take an address and
a sid instead of a PA sync object, so that the scan delegator
can add a source without syncing to the PA.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-28 07:31:06 +03:00
Bartosz Miller
0d59c1a780 tests: drivers: add more test cases to the i2c_bme688 test suite
Test NACK handling, bus recovery and FAST speed read.
Signed-off-by: Bartosz Miller <bartosz.miller@nordicsemi.no>
2024-07-28 07:30:59 +03:00
Ren Chen
aa3470ba7e tests: usb: desc_sections: raise the description span to 201
Raise the descriptor table span to 201 due to the inclusion of the USB
configuration descriptor.

Tested with:
$ west build -p -b it82xx2_evb tests/subsys/usb/desc_sections
  -T usb.desc_sections

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2024-07-28 07:30:30 +03:00
Szymon Janc
d434eac86f tests: bluetooth: tester: Fix zero length array in middle of struct
Zero length arrays are only allowed at the end of the structure. Here
those were used as placeholders for BTP response creation and can be
easily replaced with common member.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2024-07-27 20:51:30 +03:00
Jonathan Rico
dc053dc6d2 Bluetooth: shell: Enable sysbuild for nRF5340
Enable sysbuild for nRF5340 app core.

This automatically builds the image for the network core, making a
better user experience.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-27 20:51:10 +03:00
Emil Gydesen
72d98692dc tests: Bluetooth: Add encrypted BAP broadcast test
Added test to test encrypted broadcast

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 20:49:25 +03:00
Fabio Baltieri
32fafc7176 input: analog_axis: add output inversion
The driver right now only allows inverting the input value, which can be
useful for differential channels but is quite confusing for single ended
ones. Implement a simple output inversion flag instead to make up for
that.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 20:47:18 +03:00
Emil Gydesen
8be6db67fc Bluetooth: ISO/BAP: Refactor BIS bitfield
Refactors teh BIS bitfield values used for ISO
and BAP.

Previously BIT(1) meant BIS index 1, which was a Zephyr choice
in the early days of ISO, as the BT Core spec did not use
a bitfield for BIS indexes.

Later the BASS specification came along and defined that
BIT(0) meant BIS index 1, which meant that we had to shift BIS
bitfields between BAP and ISO.

This commit refactors the ISO layer to use BIT(0) for Index 1 now,
which means that there is no longer a need for conversion
between the BAP and ISO layers, and that we can use a value
range defined by a BT Core spec (BASS).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 15:19:46 +03:00
Jordan Yates
c9b1daa7ae tests: fs: fat_fs_api: disable flash disk in RAM test
Disable the flash disk driver in the RAM driver test to prevent the
test using the wrong disk in the tests.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-27 15:19:14 +03:00
Chris Friedt
d0808473f2 tests: posix: net: open native_sim in c++,posix,net,native case
Prior to the fixes in the previous commits, combining a build
for native_sim with

CONFIG_CPP=y
CONFIG_POSIX_API=y
CONFIG_STD_CPP20=y
CONFIG_REQUIRES_FULL_LIBCPP=y

would fail.

It succeeds now.

This change adds a testcase to monitor that scenario in CI.

Note: this was partially necessary because the deprecation of
CONFIG_NET_SOCKETS_POSIX_NAMES is not yet complete, so there
is a dependency cycle, and also because <sys/types.h> was
pulling in the host <sys/types.h> instead of Zephyr's or one
of the embedded OSes we support.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-07-27 15:17:24 +03:00
Emil Gydesen
f338bf6fae Bluetooth: Host: Discard advertising data if not explicit scanning
If the application is not explicitly scanning, then there is not
really any need to parse advertising reports nor send them to the
application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-27 15:12:39 +03:00
Vinayak Kariappa Chettimada
04e3d0081b Bluetooth: Controller: Fix Advertising PDU memory allocation
Fix Advertising PDU memory allocation for redundant Periodic
Advertising related PDU allocations. The buffer count
related to Periodic Advertising was included twice.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-07-27 15:09:39 +03:00
Anas Nashif
c5e6416a65 tests: device: test CONFIG_DEVICE_DT_METADATA=y
Looks like this option is not tested with userspace enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-07-27 15:09:10 +03:00
Robert Lubos
dd0a95ec15 tests: net: lib: http_server: core: Add test for RST_STREAM frame
Add test case verifying that stream is closed when RST_STREAM frame is
received.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
338e41a063 tests: net: lib: http_server: core: Add test for trailing header frame
Add test case covering a scenario when a client sends a trailing header
frame in a request.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
a99f70ce42 tests: net: lib: http_server: core: Add tests for continuation frame
Add test cases for continuation frame processing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
71e0b9fac2 tests: net: lib: http_server: core: Add tests for header with priority
Add test cases verifying that request containing header frame with
priority flag set is processed properly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
1da42b6626 tests: net: lib: http_server: core: Add tests for frames with padding
Add tests verifying that requests which include frames with padding are
processed correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
d1ebddb110 tests: net: lib: http_server: core: Add tests for dynamic POST/GET
Add tests cases covering interaction with dynamic resources with
POST/GET requests.

Simplify HTTP2 request generation to facilitate adding more tests.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
938088641c tests: net: lib: http_server: core: Add test for connection close
Add test case verifying that the server keeps the connection open if no
Connection: close header is present in the request.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
a6d494b16f tests: net: lib: http_server: core: Clarify existing tests
Remove pointless helper functions, the test code can simply be included
in the test case w/o code duplication.

Clarify the naming of existing test cases. Backward compatibility simply
tests HTTP1. The upgrade test wasn't really testing HTTP upgrade, so
rename the test case too. Add a new test case actually verifying HTTP
upgrade.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
ff65815a3b tests: net: lib: http_server: core: Extend start/stop test
Ensure it's possible to restart the server w/o issues after a client
connected.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
5a23c2d602 tests: net: lib: http_server: core: Cleanup before adding more tests
Do some cleanup regarding naming used in the test suite to prepare it
for adding more test cases.

Extract common setup/teardown into respective before and after ztest
functions to simplify test code. Proper before and after functions also
ensure that individual test case failure does not disrupt other tests
operation.

Split the tests into two separate test suites, one for those which
require pre-setup and second for those which don't.

Finally, enable receive timeout on the client socket to ensure tests
won't stall in case of errors.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Robert Lubos
1e2b2c79a5 tests: net: lib: http_server: Rename prototype test suite
"prototype" is ambiguous in this regard, as it doesn't really tell what
the test suite is testing. As tests in this test suite verify core HTTP
server functionality, rename it to "core".

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 15:08:40 +03:00
Johann Fischer
28b2051bda usb: device_next: add support for configuration string descriptor
Change USBD_CONFIGURATION_DEFINE macro to take the address of a string
descriptor node as an argument. This is a breaking change for macro
users, but quite convenient and easy to implement.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-27 15:06:09 +03:00
Robert Lubos
dfbdfb05da tests: net: sockets: misc: Fix SO_BINDTODEVICE test
The test case for SO_BINDTODEVICE socket option was flaky, the client
socket always sent the datagram to the IP address of the second
interface, so in theory every packet should end up on that interface.
In practice though, due to imperfect loopback packet handling, the test
worked as the packet ended up on the interface it was sent from.

The test should send datagrams to the IP addresses of the interface 1
and 2 alternatively. The server socket binds to ANY address, so w/o
interface binding it should receive all datagrams, so it allows to
verify if SO_BINDTODEVICE filtering works fine.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-27 10:44:48 +03:00
Seppo Takalo
9fc2048bcc tests: lwm2m: Add Portfolio testcases
Add testcases:
* LightweightM2M-1.1-int-1630 - Create Portfolio Object Instance
* LightweightM2M-1.1-int-1635 - Delete Portfolio Object Instance

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-07-27 10:44:12 +03:00
Yong Cong Sin
58f66623aa tests: gdbstub: add build-only test
Add build-only test for existing boards.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-07-27 10:42:59 +03:00
Yong Cong Sin
b97d97ff17 tests: gdbstub: minor refactor to the testcase.yaml
Change the `platform_allow` to multi-line format so that newly
supported archs/boards can be added as a new line.

Refactor the tags out to `common`, and add
`CONFIG_ARCH_HAS_GDBSTUB` filter

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-07-27 10:42:59 +03:00
Fabian Pflug
ca53d2bf80 net: l2: ieee802154: mgmt: allow beacon payload
The standard does allow for a optional beacon payload, which gets lost
during scan, that could be interesting for the application to access
in the NET_EVENT_IEEE802154_SCAN_RESULT callback.

See section 7.3.1.6 in IEEE Std 802.15.4 for more information about
the beacon payload field. And section 7.3.1 and figure 7-5 about general
beacon frame format.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
2024-07-27 10:42:45 +03:00
Fabio Baltieri
ef14c9b867 lib: os: add a header for printk hook functions
Add a zephyr/printk.h header for the __printk_hook functions, these are
currently manually declared by all console drivers for no good reason.

Move the documentation into the header and also unify the way that
console drivers call the function.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 10:41:01 +03:00
Anas Nashif
569dbd8e0f tests: cmake: fix test identifier
cmake is part of the build system area.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-07-18 06:47:57 -04:00