Commit Graph

444 Commits

Author SHA1 Message Date
Robert Lubos
dcbd1ed5fc tests: net: socket: tcp: Add test for keepalive connection upkeep
Add test verifying that if keep-alive messages are exchanged, the
connection remains alive.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-28 08:44:41 -04:00
Gaetan Perrot
aaec242a63 tests: net: socket: net_mgmt: mark unused function argument
Use ARG_UNUSED() to mark unused function argument.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-14 11:18:31 -10:00
Gaetan Perrot
369d5b170c tests: net: socket: getaddrinfo: Remove unused assignment
In check_dns_query(), the assignment `ret = -ENOMEM` was never used since
the function returns false immediately afterward.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-07 10:05:51 -05:00
Tim Pambor
ee1468b675 tests: net: socket: Fix function signature
Update the process_dns function signature to match the expected
k_thread_entry_t type:
typedef void (*k_thread_entry_t)(void *p1, void *p2, void *p3);

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-07-04 14:21:23 -10:00
Tim Pambor
f682a173d8 net: socket: mgmt: Fix function signature
Update the trigger_events function signature to match the expected
k_thread_entry_t type:
typedef void (*k_thread_entry_t)(void *p1, void *p2, void *p3);

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-07-04 14:21:23 -10:00
Robert Lubos
aa4a8789d5 net: sockets: socket_dispatcher: Fix close function type
Socket dispatcher (and offloaded implementations in tests) register
fd as ZVFS_MODE_IFSOCK therefore they should register a  close2(
function instead of close().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
2d49ef26ad tests: net: socket: udp: Don't call memset() on a NULL pointer
cmsgbuf pointer can be NULL, therefore verify that before calling
memset() on it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Jukka Rissanen
2ed2232f17 net: socket: mgmt: Create proper socket options for net_mgmt sockets
We cannot use the network management event number directly as
a socket option value because the management value is uint64_t
and that cannot be mapped directly to 32 bit integer.
So have an intermediate socket option that is mapped to actual
network management request number in getsockopt() and setsockopt().

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 10:54:44 +02:00
Fin Maaß
ed4d421ace drivers: ethernet: remove phy related configs from eth config
remove phy related configs from eth config.
phy related configs chould go directly into the phy.
Most ethernet drivers didn't support the now removed
functions yet. Users should instead use `phy_configure_link()`
together with the `net_eth_get_phy()` function.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-06-11 10:17:37 -07:00
Krzysztof Chruściński
5acd29e651 tests: all: Fix remaining issues reported by string validation
Fix issues reported by string validation which was added to strings
used in zassert macros.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-05-27 09:16:08 +02:00
Robert Lubos
6aa8f3fe57 tests: net: socket: tls_ext: Add test case for cert veirfy cb option
Add test case to verify if TLS_CERT_VERIFY_CALLBACK socket option works
as expected.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-22 13:44:43 +02:00
Robert Lubos
0956271bc3 tests: net: socket: tls_ext: Add test case for verify result option
Add test case to verify if TLS_CERT_VERIFY_RESULT socket option works as
expected.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-22 13:44:43 +02:00
Robert Lubos
6be66aac60 tests: net: socket: tls_ext: Extract common code into functions
Extract server configuration, client configuration and test shutdown
into separate functions so that they're reusable in other tests.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-22 13:44:43 +02:00
Alberto Escolar Piedras
b2ee13cc12 tests/net/socket/af_packet: Fix typo
Just a typo

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-05-21 12:35:28 +02:00
Robert Lubos
4512cbf509 tests: net: sockets: tls_configurations: Use fixture for openssl
Currently, creating and killing openssl process was part of the test. In
result, if the test case failed for whatever reason, the openssl process
would remain open, causing disruptions in consecutive test executions.

Fix that by defining openssl server instance as a pytest fixture. That
way, openssl process will be terminated regardless of the test
result.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-15 14:10:05 +02:00
Tomi Fontanilles
35f7eda545 modules: mbedtls: make key exchange Kconfigs depend on, not select
Turn the MBEDTLS_RSA_FULL selects into depends on.
This is how the other MBEDTLS_KEY_EXCHANGE_* Kconfig options are defined.

This is done to avoid circular dependencies.

At the same time update uses of the affected MBEDTLS_KEY_EXCHANGE_*
Kconfig options to enable/disable the dependencies which used to be
automatically handled.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2025-05-13 22:22:43 -04:00
Robert Lubos
bbad01eb91 tests: net: socket: af_packet: Add more tests to verify binding
In case the receiving packet socket is not bound to any specific
interface, or is explicitly bound to "any" interface (at index 0),
it should collect packets from all interfaces. Add test cases which
verify that.

Also, if a packet socket is bound to a specific interface, it should not
receive packets from others. Add a test case to verify that as well.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-30 16:26:16 +02:00
Robert Lubos
6654f78376 tests: net: socket: af_packet: Remove unused param
iface parameter in setup_packet_socket() function was not used, remove
it to avoid confusion.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-30 16:26:16 +02:00
Robert Lubos
cd50608f24 tests: net: sockets: af_packet: Fix recvfrom DGRAM test
The recvfrom test case for DGRAM packet socket specified wrong socket
type, so RAW sockets were tested twice instead. Also, for the DGRAM
variant, the offset was not taken into account for the expected packet
length.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-30 16:26:16 +02:00
Fin Maaß
3a195a08da drivers: net: ethernet: change ETHERNET_LINK_*BASE_T
change ETHERNET_LINK_*BASE_T to ETHERNET_LINK_*BASE.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-04-28 09:22:09 +01:00
Robert Lubos
95ac568ed0 tests: net: socket: af_packet: Extend the test suite with more tests
Add more tests cases to the AF_PACKET sockets test suite, covering the
summary of the packet socket functionalities prepared from various
sources (mostly man pages).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-17 17:23:23 +02:00
Robert Lubos
6869668cc9 tests: net: socket: af_packet: Fix test_raw_and_dgram_socket_recv test
The test case did not do what it said, it was supposed to receive data
on both RAW and DGRAM packet sockets, but instead it received on RAW
socket twice.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-17 17:23:23 +02:00
Robert Lubos
9f6ac50566 tests: net: socket: af_packet: Simplify test initialization
Test interface configuration doesn't change throught the test suite
execution, therefore there's no need to reiterate the interfaces to set
the interface pointers in each test case. Do it just once, when test
suite is setup.

Also remove the __test_packet_sockets() function which seemed no longer
useful with all those simplifications.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-17 17:23:23 +02:00
Robert Lubos
0a98a83387 tests: net: socket: af_packet: Switch to blocking sockets with timeout
Packet socket tests used non-blocking sockets so in results the test
code was overly complicated with delays and loops scattered all across
the test code, making it difficult to read.
As packet sockets do support blocking operation with timeout,
reconfigure the sockets to use that and simplify the test code by
getting rid of unnecessary loops and delays.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-17 17:23:23 +02:00
Robert Lubos
ff801c62b1 tests: net: socket: af_packet: Increase IPv4 context instance count
Test suite prints a warning on boot about not enough IPv4 context
instances compared to the number of interfaces, therefore adjust the
config value to get rid of it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-17 17:23:23 +02:00
Robert Lubos
76605f813a tests: net: socket: af_packet: Make sure sockets are closed on failure
Make sure all sockets used in test are closed even in case of test
failure. Otherwise, a single test failure could derail other tests,
making the results obfuscated.

Remove redundant code related to socket creation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-17 17:23:23 +02:00
Robert Lubos
307694f3d9 net: sockets: Remove support for AF_PACKET/IPPROTO_RAW combination
IPPROTO_RAW is not a valid protocol type for AF_PACKET sockets, which
should only use IEEE 802.3 protocol numbers. Therefore remove support
for this type of sockets.

As an alternative, users can use AF_PACKET/SOCK_DGRAM or
AF_INET(6)/SOCK_RAW, depending on the actual use case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-09 12:36:34 +02:00
Robert Lubos
4f92df61f1 tests: net: socket: Add tests for AF_INET raw sockets
Add test suite verifying AF_INET/AF_INET6 and SOCK_RAW sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-09 12:36:34 +02:00
Anas Nashif
37c4631a0b tests: remove various filters due to bugs/issue that were fixed
Some platforms were excluded due to issues that were fixed or resolved
themselves. Enable those platforms again and remove the comments related
to the issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-03-28 21:52:13 +01:00
Robert Lubos
a61287e876 net: lib: tls_credentials: Rename TLS_CREDENTIAL_SERVER_CERTIFICATE
TLS_CREDENTIAL_SERVER_CERTIFICATE credential type is misleading, as in
fact it just represents a public certificate, it does not matter if the
certificate belongs to a server or a client. And actually, it was
already used in-tree for clients as well, for example in LwM2M.

Therefore rename the credential type to a more generic
TLS_CREDENTIAL_PUBLIC_CERTIFICATE and deprecate the old one.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-21 14:18:52 +01:00
Jukka Rissanen
ac3cb9dac0 net: Change the net_linkaddr struct to not use pointers
Previously the net_linkaddr struct had pointers to the link address.
This is error prone and difficult to handle if cloning the packet as
those pointers can point to wrong place. Mitigate this issue by
allocating the space for link address in net_linkaddr struct. This will
increase the size of the net_pkt by 4 octets for IEEE 802.15.4 where the
link address length is 8, but there no increase in size if link address
is 6 bytes like in Ethernet/Wi-Fi.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-17 16:25:22 +01:00
Christoph Seitz
b01b77aa44 tests: net: socket: Check length for AF_PACKET SOCK_DGRAM socket
This test checks that the length returned is not altered
even if the payload resembles a valid IPv4 or IPv6 length.

Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
2025-03-12 02:29:02 +01:00
Christoph Seitz
5340fa49a7 tests: net: socket: Add recvfrom addr validation
Add address length validation and expected source address
checks in packet socket tests.

Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
2025-03-10 15:02:38 +01:00
Alberto Escolar Piedras
78f800642a drivers/ethernet/eth_native_posix: Rename to eth_native_tap
Rename this driver to eth_native_tap, including renaming all its
options.
The old options remain until v4.4, but as deprecated.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 20:10:38 +01:00
Noah Olson
b2e29fe0d7 net: tcp: fix ECONNREFUSED not reported by zsock_connect
When a TCP connection is refused during zsock_connect, errno is set
to -ENOTCONN, but errno should be set to -ECONNREFUSED. This change
causes the ECONNREFUSED status to be propagated from tcp_in to
net_tcp_connect, which eventually causes errno to be set
to -ECONNREFUSED.

Signed-off-by: Noah Olson <noah@wavelynx.com>
2025-03-07 19:48:10 +01:00
Alberto Escolar Piedras
6c38bc8ec4 boards native_posix: Remove twister support
native_posix is being removed as it has reached its end of life in 4.2,
after being deprecated since 4.0.

Remove the twister support for native_posix[//64] and therefore all
references to them from the testcases and samples yamls, so twister
does not error out.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 19:16:14 +01:00
Tom Hughes
9e85669482 tests: net: socket: Fix -Wsometimes-uninitialized warning
Building with clang warns:

tests/net/socket/tcp/src/main.c:377:13: error: variable 'c_sock' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
        } else if (family == AF_INET6) {
                   ^~~~~~~~~~~~~~~~~~
tests/net/socket/tcp/src/main.c:396:15: note: uninitialized use occurs here
        test_connect(c_sock, s_saddr, addrlen);
                     ^~~~~~
tests/net/socket/tcp/src/main.c:377:9: note: remove the 'if' if its
condition is always true
        } else if (family == AF_INET6) {
               ^~~~~~~~~~~~~~~~~~~~~~~~
tests/net/socket/tcp/src/main.c:360:12: note: initialize the variable
'c_sock' to silence this warning
        int c_sock;
                  ^
                   = 0
tests/net/socket/tcp/src/main.c:377:13: error: variable 's_sock' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
        } else if (family == AF_INET6) {
                   ^~~~~~~~~~~~~~~~~~
tests/net/socket/tcp/src/main.c:387:12: note: uninitialized use occurs here
        test_bind(s_sock, s_saddr, addrlen);
                  ^~~~~~
tests/net/socket/tcp/src/main.c:377:9: note: remove the 'if' if its
condition is always true
        } else if (family == AF_INET6) {
               ^~~~~~~~~~~~~~~~~~~~~~~~
tests/net/socket/tcp/src/main.c:361:12: note: initialize the variable
's_sock' to silence this warning
        int s_sock;
                  ^
                   = 0

Not really needed since we have zassert_unreachable(), but doesn't hurt
to initialize the variables.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-07 02:23:24 +01:00
Robert Lubos
a31e3537b5 tests: net: tls_ext: Fix scheduling race
After recent kernel changes there's some thread scheduling race when
running tests, therefore add k_yield() at the end of the test to make
sure the network stack has a chance to run in between tests.
Make sure CONFIG_NET_TCP_TIME_WAIT_DELAY is set to 0 so that TCP
connections are released immediately.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-02-04 11:55:17 +01:00
Robert Lubos
571d773d24 tests: net: socket: udp: Verify recvmsg buffer lengths
Make sure that buffer configuration and buffer lengths provided in
struct msghdr are left intact after being processed by recvmsg().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-30 14:09:35 +01:00
Robert Lubos
fcc8d7288f tests: net: socket: tcp: Verify recvmsg buffer lengths
Make sure that buffer configuration and buffer lengths provided in
struct msghdr are left intact after being processed by recvmsg().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-30 14:09:35 +01:00
Jukka Rissanen
d243bc1fdb net: Fix inet_pton IPv4 implementation
The conversion from IPv4 string presentation to numeric value
did not check if the individual address value was between 0 and 255
inclusive.

Add also test case for this.

Fixes #84593

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-01-29 17:56:09 +01:00
Samuel Chee
8d6d4de79d boards: arm: mps2: Add support for mps2/an383
Added new mps2 board an383 to enable testing with ARM FVP.
Qualifier to build/run is mps2/an383

Signed-off-by: Samuel Chee <samche01@arm.com>
2025-01-20 11:15:32 +01:00
Valerio Setti
ff8b970b33 tests: tls_configurations: adjust Kconfig in overlay-ec
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC is promptless so it cannot
be selected. Moreover it's also automatically enabled by
CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE in the same overlay file
so there would be no need to explicitly enable it.

As for the IMPORT, EXPORT, DERIVE they are needed for the TLS connection
to work properly. Previously it was working because at least IMPORT and
EXPORT are internally enabled by Mbed TLS at build time. So here we
are basically doing the same enablements with Kconfigs in clear.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-12-16 22:56:43 +01:00
Robert Lubos
55ea932f88 tests: net: socket: tcp: Increase system workqueue stack size
The tests overflowed system workqueue stack slightly when running on
nRF52840, increase the stack size globally for the tests to avoid
potential issues on other platforms as well.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-12-11 15:54:44 +00:00
Robert Lubos
6ac2ab70a2 tests: net: misc: Use different subnets on test interfaces
The test interfaces registered addresses within the same subnet. As now
only the subnet part of the address is verified when choosing source
address or interface, it was not deterministic which interface would be
selected. Therefore, make the two interfaces use two different subnets
so that tests that verified which address/interface was used work
reliably as earlier.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-11-29 11:44:39 +01:00
Jukka Rissanen
9332c2813e tests: net: socket: udp: Add min_flash to the test config
Add minimum flash requirement to the tests. This will effectively
exclude nrf5340dk/nrf5340/cpuapp/ns as it does not have
enough flash for the application.

Fixes #81862

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-27 10:38:15 -05:00
Pieter De Gendt
bf2db7afc0 python: Format and sort imports
ruff check --select I001 --fix applied to all python files that had
this as only issue.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-25 10:07:13 +01:00
Jukka Rissanen
5531692bcc tests: net: socket: udp: Add IP_LOCAL_PORT_RANGE socket option tests
Make sure that the IP_LOCAL_PORT_RANGE socket option works
as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-22 17:42:08 +01:00
Jukka Rissanen
c2802618df tests: net: socket: tcp: Add min_flash to the test config
Add minimum flash requirement to the tests. This will effectively
exclude nrf5340dk/nrf5340/cpuapp/ns as it does not have
enough flash for the application.

Fixes #81608

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-22 11:33:52 +01:00
Pieter De Gendt
f05deb1aa4 python: Format trivial files where only newlines were missing
Apply formatting on files that only needed adding newlines.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-21 20:10:51 +01:00