576 Commits

Author SHA1 Message Date
Robert Lubos
59b653bb4f tests: net: lib: http_server: Add test case for overlapping resources
Add a test case verifying that if there's a static resource defined
which overlaps a FS resource pointing to a directory, it takes
preference on exact URI match.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 13:52:47 +01:00
Gaetan Perrot
69f318ab16 tests: net: lwm2m: interop: client: make lwm2m_setup void
lwm2m_setup() never reports errors and always returns 0.
The error check at the call site is therefore dead code.

Make the function void and drop the unused error handling.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-01-15 15:27:04 +01:00
Tim Pambor
d40c003513 net: http_server: Add transaction complete status
When the response has been sent completely to the client, the server
reports the new `HTTP_SERVER_TRANSACTION_COMPLETE` status. Together with
the existing `HTTP_SERVER_TRANSACTION_ABORTED` status, the application
can now also for successful completions of requests clean up any
resources allocated for handling the request.

This especially allows to dynamically allocate the response buffer
passed to the server in the request callback and free it when the
request is done.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-01-11 13:04:52 +01:00
Tim Pambor
43d3387634 net: http_server: clarify naming of HTTP server callback status enum
Rename enum http_data_status to enum http_transaction_status
to better reflect its purpose, which is to indicate the status of the
overall HTTP transaction, not just data transfer.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-01-11 13:04:52 +01:00
Sam Friedman
6383a7222b tests: net: coap_client: allow native_sim/native/64
Fix build failures when compiling for 64-bit native_sim,
and add native_sim/native/64 to the platform allow list for
the coap client tests.

Signed-off-by: Sam Friedman <sam@golioth.io>
2026-01-09 17:12:31 -06:00
Robert Lubos
346e4d041e tests: net: lib: lwm2m: interop: Add missing PSA configs
Some PSA configs were missing for DTLS to work in LwM2M interop tests.

CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID was defined twice, so remove
redundant entry.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-12-23 19:50:17 +00:00
Alberto Escolar Piedras
242b69e1ac tests: net: dns_resolver: Increase heap size
The test fails on 64bit targets running out of heap.
Let's just increase it.

Circumstantially it started failing after
d5982f0f89

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-12-20 15:04:29 +01:00
Michael Zimmermann
4759e39122 net: mqtt_sn: Disable support for GWINFO messages
The MQTT-SN v1.2 [0] specification specified the GwAddr as follows:
The GwAdd field has a variable length and contains the address of a GW. Its
depends on the network over which MQTT-SN operates and is indicated in the
first octet of this field. For example, in a ZigBee network the network
address is 2-octet long.

It specifies neither the possible values for the first octet, nor the
format of the network-specific address that follows. Thus, the
specification is incomplete and this functionality unusable.

I also wasn't able to find any implementation which implements a gwinfo
message where the address length is not zero. This includes
https://github.com/eclipse-paho/paho.mqtt-sn.embedded-c .

The current implementation in Zephyr simply copies a `struct sockaddr`
into GwAddr. This is a bad idea for many reasons, the most important one
being that the format is not even specified by POSIX [1]. They only say,
which defines must exist, not what their values are. And in fact, these
even differ between Zephyr and Linux.

