Commit graph

377 commits

Author SHA1 Message Date
Kenny Johansson 10386f02f3 tests: net: Add tests for large IPv6 TCP messages
Add tests for lage IPv6 messages, reusing similar IPv4 test structure.

Signed-off-by: Kenny Johansson <wirehell@gmail.com>
2023-04-17 10:17:09 +02:00
Anas Nashif fcefc27823 tests: remove intel adsp cavs platforms from filters
Remove all filters related to dropped platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-06 18:51:56 +02:00
Robert Lubos 5b4a83f9b9 Revert "tests: net: websocket: exclude 64 bit platforms"
This reverts commit a1e07ddbbe.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-05 15:01:50 +02:00
Robert Lubos 162c0f64c2 tests: net: websocket: Fix test execution on 64-bit platforms
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.

The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-04-05 15:01:50 +02:00
Anas Nashif 0f03b1283b tests: net: socketpair: prefix tests with test_
tests need to be prefixed with test_ or else we will not be able to
parse output correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-04-05 10:27:28 +02:00
Fabio Baltieri a1e07ddbbe tests: net: websocket: exclude 64 bit platforms
The websocket library uses int for pointers for testing and does not
work reliably on 64 bit architectures.

Exclude the test so it does not block other unrelated PRs.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-04-05 08:20:24 +00:00
Robert Lubos 159559b807 tests: net: sockets: tcp: Add SO_SNDTIMEO test cases
Add test cases which verify that the TX timeouts configured with
SO_SNDTIMEO work correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Robert Lubos 3da59df974 tests: net: sockets: tcp: Extend SO_RCVBUF/SO_SNDBUF tests
Add new test cases for SO_RCVBUF/SO_SNDBUF which verify that setting
those options actually affects the RX/TX window sizes at the TCP level.
Existing tests only verified whether the options can be set/read
correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-03-20 16:54:41 +01:00
Georges Oates_Larsen 3c6b7dc35a net: dummy L2 for offloaded ifaces
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-03-20 09:53:25 +01:00
Christopher Friedt 1c985a8029 Revert "tests: net: socketpair: skip nonblocking tests on posix arch"
This reverts commit 2eb53f4bd7.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-03-15 07:17:25 -04:00
Christopher Friedt 71f12d7161 tests: net: socketpair: explicit fcntl path on native_posix
Previously, `socketpair()` tests had pulled in the native
`fcntl()` implementation instead of using the Zephyr version
when being run under `native_posix_64`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-03-15 07:17:25 -04:00
Anas Nashif fb48914600 tests: net: socket: remove platform exclude on native_posix_64
This test runs fine on native_posix_64. The exclude was added long time
ago and seems to not apply anymore.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 12:18:04 +01:00
Anas Nashif eaeaede7b6 tests: net: socket: do not enable shell
Shell support not needed for this test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 12:18:04 +01:00
Hu Zhenyu 9c10e8958f tests: net: socket: websocket move to new ztest API
Move net/socket/websocket tests to use new ztest API
TEST=twister -T tests/net/socket/websocket

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-02-22 12:18:04 +01:00
Chris Friedt 2eb53f4bd7 tests: net: socketpair: skip nonblocking tests on posix arch
The `fcntl()` call (`zsock_fcntl()`) does not seem to work
properly (specifically with `CONFIG_ARCH_POSIX`). This will
be resolved in subsequent work harmonizing the networking
subsystem and POSIX library.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Chris Friedt 494faf3e2c tests: net: socketpair: coverage for all C libraries
Previously, the test was only run for configurations that used
the Newlib C library. However, socketpair runs equally well
under the minimal libc, and picolibc, as well as the native
libc.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Chris Friedt b9fe11c7f2 tests: net: socketpair: use do not alias read and write
* do not define `read`, `write`, as different symbols
* use `recv`, and `send` as defined by
  `CONFIG_NET_SOCKETS_POSIX_NAMES`
* do not specify `(2)` as manual-page sections are
  somewhat irrelevant

Note: we use `CONFIG_NET_SOCKETS_POSIX_NAMES` here, and
`CONFIG_POSIX_API` in `samples/` to show that the socketpair
API is available in both configurations.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Chris Friedt c73b8ed4f3 tests: net: socketpair: put common includes in one header
This serves to increase SNR in the test sources (i.e. to
make test sources easier to read).

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Chris Friedt 750299534e tests: net: socketpair: rename files to be less redundant
Wow, this testsuite was really celebrating some redundancy
before.

While that is sometimes a good thing, it's also sometimes
better to be more concise.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Chris Friedt ee2656d83f tests: net: socketpair: remove test_socketpair_ prefix
The `test_socketpair_` prefix was leftover from the old ztest
framework.

It is also redundant, so remove it.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Chris Friedt bb465bd78c tests: net: socketpair: remove unused extern declarations
The declarations of extern test functions were leftover from
the old ztest framework.

They are unnecessary now.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-20 11:04:07 +01:00
Hu Zhenyu a8bda2ef8f tests: net: socket: tls_ext move to new ztest API
Move net/socket/tls_ext tests to use new ztest API
TEST=west build -p -b native_posix tests/net/socket/tls_ext

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2023-02-19 10:32:03 -05:00
Robert Lubos 690140baa6 tests: net: socket: tcp: Disable IPv6 ND
There is a test case which verifies that no new packets show up on the
interface, assuming that the only source of the packets is TCP stack.
ND protocol could interfere with that assumption, sending
advertisements.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-01-26 12:34:04 +00:00
Jamie McCrae ec7044437e treewide: Disable automatic argparse argument shortening
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00
Nicolas Pitre bb3795505d tests/net/socket: fix compiler warnings
warning: format '%d' expects argument of type 'int', but argument 3
has type 'size_' {aka 'long unsigned int'} [-Wformat=]

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-01-10 09:58:01 +01:00
Sjors Hettinga 1be1b472cd net: tcp: Extend TCP receive queue timeout
After several fixes of the re-ordering logic in TCP, the receive queue
works as intended and cleans itself up properly. Previously the default
timeout was 100 ms, which pretty much disables it for real applications.

Increase the timeout to 2 seconds to actually enable it for in practice.
This should help pass much more of the Maxwell Pro tests.

This is the first step before removing the timeout completely.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-01-10 09:26:28 +01:00
Chris Friedt 8659e2f69e libc: minimal: include: move fcntl.h to posix
The `fcntl.h` header has never been a part of ISO C so move it to
`include/zephyr/posix`.

To ensure a smooth migration, a header was left in
`lib/libc/minimal/include` that prints a deprecation warning.

Users should either include `<zephyr/posix/fcntl.h>` or switch to
`CONFIG_POSIX_API=y`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-10 09:02:21 +09:00
Erwan Gouriou 66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Grixa Yrev 2a992c65c0 net: websocket: new receiving algorithm
websocket_recv_msg() is reworked with using fsm. Now the function
return 0 when payload is empty, -ENOTCONN if socket close. Receiving
empty ping and sending empty pong were added in tests.
Fixes #52327

Signed-off-by: Grixa Yrev <grixayrev@yandex.ru>
2022-12-20 17:05:12 +00:00
Anas Nashif ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Maciej Perkowski 458afb9064 tests: net: Add min flash requirment for overflowing tests
These tests turn on mbedtls and require ajusting min flash
requirements to prevent twister from trying to build them on
platforms without required amount of flash.
Fixes: #51421

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2022-10-27 11:01:24 +02:00
Robert Lubos 48c3b5bb2a tests: net: socket: udp: Don't use NET_CONFIG_SETTINGS
As the UDP test suite is mostly intended to run over loopback, use
loopback addresses and skip configuration of other addresses.

For the test cases that use fake Ethernet iterface the configuration
is done manually anyway, so just rename the symbols to avoid
collission.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos ba308cbc44 tests: net: socket: tls: Don't use NET_CONFIG_SETTINGS
As the TLS test suite is intended to run over loopback interface, use
loopback addresses and skip configuration of other addresses.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos d3eb3f8a5e tests: net: socket: tcp: Don't use NET_CONFIG_SETTINGS
As the TCP test suite is intended to run over loopback interface, use
loopback addresses and skip configuration of other addresses.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos 1b00a853cd tests: net: socket: socketpair: Don't use NET_CONFIG_SETTINGS
The socketpair test suite does not really make use of IP connectivity.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos fab28b8978 tests: net: socket: select: Don't use NET_CONFIG_SETTINGS
As the test suite is intended to run over loopback interfce, use
loopback address and skip configuration of other addresses.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos 0293efe28b tests: net: socket: poll: Don't use NET_CONFIG_SETTINGS
As the test suite is intended to run over loopback interfce, use
loopback address and skip configuration of other addresses.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos a72f6a70f2 tests: net: socket: net_mgmt: Don't use NET_CONFIG_SETTINGS
The test suite did not make use of autoconfigured IP addresses at all.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos d8ae904d95 tests: net: socket: misc: Don't use NET_CONFIG_SETTINGS
The test suite already configured the dummy interfaces manually, so it's
only needed to provide respective address strings, no need to involve
NET_CONFIG_SETTINGS.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos 3dfbef9f46 tests: net: socket: getnameinfo: Don't use NET_CONFIG_SETTINGS
No really need to set additional addresses on the interface, as they're
not used by the test.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos 8ca7b8de1e tests: net: socket: getaddrinfo: Don't use NET_CONFIG_SETTINGS
The loopback addresses are configured automatically on the loopback
interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Robert Lubos 21134f52cd tests: net: socket: af_packet: Don't use NET_CONFIG_SETTINGS
Configure the test interfaces manually instead to increase test
reliability on real hardware.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-26 12:00:22 +02:00
Henrik Brix Andersen f8a88cdb27 drivers: can: use flags fields for can_frame and can_filter structs
The can_frame and can_filter structs support a number of different flags
(standard/extended CAN ID type, Remote Transmission Request, CAN-FD format,
Bit Rate Switch, ...). Each of these flags is represented as a discrete bit
in the given structure.

This design pattern requires every user of these structs to initialize all
of these flags to either 0 or 1, which does not scale well for future flag
additions.