Thus, I think it's best to remove the implementation to prevent people from
using this, which may even lead to memory safety issues, depending on the
length of CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE. If we were to receive an
updated specification, all we'd have to do is to convert between `struct
sockaddr` and mqtt-sn addresses both ways.

[0] https://groups.oasis-open.org/higherlogic/ws/public/download/66091/MQTT-SN_spec_v1.2.pdf
[1] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-12-15 07:27:57 -05:00
Michael Zimmermann
53012f9cc2 tests: net: mqtt_sn: client: Test gwinfo response from a gateway itself.
When the response comes from a gateway, the address length is 0. I renamed
the test which tests a gwinfo from another client to make this more clear.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-12-15 07:27:57 -05:00
Michael Zimmermann
2d8cb5dad9 tests: net: mqtt_sn: client: fix running just search_gw
Since the code can't handle timestamp 0, we have to sleep during setup.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-12-15 07:27:57 -05:00
Valerio Setti
99bb73537c tests: net: lwm2m: replace legacy crypto deps with PSA API
Replace usage of legacy Mbed TLS crypto with PSA Crypto API.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-02 11:32:35 +01:00
Valerio Setti
52df6fb770 tests: net: http_server: replace legacy crypto deps with PSA API
Replace legacy Mbed TLS crypto support with PSA API.
RSA key exchange dependency was removed because all certificates and
keys used in the test are EC.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-02 11:32:35 +01:00
Robert Lubos
7a9ca8e410 tests: net: dns_resolve: Add tests for dns_unpack_name()
Verify that dns_unpack_name() generates a valid DNS name when unpacking
records and that it returns an error in case of overflow.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-21 11:40:44 -05:00
Jukka Rissanen
9795ce7bba tests: net: ocpp: Fix uninitialized variable warning
According to the compiler, the ret variable might be uninitialized
in the function (looks like a false positive but fix it anyway).

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-21 12:01:31 +01:00
Jukka Rissanen
8046a24104 net: Fix network API calls that were not namespaced
Some of the networking calls were not namespaced so fix it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-21 12:01:31 +01:00
Jakub Klimczak
f16f3f641e zvfs: Move fdtable into ZVFS
The file descriptor table is used in every area that expects to work on
files through descriptor indices. It can only be operated on through
functions whose names indicate a relationship with ZVFS (`zvfs_*fd*`).
The integer file descriptor mechanism shouldn't be separate from ZVFS.
This will make cooperation between different file access APIs much
simpler. This commit also makes preparations for the fdtable becoming
optional.

Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
2025-11-18 08:12:19 -05:00
Jukka Rissanen
d45cd6716b net: Convert network codebase to use renamed network APIs
Rename network symbols in network stack to use the renamed network APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-17 14:01:32 -05:00
Josuah Demangeon
e6e7fc549e style: tests: apply coding style on CMakeLists.txt files
Apply the CMake style guidelines to CMakeList.txt files in tests/.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Julien Vermillard
4e54e9a806 net: lwm2m: get cache free slots
Add function to query LwM2M cache free slots on a given path.

Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
2025-11-14 09:20:59 +01:00
Jukka Rissanen
820cd34dbb net: Replace Posix eventfd by zvfs_eventfd API
No need to use Posix eventfd API in core network code as zvfs_eventfd
is compatible with it and we can now avoid using Posix headers
unnecessarily.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-13 23:12:04 +02:00
Jukka Rissanen
79a0dadef3 tests: net: lwm2m_engine: The test needs more fds
Set minimum amount of file descriptors in the test to pass
the tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-30 14:23:46 -04:00
Jukka Rissanen
0ad1a5ad6a tests: net: dns_resolver: The test needs more fds
Set minimum amount of file descriptors in the test to pass
the tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-30 14:23:46 -04:00
Simon Walz
645e62fb8f tests: lwm2m: add test for senml cbor composite writer
This adds a test for the composite writer with time serialized resource and
resource instance values.

Signed-off-by: Simon Walz <simon.walz@autosen.com>
2025-10-29 20:18:30 +02:00
Anas Nashif
303af992e5 style: fix 'if (' usage in cmake files
Replace with 'if(' and 'else(' per the cmake style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-29 11:44:13 +02:00
Valerio Setti
f960db846c modules: mbedtls: rename MBEDTLS_TLS_VERSION_1_2
Align Kconfig name to the Mbed TLS build symbol.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-24 13:27:59 -04:00
Jukka Rissanen
7573a3a699 tests: Remove not needed CONFIG_ZVFS_OPEN_MAX option
Either remove the option from conf file or adjust its value
by using CONFIG_ZVFS_OPEN_ADD_SIZE_NET option because the
max number of socket descriptors is now calculated dynamically
at built time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-21 17:22:03 +03:00
Nicolas Pitre
d9141b2b9b tests: net: mqtt_sn: Fix format specifier for uint16_t
The msg.len field is of type uint16_t, so the correct format
specifier is %u, not %zu.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-10-20 11:28:44 -04:00
Julien Vermillard
9ee47f2856 net: lwm2m: add cache filtering
Introduce `lwm2m_set_cache_filter()` so applications can drop cached
samples before they reach the LwM2M SEND path.

Fixes #91590

Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
2025-10-16 17:10:24 +03:00
Robert Lubos
c5c51f23d8 net: coap: Define a symbol for fixed header size
Move the definition from the test suite to a public header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-14 12:50:39 +03:00
Robert Lubos
f7e9d21936 net: coap_client: Use buffers instead of pointers for path and options
Use buffers instead of pointers for path and extra options provided in
the struct coap_client_request, so that the library keeps a copy of the
path/options instead of pointers. That way, the library can still work
correctly in case of retransmissions or block transfer in case when the
original path or options were automatic variables that went out of
context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-14 12:50:39 +03:00
Ofir Shemesh
4187375d81 tests: http_server: remove duplicated CONFIG_ZVFS_OPEN_MAX
The prj.conf for http_server/tls defined CONFIG_ZVFS_OPEN_MAX
twice.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2025-10-10 20:50:07 -04:00
Pieter De Gendt
cbef8679f4 net: lib: coap: Convert client response callback arguments to struct
Make it easier to modify the response callback data by passing it as a
struct pointer rather than a long list of arguments.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-07 11:00:50 +02:00
Michael Zimmermann
f07f0d288e net: mqtt_sn: Implement updating will topic and message
Since the protocol doesn't have message IDs in the responses to these
update messages, there's no reliable way to know, if an update succeeded or
not. I use that fact to simplify the implementation by:
- Not providing success/failure callbacks.
- Not handling updating the variables in the client struct while
  an update is in progess.

In addition to adding some tests, I tested this with the emqx server.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-02 09:31:53 +02:00
Michael Zimmermann
a039babf77 tests: net: mqtt_sn_client: test predefined topics
This add tests for both outgoing and incoming publishes on predefined
topics.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Michael Zimmermann
e79315de45 tests: net: mqtt_sn_client: test incoming publishes
Until now, only outgoing ones were tested.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Michael Zimmermann
3289d83dad tests: net: mqtt_sn_client: store expected recv data const
It's never modified anyway and allows API users to make use of that.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Michael Zimmermann
9b3b5b4447 net: mqtt_sn: scope msg_id to client instance
- The paho client does that, too.
- This allows running single tests, because they don't rely on previous
  ones having incremented the msg_id a certain number of times.
- The variable already existed in the client struct, but wasn't used. I
  guess it was intended that way but never implemented.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Jukka Rissanen
8e6077e3e5 tests: net: dns_cache: Increase ztest thread stack size
Make sure that the DNS cache tests have enough stack size for
each ztest thread so increase the stack to 1280 bytes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-09-10 13:18:40 +02:00
Benjamin Cabé
0132ea07fb doc: fix spelling errors tree-wide
fix some spelling errors in code comments and Kconfig helps

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-03 17:04:13 +02:00
Saravanan Sekar
d466ee679b tests: net: ocpp: Add test suit for OCPP lib
Add test suit for OCPP lib with one complete charging session
with a random meter values.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2025-08-06 11:57:13 -04:00
Jukka Rissanen
c3c7394ff3 tests: net: dns_resolve: Increase ztest stack size
The ztest stack size might be too small for the net.dns.resolve.hostname
tests that was added recently. Increase it to 1280 bytes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-08-06 17:11:44 +03:00
Fabio Baltieri
6ebc196008 net: sockets: getaddrinfo: use k_ variants for memory allocation
The rest of the network (and generally Zephyr subsystem code) use the k_
prefixed variants for memory allocation, which results in data goin in
the _system_heap rather than the stdlib z_malloc_heap.

The code in getaddrinfo use the z_ ones as well apart from the actual
getaddrinfo implementation, which seems like an oversight, change it to
use k_calloc and k_free as well.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-08-06 12:15:49 +03:00
Seppo Takalo
05dfc7145f net: lwm2m: Fix string truncation on some content formatters
LwM2M engine does not allow strings to be truncated as it would
lead to invalind UTF-8 strings.

However, some content formatters were truncating, so I fixed at least
these
* plain text
* TLV
* SenML CBOR
* SenML JSON
* JSON
* CBOR

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-05 13:20:57 -04:00
Seppo Takalo
0c2b771858 tests: net: lwm2m: Add tests for string truncation
lwm2m_get_string() and lwm2m_set_string() API does not allow
strings to be truncated and ensures NUL termination
regardles of using string or opaque resources to store the string.

Add tests to verify that is also true on multi-byte UTF-8
strings.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-05 13:20:57 -04:00
Anas Nashif
5d3adb00e3 tests: net: http: also build with clang
Build this test also with clang to increase coverage. This test is
selected because it had some issues with clang, however, there is
nothing special about this tests when it comes to clang, it will be one
of many to come to increase coverage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-08-01 07:50:10 -04:00
Seppo Takalo
d0cba34c7f net: lwm2m: Prevent QUEUE_RX_OFF while waiting for CoAP Ack
The LwM2M RD client state machine have no knowledge of ongoing
observations or any other CoAP traffic and might trigger
QUEUE_RX_OFF state while engine is still waiting for Ack.

This can happen if CoAP Ack timeout is longer than
CONFIG_LWM2M_QUEUE_MODE_UPTIME and response is lost or taking
longer than QUEUE_MODE_UPTIME.

When observation is lost, CoAP Ack may be send, but socket is not
listening anymore if its closed or not polled while in RX_OFF and this
stops observation.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-01 07:39:16 -04:00
Jukka Rissanen
9125f07392 tests: net: dns: Add tests for resolving hostname or localhost
Make sure we are able to resolve the localhost or local hostname.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-31 17:10:45 -04:00
Andrey Dodonov
286362087d net: http: service: extend HTTP service with config
Update the HTTP service API to allow setting per-service configuration,
currently it is only custom socket creation callback,
but in the future it can be extended with other parameter

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2025-07-30 17:32:43 -04:00
Robert Lubos
7b73998e96 tests: net: lwm2m: content_plain_text: Check for overflows
Add checks for int64_t overflows when parsing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-24 16:58:05 +01:00
Robert Lubos
e172f72e89 tests: net: lwm2m: content_json: Check for overflows
Add checks for int64_t overflows when parsing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-24 16:58:05 +01:00