Some of these flags have associated enumerations to be used for assignment,
some do not. CAN drivers and protocols tend to rely on the logical value of
the flag instead of using the enumeration, leading to a very fragile
API. The enumerations are used inconsistently between the can_frame and
can_filter structures, which further complicates the API.

Instead, convert these flags to bitfields with separate flag definitions
for the can_frame and can_filter structures. This API allows for future
extensions without having to revisit existing users of the two
structures. Furthermore, this allows driver to easily check for unsupported
flags in the respective API calls.

As this change leads to the "id_mask" field of the can_filter to be the
only mask present in that structure, rename it to "mask" for simplicity.

Fixes: #50776

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-10-25 16:32:10 +02:00
Robert Lubos 6e9e35c18d tests: net: socket: tls: Fix test_v4_dtls_sendmsg test case
test_v4_dtls_sendmsg test case wrongly used IPv6 socket instead of IPv4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-10-20 10:00:18 +02:00
Stephanos Ioannidis 6fae7a1c4c tests: net: getaddrinfo: Use newlib nano variant when available
This commit updates the `getaddrinfo` test to use the newlib nano
variant when available because it can run out of RAM with the newlib
full variant on the platforms with a small RAM.

Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
2022-10-19 16:02:51 +02:00
Hu Zhenyu 011b1ea8da tests: net: socket: offload_dispatcher move to new ztest API
Move offload_dispatcher tests to use new ztest API
TEST=twister -T tests/net/socket/offload_dispatcher

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-09-07 10:29:56 +02:00
Martin Jäger c05e71ed4b net: socketcan: make socketcan_frame CAN FD capable
Align the struct socketcan_frame to most recent Linux kernel.

Compatibility with legacy can frames is maintained because the DLC is
equal to payload length for up to 8 bytes. Only the data buffer is
extended, resulting in larger size when CAN FD is enabled.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-09-05 14:48:22 +00:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Hu Zhenyu 6505200b8e tests: net: socket: socketpair: move to new ztest API
Move socketpair tests to use new ztest API
TEST=twister -T tests/net/socket/socketpair

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-09-02 10:54:49 +00:00
Sjors Hettinga 069e003380 net: tcp: Also run the packet loss test with NO_DELAY option
When the NO_DELAY option is enabled, the retransmitted packets
will likely be differently broken down from the packets transmitted
initially. This provides a nice stress test for the out or order
reception logic.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Sjors Hettinga f2d94a7f5c net: tcp: Implement a fast retransmit algorithm
Instead of waiting for the retransmit timeout, retransmit as soon as
missing data is deduced based on a triple-duplicate ACK.

Increase the number of buffers in the testcase, to allow for at least 4
packets in flight to trigger the triple-duplicate ACK.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-09-01 10:38:28 +00:00
Florian Grandel 7fb2e1ec4d net: l2: ieee802154: add unittests
This change introduces test coverage for IEEE 802.15.4 AF_PACKET support
and IEEE 802.15.4 security operation.

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-08-31 21:52:37 +00:00
Hu Zhenyu dcda3eab8d tests: net: socket: tcp: move to new ztest API
Move net/socket/tcp tests to use new ztest API
TEST=twister -T tests/net/socket/tcp

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-08-29 11:58:17 -04:00
Hu Zhenyu d548ebc318 tests: net: socket: udp move to new ztest API
Move net/socket/udp tests to use new ztest API
TEST=twister -T tests/net/socket/udp

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-08-29 10:30:14 -04:00
Hu Zhenyu b962074a68 tests: net: socket: tls move to new ztest API
Move net/socket/tls tests to use new ztest API
TEST=twister -T tests/net/socket/tls

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-08-18 12:36:20 +02:00
Henrik Brix Andersen 27eb12ed48 net: socketcan: decouple SocketCAN and CAN controller headers
Decouple the zephyr/net/socketcan.h and zephyr/drivers/can.h header files
by moving the SocketCAN utilities to their own header.

This is preparation for including the SocketCAN types defined in
socketcan.h in a native posix (Linux) SocketCAN driver context without name
clashes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen ef1e492032 net: socketcan: SocketCAN supports classic CAN, not CAN-FD
SocketCAN does not support CAN-FD data lengths of up to 64 bytes
payload. Decouple the maximum supported SocketCAN data length from the
maximum supported CAN controller data length.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen d1d48e8304 net: socketcan: rename SocketCAN header from socket_can.h to socketcan.h
Rename the SocketCAN header from socket_can.h to socketcan.h to better
match the naming of the functionality.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen b40a8cb9fd net: socket: can: rename utility functions
Rename the SocketCAN utility functions to reflect the new naming of the CAN
controller API and SocketCAN API data types.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen 13c75417ba drivers: can: remove z prefix from public CAN API types
Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen d159947443 net: socket: can: prepend SocketCAN data types with socketcan
Rename the SocketCAN data types to "socketcan_*" in preparation of renaming
the low-level CAN controller API data types.

This breaks the naming compatibility with the similar SocketCAN data types
from the Linux kernel, but Zephyr and Linux SocketCAN are not 100%
compatible anyways (only the structure fields are compatible, extended
functionality such filtering, error reporting etc. are not).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Henrik Brix Andersen 6099e180b1 tests: move the SocketCAN tests to tests/net/socket/can
Move the SocketCAN tests from tests/drivers/can/utilities to
tests/net/socket/can to match the location of the code under test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-18 10:19:29 +02:00
Kumar Gala 6124ccfccf drivers: ethernet: provide Kconfig means to disable ethernet drivers
There are several test cases that create fake ethernet devices and
expect the fake device to be the only ethernet device enabled.  Some
tests handle this be explicitly disabling actual ethernet drivers,
but this doesn't scale well.

Change drivers/ethernet/Kconfig to utilze a menuconfig option that
wraps all the drivers.  This allows us for those test cases that
don't want any actual ethernet drivers to disable them with a
simple CONFIG_ETH_DRIVER=n.

Note, the fake ethernet devices utilize CONFIG_ETH_INIT_PRIORITY so
we have it outside of the 'if ETH_DRIVER' block.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-12 11:33:43 +02:00
Robert Lubos 3eaf55a364 tests: net: socket: Disable unstable tests for mps2_an385
Disable unstable tests cases for mps2_an385, which fail sporadically
due to timer stability issues on that platform (see #48608).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-08-08 22:18:23 +09:00
Martí Bolívar 4583ebe50d tests: net: socket: adjust fudge factors
Loosen some timing constraints in order to hack arond spurious
failures in upstream Zephyr's CI while working on an unrelated task.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2022-08-08 10:44:41 +02:00
Stephanos Ioannidis 815b974382 tests: net: socket: tcp: Disable preempt test for mps2_an385
This commit disables the `net.socket.tcp.preempt` test on the
`mps2_an385` platform because it fails very frequently due to the
system timer stability issues.

For more details, refer to the issue zephyrproject-rtos/zephyr#48608.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2022-08-03 08:56:28 -04:00
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Sjors Hettinga fafcbf59b9 net: tcp: Implement randomized retransmission timeouts
It can happen that two similar stacks enter a retransmission cycle
due to a packet collision. If the transmission timeout is the same
both stacks will retry at the same moment resulting in another
collision.

By introducing a randomized retry timeout, the chance of
a second collision is reduced and it reduces furter the more
retransmissions occur.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Sjors Hettinga ea4f10fc58 net: tcp: Basic exponential backoff implementation
Apply an exponentially increasing wait time between tcp retries. This
is a good balance between reacting fast to single lost packets and reduce
the network load when an outage takes a little longer. It also allows the
connection to survive a longer interruption with less retransmissions.

Update the test to accommodate for the increased socket closure timeout

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Sjors Hettinga a0ca04b893 net: tcp: Explicitly wait for context closure instead of simply waiting
Previously the test waited for the worst case time till all sockets
where closed, this causes the test to wait for a long unnecessary time.
Secondly it does not ensure the sockets are actually closed before
starting the next tests.

For tests that are not conducted in user mode, wait until all the contexts
are close for a maximum time. If the contexts are not closed in time raise
an explicit assertion.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-08-01 10:33:24 +02:00
Hu Zhenyu 8090fa3b33 tests: net: socket: select move to new ztest API
Move net/socket/select tests to use new ztest API
TEST=twister -T tests/net/socket/select

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:51:16 -04:00
Hu Zhenyu 74fdc04234 tests: net: socket: register: move to new ztest API
Move net/socket/register tests to use new ztest API
TEST=twister -T tests/net/socket/register

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:51:02 -04:00
Hu Zhenyu 79c68eb783 tests: net: socket: poll move to new ztest API
Move net/socket/poll tests to use new ztest API
TEST=twister -T tests/net/socket/poll

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:50:50 -04:00
Hu Zhenyu f40e50f519 tests: net: socket: net_mgmt move to new ztest API
Move net_mgmt tests to use new ztest API
TEST=twister -T tests/net/socket/net_mgmt

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:50:18 -04:00
Hu Zhenyu 8b39587f23 tests: net: socket: getnameinfo: move to new ztest API
Move getnameinfo tests to use new ztest API
TEST=twister -T tests/net/socket/getnameinfo

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:49:59 -04:00
Hu Zhenyu 2ff8588cd3 tests: net: socket: getaddrinfo: move to new ztest API
Move getaddrinfo tests to use new ztest API
TEST=twister -T tests/net/socket/getaddrinfo

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:49:45 -04:00
Hu Zhenyu 7bc775c479 tests: net: socket: af_packet_ipproto_raw move to new ztest API
Move af_packet_ipproto_raw tests to use new ztest API
TEST=twister -T tests/net/socket/af_packet_ipproto_raw/

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-28 10:49:28 -04:00
Hu Zhenyu ada34a250e tests: net: socket: move to new ztest API
Move net tests to use new ztest API
TEST=twister -T tests/net/socket/af_packet

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-27 18:47:21 +02:00
Hu Zhenyu 4fd935b6ef test: Update the new ZTEST APIs tests/net/socket/misc
TEST=twister -T tests/net/socket/misc

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-07-25 11:08:26 -04:00
Andrei Emeltchenko 30be920bd6 tests: net: socket: Add missing return code check
Add missing check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 10:34:40 +02:00
Andrei Emeltchenko 6360f75d0c tests: net: socket: Fix checking wrong variable
Check return code instead of parameter.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2022-06-30 10:34:40 +02:00
Krzysztof Chruscinski 041f0e5379 all: logging: Remove log_strdup function
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-23 13:42:23 +02:00
Marcin Niestroj 994f6c8630 tests: net: sockets: tls: increase ztest and sysworkq stack sizes
Increase threads stack sizes from 2k to 3k, so that it will pass without
stack overflow on qemu_x86 platform when SHA384 support will be reenabled.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-15 09:11:09 +02:00
Marcin Niestroj c4bd3f1e38 tests: net: socket: udp: verify that sent DGRAM was not fragmented
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that.

Verify that by trying to send MTU+1 bytes in case of IPv4 (as IP level
fragmentation is not implemented) and IPv6 (should fail when IPv6
fragmentation support is not enabled and succeed otherwise). In case of
IPv6 try to send "total number of network buffers + 1", so that even with
IPv6 fragmentation enabled requested datagram will not be sent. In all
tested cases when datagram is too big, check that ENOMEM error code is set.

NOTE: Tested behavior is not 100% compliant with Linux, as on Linux
EMSGSIZE error code is set when trying to send datagram bigger than MTU,
when manually disabling IP fragmentation (by setting IP_MTU_DISCOVER to
IP_PMTUDISC_DO). However, it is not trivial to implement such
behavior (EMSGSIZE error due to MTU) now and there is always a risk of
running out of buffers (and getting ENOMEM), so for now implemented tests
just assume the latter case to always happen.

Add 3rd testcase, which enables IPv6 fragmentation support, so that UDP
socket behavior can be tested in that context.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-01 11:17:07 +02:00
Sjors Hettinga d55c921e2f tests: net: socket: tcp: Add test for a broken link
A reproducible case to the behavior when during a connection
the link gets broken and all data is lost, the TCP connection
should properly terminate.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-30 10:30:38 +02:00
Robert Lubos 3cd88c72b1 tests: net: sockets: Update packet socket tests
Fix the existing DGRAM packet socket test. The test will now specify
LL destination address and protocol type. Also, update the fake ethernet
device send handler, so that it sets the packet network interface
corretly, so that the packet is not rejected at Ethernet L2.

Additionally, add two additional test cases verifying datagram packet
sockets. Fist test will exchange packet between RAW and DGRAM socket,
making sure that net stack forwards/removes L2 header correctly. The
second test verifies that it's possible to recieve a packet on both RAW
and DGRAM socket, making sure the received data has correct format.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-27 15:40:29 -07:00
Marcin Niestroj 084aca1aa4 tests: socket: tls: check sendmsg() behavior for datagrams
Datagrams (for DTLS connection) need to be sent using single API call to
mbedTLS and should not result in sending each fragment in a separate
datagram. Check if that is the case, so allow only single fragment data to
be sent and expect an error when multiple fragments were passed to
sendmsg().

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-05-25 14:20:09 +02:00
Robert Lubos f49ed7a539 tests: net: socket: Add test to verify POLLOUT functionality
Add test which verifies that POLLOUT is reported correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-18 11:09:17 +02:00
Sjors Hettinga c3158804d4 tests: net: socket: tcp: Add test to validate obstructed close
When there is no response from the server, a client side close
is obstructed, it should terminate and clean the context. This
tests breaks the connection after the accept and validates
this behavior.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-16 16:55:51 +02:00
Robert Lubos d63cb79383 tests: net: socket: Increase ztest stack size for offload_dispatcher
The test suite is failing on qemu_cotext_a9 due to stack overflow.
Apparently this issue can also be observed on main after enabling
STACK_SENTINEL, however the test only started crashing after TCP
changes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-05-13 15:42:01 +02:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Sjors Hettinga 11288cdbdd tests: net: socket: tcp: Make test_vX_msg_waitall more robust
The close function on a TCP socket can return before the complete
socket has been closed, as there might be packets still in flight.
Add a wait at the end of the test so we are sure all sockets have
been closed before the next test starts.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-05 14:45:02 -05:00
Sjors Hettinga cf3466ff74 tests: net: socket: tcp: Make test_open_close_immediately more robust
The close function on a TCP socket can return before the complete
socket has been closed, as there might be packets still in flight.
Modify the test to wait briefly (less then the retransmit time), before
counting the number of still open net_contexts. This makes the test
outcome not dependent on the scheduling order of the different tasks.

Secondly the test actually checks the number of open contexts to be zero
so there is no need to wait for any open contexts to still close.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-05 14:45:02 -05:00
Sjors Hettinga 40ee401dd2 tests: net: socket: tcp: Add test to validate connect timeout
When there is no response from the server, a client side connect
should return a ETIMEOUT. This tests breaks the connection and validates
this behavior.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-05-05 14:45:02 -05:00
Robert Lubos 6da10468ad tests: net: Add socket dispatcher unit tests
Add unit tests for socket dispatcher module. The tests verify that:
* a socket is automatically dispatched to a regular socket on any
  first socket call, if the socket was not bound already before
  (according to the default priority rules)
* a socket is correctly dispatched to an offloaded/native socket
  implementation after a SO_BINDTODEVICE call
* a socket is correctly dispatched to a native TLS socket, with an
  underlying native/offloaded socket, if TLS_NATIVE and SO_BINDOTODEVICE
  socket options are used

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-04-20 11:27:05 +02:00
Mohan Kumar Kumar 2558d277e2 tests: net: tcp: Add new tests for get/set SO_SNDBUF
Test SO_SNDBUF option using getsockopt and setsockopt.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-11 10:23:31 +02:00
Sjors Hettinga 3b03344a8d tests: net: socket: tcp: Add test for big block data transfer
A reproducible case to see what happens when the TCP stack runs out
of buffers. It transfers a block, bigger then the number of buffers
available.
Also test by introducing packet loss in the loopback driver.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2022-04-01 12:36:14 -05:00
Mohan Kumar Kumar 4e7a74c547 tests: net: tcp: Add new tests for get/set SO_RCVBUF
Test SO_RCVBUF option using getsockopt and setsockopt.

Signed-off-by: Mohan Kumar Kumar <mohankm@fb.com>
2022-04-01 13:30:09 +02:00
Katarzyna Giadla 681e3a16c7 tests: Change duplicated names of the test cases
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.

Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
2022-03-30 17:42:01 -04:00
Robert Lubos c1f06c7442 tests: net: sokcets: tcp: Adjust net_pkt count
Since the loopback driver makes use of the RX packet pool now, adjust
the packet count for the test.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-30 11:08:22 +02:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Robert Lubos cea2c8de3d tests: net: socket: Add getpeername() tests
Add tests for new getpeername() function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-03-16 16:23:16 +01:00
Marcin Niestroj 4480831fc6 tests: socket: tcp: add shutdown(..., SHUT_RD) tests
Those tests cover behavior of shutdown(fd, SHUT_RD) and recv(fd, ...).

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2022-03-02 10:05:09 -08:00
Carles Cufi e83a13aabf kconfig: Rename the TEST_EXTRA stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Carles Cufi 4b8f1c04ab kconfig: Rename the ZTEST stack size option to align with the rest
All stack sizes should end with STACK_SIZE.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-02-22 08:23:05 -05:00
Yong Cong Sin 731241f8d0 kernel: workq: Fix type errors in delayable work handlers
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.

Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-02-02 18:43:12 -05:00
Christopher Friedt 3e86c627f7 kernel: atomics: update print specifiers for atomic_t
The print specifier for `atomic_t` should be updated
to `%ld`, `%lu`, or `%lx` to account for the type
change of `atomic_t` to `long`.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-11-15 09:59:01 -05:00
Tomasz Bursztyka 404f67ab5e tests/net: Raise TLS timeout option on waitall checks
Previous timeouts values were done when local TCP replies wourd occur
within sender's thread. This was a known behavior: no context switch,
shorter timings for sending packets (locally only) thus shorter
timeouts.

Such behavior changed when local replies had to go through TCP's work
queue. See commit 798588e709

Fixes #40129

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-09 12:51:44 +01:00
Anas Nashif 6432289baf tests: add integration_platforms to socket/tls test
Run only on defined integration platforms in CI.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-11-05 09:23:41 -04:00
Tomasz Bursztyka 3718904a50 test/net: Make sure the tls server socket is accepting before connect
Client thread might run before the server gets to put itself on accept.
Leading to the server waiting forever.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-04 13:54:28 +01:00
Tomasz Bursztyka 1696f6de35 tests/net: TLS test requires more RX PKT and buffers
Due to the previous change on when to send TCP packet on local IP, pkt
may be held in a queue which is to run on a k_work. This changes the
scheduling, and due to that one of the test is failing to allocate a
RX net_pkt at the time it wants to. (previous TCP connection is not yet
fully closed and still own PKT that new connection cannot get then).

Of course all those waiting paquets require buffers so raising them.

It was verified that there is no leak, adding net_pkt_print() at
tcp_conn_unref() shows that when all tcp connection are finally unrefed:
all net_pkt get freed as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-04 13:54:28 +01:00
Robert Lubos 0dbdcc770d net: sockets: Add socket processing priority
When creating a socket, all of the registered socket implementation are
processed in a sequence, allowing to find appropriate socket
implementation for specified family/type/protocol. So far however,
the order of processing was not clearly defined, leaving ambiguity if
multiple implmentations supported the same set of parameters.

Fix this, by registering socket priority along with implementation. This
makes the processing order of particular socket implementations
explicit, giving more flexibility to the user, for example when it's
neeed to prioritze one implementation over another if they support the
same set of parameters.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-09-28 20:11:26 -04:00
Torsten Rasmussen 8e64038559 drivers: net: adding NET_DRIVERS menuconfig
Fixes: #38403

Adding NET_DRIVERS menuconfig so that network drivers are grouped
together in its own menu entry under drivers, similar to most other
drivers.

This further has the advantages that `CONFIG_NET_DRIVERS` can be used
for testing to determine if network drivers has been selected.

This changed revealed a dependency loop where both `select` (for SLIP)
and `depends` (for PPP) which both depends on NET_DRIVERS` where in use
in the dependency tree for Qemu networking, especially NET_SLIP_TAP.

This is handled by defaulting `NET_DRIVERS` to `y` when building for a
Qemu target.
`SLIP` had a dependency to `!QEMU_TARGET || NET_QEMU_SLIP`. This is
changed so that SLIP prompt depends on `!QEMU_TARGET` which provides
full user control in hardware but makes the symbol promptless on Qemu
targets.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-28 12:13:23 +02:00
Jani Hirsimäki f7219e8a31 tests: net: socket: new tests for AF_PACKET&SOCK_RAW&IPPROTO_RAW
New test case for testing send/recv for
socket combo of: AF_PACKET&SOCK_RAW&IPPROTO_RAW.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2021-09-14 08:37:36 -04:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Robert Lubos 3fe94e088b tests: net: socket: select: Relax timing requirements
The test ocassionally fails on the mps2_an385 platform in the CI, due
to strict timing requirements of the test.

Relax the timeouts and acceptable fuzz time a bit, to prevent the
failures in the future.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-14 07:41:08 -04:00
Robert Lubos f6a2d3ac7a tests: net: socketpair: Verify that poll is signalled correctly
Add unit tests which verifies that poll() function is signalled
correctly if called after data was written/read to/from a socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-02 22:22:42 -04:00
David Leach 6688f70996 tests: net: socket: tls_ext: Add platform filter
Network test cases are designed for emulated
environments so add platform_allowed filter to
only allow qemu platforms.

Fixes: #36418

Signed-off-by: David Leach <david.leach@nxp.com>
2021-07-02 09:46:04 -04:00
Robert Lubos 2f409f401e tests: net: socket: tls: Fix timing issue on nRF devices
The timings were too tight for TLS tests executing on nRF52840 with
hardware entropy source enabled. Increase the timings to make tests
pass.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-06-09 16:11:11 +03:00
Jukka Rissanen 0106e83c74 tests: net: socket: Add userspace tests to SO_BINDTODEVICE
Change the SO_BINDTODEVICE tests so that we test also userspace
mode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-07 10:37:22 +03:00
Stephanos Ioannidis 79788137cf tests: net: getaddrinfo: Increase newlib heap size
This commit increases the newlib heap size to 2048, which is the
recommended minimum required to ensure proper operation of the newlib
nano used by test (see #35799).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-02 08:50:45 -05:00
Jukka Rissanen dab391f253 tests: net: getaddrinfo: Disable onboard Ethernet controller
If the tests/net/socket/getaddrinfo is run in a board that has
Ethernet controller, then it is possible that it will interfere
the test if the Ethernet cable is connected. As the test only
needs loopback support to run, disable the Ethernet as it is
not needed by the test.

Fixes #34923

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-13 22:07:00 -04:00
Jukka Rissanen 6e1df0d603 tests: net: Refactor tests when running in real hw
The network tests were expecting that network interfaces
are in certain order. As we cannot guarantee that, refactor
the tests like this:

* if test is using DUMMY L2 driver, then disable Ethernet L2
  and fetch only DUMMY L2 instead of default interface
* if test is using Ethernet L2 driver, then make sure that the
  test is using the Ethernet interface specified in the test
  instead of the one provided by the DUT

Fixes #34505

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-30 11:59:10 +03:00
Gerard Marull-Paretas 5899b8a190 tests: net: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 12:53:09 -04:00
Jukka Rissanen 91ff30513f tests: net: poll: Increase ztest thread stack size
The socket poll test was running out of ztest stack so increase
it by 256 bytes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Peter Bigot 188cb2cb7c net: Conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-14 07:07:40 -04:00
Robert Lubos 71532eb8c2 tests: net: sockets: Implement SO_BINDTODEVICE option tests
Add tests for SO_BINDTODEVCIE socket option.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-02 07:23:17 -04:00
Hake Huang 6d397801e7 tests: disable long time case from NXP FRDM_KW41Z
CMSIS_DSP and net_socket tests are either too
slow or too large for this platform, also drop
bluetooth for test

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
2021-04-01 10:57:19 -05:00
Christopher Friedt 5b1d71259b tests: sockets: add test for socket api tls extensions
This change adds a test for the socket API TLS extensions.

Fixes #30936

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-03-23 14:09:08 +02:00
Robert Lubos 8929b40b78 tests: net: sockets: tls: Add MSG_TRUNC flag tests
Add unit tests for MSG_TRUNC flag.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-23 13:16:30 +02:00
Robert Lubos d93003e267 tests: net: sockets: Add MSG_TRUNC flag tests
Add unit tests for MSG_TRUNC flag.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-23 13:16:30 +02:00
Guðni Már Gilbert 01252c2b6b tests: net: socket: getaddrinfo: fix resource leak
Fix resource leak detected by coverity by adding missing
zsock_freeaddrinfo(res) calls.

Coverity-CID: 219527
Fixes #32919

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-19 17:22:31 +02:00
Guðni Már Gilbert 4d5566adf1 tests: net: socket: af_packet: fix resource leak
Fix resource leak by closing opened AF_PACKET sockets

Coverity-CID: 219491
Fixes #32949

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-15 17:19:39 +02:00
Anas Nashif 15b9565b37 Revert "tests: net: socket: af_packet: fix resource leak"
This reverts commit a1ae45fecd.

The test is failing now, reverting until properly fixed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-12 19:50:54 -05:00
Robert Lubos 5de148d8c0 tests: net: sockets: tls: Add unit test for TLS MSG_WAITALL flag
Add a unit test that covers MSG_WAITALL flag functionality for TLS
sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-12 13:57:11 -05:00
Robert Lubos 4582e57903 tests: net: sockets: tcp: Add unit test for MSG_WAITALL flag
Add a unit test that covers MSG_WAITALL flag functionality for TCP
sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-12 13:57:11 -05:00
Jukka Rissanen 8140fb8d2f tests: net: getaddrinfo: Verify that we receive all queries
The previous implementation of process_dns() handler did not
properly catch how many queries we sent.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-12 11:26:16 -05:00
Guðni Már Gilbert a1ae45fecd tests: net: socket: af_packet: fix resource leak
Fix resource leak by closing opened
sockets

Coverity-CID: 219491
Fixes #32949

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-12 09:22:26 -05:00
Andy Ross 3d81464194 tests: samples: Add targetted platform_excludes for intel_adsp_cavs15
This platform has a tiny handful of remaining tests that fail.  We
will track them as issues, but let's exclude them from integration
testing to allow full runs to complete.  Often a hung device in one
test will break an entire twister run.

Tests with known (and tracked) failures:

  samples/application_development/external_lib
  samples/posix/eventfd
  samples/userspace/hello_world_user
  tests/kernel/fatal/message_capture
  tests/net/socket/socketpair
  tests/portability/cmsis_rtos_v2

These tests never fail in isolated testing, but are reliable timeouts
when run in sequence in a big twister run.  It's possible that the bug
here may be in twister or the flash/serial scripts:

  tests/crypto/tinycrypt
  tests/subsys/logging/log_immediate
  tests/subsys/logging/log_output

See: #32836

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-03-08 19:25:25 -05:00
Jukka Rissanen 15e3355d85 tests: net: select: Increase the timeout to 20ms
The timeout might take more than 10ms in a heavily loaded system,
so increase the timeout to 20ms.

For example this is often seen for mps2_an385 platform.

  Assertion failed at \
  WEST_TOPDIR/zephyr/tests/net/socket/select/src/main.c:101: \
  test_select: (tstamp <= FUZZ is false)

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-24 08:01:43 -05:00
Hubert Miś ca87d134b5 tests: Socket send timeout option
This patch adds tests for SO_SNDTIMEO socket option.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-24 14:16:33 +02:00
Hubert Miś 2f02ca0b39 tests: net: socket: SO_PROTOCOL socket option
This patch adds tests to verify getting SO_PROTOCOL socket option for
TCP, UDP, and TLS sockets.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-17 10:36:58 +02:00
Hubert Miś a6e83eb769 tests: net: socket: SO_TYPE socket option
This patch adds tests to verify getting SO_TYPE socket option for
TCP, UDP, and TLS sockets.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-02-17 10:36:58 +02:00
Flavio Ceolin 1335716b5f tests: socket: Fix compiler warnings
../src/main.c:662:13: warning: cast from pointer to integer of different
size [-Wpointer-to-int-cast]
  662 |  int sock = (int)p1;
      |             ^
../src/main.c: In function 'spawn_child':
../src/main.c:671:4: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
  671 |    (void *)sock, NULL, NULL, 0, K_USER,

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-27 08:05:48 -05:00
Hubert Miś 401ee4ae5b tests: Socket receive timeout option
This patch adds tests for SO_RCVTIMEO socket option for UDP and
TCP sockets.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-19 17:11:25 -05:00
Jukka Rissanen ebd077b258 tests: net: af_packet: Increase main stack size
The main stack size is too small by default in many boards.
Increase the size to 1024 bytes which works fine with
sam_e70_xplained board.

Fixes #31343

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-15 12:14:53 -05:00
Lukasz Majewski 33028963c8 test: af_packet: Add test for passing UDP packet to open RAW socket
The af_packet test has been augmented to check if sent UDP packet from
one port to another (via net interface) is also passed to open SOCK_RAW
connection.
The test_packet_sockets() function has been reused to setup the SOCK_RAW
sockets for this test.
It is important to note that the packet is passed to receive part of net
stack after being sent.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-01-15 09:30:17 +02:00
Lukasz Majewski 4987c7ba47 test: af_packet: Do not change proto to network order when creating socket
The setup_socket() function calls socket() with proto changed to network
order. In this case functions with zsock_* prefix are called instead of
zpacket_*. The problem is with 'packet_is_supported()' method from
sockets_packet.c, which returns false when ETH_P_ALL proto is converted
with htons().

This patch fixes this issue by removing the htons() call.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Suggested-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-15 09:30:17 +02:00
Hubert Miś 4ca7942411 tests: net: Test resolving literal IPv6 addresses
This patch adds a test for the network address resolver module
that verifies resolving literal IPv6 addresses.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2020-12-22 15:44:00 +02:00
Watson Zeng 7a3f9c4e39 tests: add filter for some tests using newlib
some tests configured with CONFIG_NEWLIB_LIBC=y,
it's better to add a filter filter: TOOLCHAIN_HAS_NEWLIB == 1
in those tests yaml file.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2020-12-16 08:57:40 -05:00