Commit graph

377 commits

Author SHA1 Message Date
Robert Lubos 5bbf898905 tests: net: socket: tcp: Fix FD leak in fionread tests
Socket close was missing in fionread tests, causing file descriptor
leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:06:50 +01:00
Robert Lubos 95155c1fae tests: net: tcp: Add small delay when checking context dereference
Since the TCP context (and thus net_context) is not dereferenced
directly from the test thread anymore, add a small delay so that TCP
work queue have a chance to run, before checking net_context count or
reusing the port on new allocation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:06:50 +01:00
Jukka Rissanen 55958d851f net: context: Refactor option getters
Set separate option getters for bool, uint8_t and uint16_t
values. Use those generic getters when fetching the desired
option value.

Noticed mixed usage (bool vs int) for txtime option. Changed
the code to use int type like in other options.

The uint16_t option getter gets the value from uint16_t variable
but returns int value to the caller, and also expects that user
supplies int value.

For uint8_t value, it is expected that uint8_t value is supplied
instead of int.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Jukka Rissanen 5539a47eb6 tests: net: socket: Add recv pktinfo ancillary tests for recvmsg
Make sure recvmsg() is able to return IPv4 IP_PKTINFO and
IPv6 IPV6_RECVPKTINFO ancillary data to the caller.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen bb880c6457 tests: net: udp: Make receive timeout shorter
No need to wait 2.5 seconds for the test to pass, 400ms wait
is enough.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 34929a57e0 tests: net: socket: Add TCP tests for recvmsg()
Make sure recvmsg() works as expected for TCP data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 0b71043f6a tests: net: socket: Add UDP tests for recvmsg()
Make sure recvmsg() works as expected for UDP data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Alberto Escolar Piedras 0a81ea5406 tests/net/socket/can: Switch from native_posix to native_sim
Switch from native_posix to native_sim as default test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Jukka Rissanen 1e15949fe0 tests: net: socket: tls: Increase the mbedtls heap size
native_posix_64 needs more heap for the test to pass so
increase it by 2kb.

Fixes #64670

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-02 13:20:40 +01:00
Robert Lubos 9d3306b22f tests: net: socket: misc: Fix optlen type
The optlen parameter passed to getsockopt() should be of (socklen_t *)
type. Using int produced build errors on 64 bit platforms.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-26 12:34:12 -05:00
Robert Lubos f64d09040b tests: net: socket: misc: Increase stack size
Recently added tests require more stack on certain platforms
(nrf52840dk_nrf52840 in this case), hence increase the ZTEST stack size.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-26 12:34:12 -05:00
Keith Packard 565c9376f1 tests: Switch from NEWLIB_LIBC to REQUIRES_FULL_LIBC
Instead of forcing use of NEWLIB_LIBC, select any available complete C
library implementation. Add CONFIG_REQUIRES_FLOAT_PRINTF where needed.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-10-25 08:32:06 +02:00
Jukka Rissanen b510073db3 tests: net: tcp: Add test case for connect timeout
This checks that if connect() timeouts, we check TCP pointer
properly in select() and poll() in order to catch the situation.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen bc41d03e28 tests: net: socket: misc: Fix memory leak
The sent pkt must be removed after we have cloned it
in the simulated driver otherwise there is a memory leak.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen 83aaeadddd tests: net: socket: Add tests for IPV6_V6ONLY option
The IPV6_V6ONLY option is only checked if
CONFIG_NET_IPV4_MAPPED_TO_IPV6 option is set.
By default the IPV6_V6ONLY option is set.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Henrik Brix Andersen b603910214 tests: net: socket: can: split RTR flag from data contents test
Split the conversion of the RTR frame flags from the data contents test as
RTR frames do not carry any data.

Replace a couple of direct DLC assignments with proper use of
can_bytes_to_dlc().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-10-13 10:08:45 +03:00
Jukka Rissanen 5c6dca3c52 tests: net: sockets: mgmt: Add tests for too long message
Add test that checks we get proper return code if trying
to copy too much data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-12 10:33:36 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Florian Grandel 36402b6d2a net: pkt: time: introduce ns timestamp helper
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:

Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:15 +02:00
Robert Lubos e836427f97 tests: net: socket: reuseaddr_reuseport: Fix userspace testing
net_context_foreach() is not a systemcall, therefore should not be used
from userspace threads. Usage of this API made SO_REUSADDR/SO_REUSEPORT
userspace tests unfunctional (crashing).

Fix this by using CONFIG_NET_TCP_TIME_WAIT_DELAY instead for tests that
involve TCP connections. Other tests don't really need to wait as
there's no teardown delay on UDP or unconnected TCP contexts.

Additionally, remove the platform exclude for qemu_x86 platform, as this
was the sole reason the tests were crashing on that platform.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 15:15:44 +02:00
Tobias Frauenschläger 1de4e73e6d tests: net: sockets: add tests for SO_REUSEPORT
This commit adds unit tests for the SO_REUSEPORT sockets option. It also
fixes some bugs in other tests triggered by the new features.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-09-20 08:56:31 +02:00
Tobias Frauenschläger 795c96494a tests: net: sockets: add tests for SO_REUSEADDR
This commit adds unit tests for the SO_REUSEADDR socket option to test
the different possible scenarios for the option to work correctly.

There is also a fix for the TCP testsuite to make a now failing test
pass again due to a TIME_WAIT socket.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-09-20 08:56:31 +02:00
Chaitanya Tata 40ee8791f2 net: socketpair: Fix use after free
In low memory conditions, its possible for socketpair memory allocation
to fail and then the socketpair is freed but after that the remote
semaphore is released causing a crash.

Fix this by freeing the socketpair after releasing the semaphore. Add a
test case to induce low memory conditions (low HEAP and high socketpair
buffer size), with the fix issue is not seen.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-09-18 20:34:12 +02:00
Jukka Rissanen 7aa4904b5a net: socket: Change SO_BINDTODEVICE to use interface name
Make sure we use the network interface name (if configured)
instead of device name when binding to certain network
interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 14:43:36 +02:00
Robert Lubos 9a90440226 tests: net: sockets: misc: Add getsockname() tests
Add tests which verify that getsockname() function works as expected.

Additionally, add a teardown delay in tests involving TCP, to make sure
all resources are released before the test ends, not to interfere with
other tests.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-27 07:35:34 -04:00
Robert Lubos e8a00b7ef6 tests: net: socket: udp: Add test to verify connected socket behavior
Add test cases which verify that when UDP socket is connected, it only
accepts datagrams from a remote peer it was connected to, and not
others.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-08-25 10:31:19 +02:00
Christopher Friedt 9d16fbb70c tests: net: socket: tcp: reduce number of file descriptors
For some reason, tests/net/socket/tcp/net.socket.tcp.preempt
was failing to link for vmu_rt1170 with these changes, and
for some reason reducing CONFIG_POSIX_MAX_FDS from 20 to 10
resolves that issue.

ld.bfd: scripts/build/gen_kobject_placeholders.py \
  did not reserve enough space for kobject rodata.
Memory region         Used Size  Region Size  %age Used
           FLASH:      287860 B        64 MB      0.43%
             RAM:       86460 B       512 KB     16.49%
           OCRAM:          0 GB       256 KB      0.00%
          OCRAM1:          0 GB       512 KB      0.00%
          OCRAM2:          0 GB       512 KB      0.00%
            ITCM:          0 GB       256 KB      0.00%
            DTCM:       13908 B       256 KB      5.31%
        IDT_LIST:          0 GB         2 KB      0.00%
collect2: error: ld returned 1 exit status

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt 4cc5102225 net: sockets: udp: test FIONREAD with ipv4 and ipv6 sockets
The FIONREAD ioctl (or rather ZFD_IOCTL_FIONREAD) returns the
number of bytes available on the socket that can be read
immediately.

Test that the ioctl behaves according to the expectation.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt 0f139736f3 tests: net: socket: udp: clear fdtable in after()
Add an `after()` function that is executed after each test in
the testsuite.

Previously, even if one one test failed, it would calls almost
all subsequent tests to fail. This way, other tests can still
succeed.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt e7182beb40 tests: net: socket: tcp: clear fdtable in after()
Add an `after()` function that is executed after each test in
the testsuite.

Previously, even if one one test failed, it would calls almost
all subsequent tests to fail. This way, other tests can still
succeed.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt 37ca8e0697 net: sockets: tcp: test FIONREAD with ipv4 and ipv6 TCP sockets
The FIONREAD ioctl (or rather ZFD_IOCTL_FIONREAD) returns the
number of bytes available on the socket that can be read
immediately.

Test that the ioctl behaves according to the expectation.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt f1d7c0b196 tests: net: socketpair: use a test fixture to deduplicate code
A fair bit of setup / teardown code was being duplicated in many
test cases in the socketpair testsuite.

Take advantage of the `setup()`, `before()`, and `after()`
functions in the new ZTest API.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt 2116c553a1 tests: net: socketpair: add fionread test
Add a test to exercise
`zsock_ioctl(fd, ZFD_IOCTL_FIONREAD, &avail)`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt 0f143c9ec9 tests: net: socketpair: reduce requirements for test
Reduce additional requirements for the socketpair testsuite.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Daniel Leung efeb2d13a7 tests: net: renames shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:43 +00:00
Sjors Hettinga 9d2c17dee2 tests: net: tcp: Default disable logging in TCP socket test
Accidentally statements to enable logging in the TCP socket test
where pushed. This broke some tests running on real devices due
to the additional code size.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-09 08:34:06 +00:00
Benjamin Perseghetti 79796d5c74 tests: net/socket/socketpair: exclude vmu and 1160
This has failed in repeated CI runs. Filed an issue
for having it checked. Excluding it until it's
fixed.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
2023-08-08 12:09:10 -05:00
Sjors Hettinga 5b640ec9db net: tcp: Implement TCP new Reno collision avoidance
To avoid a TCP connection from collapsing a link, implement a collision
avoidance algorithm. Initially TCP new Reno is implemented for its
simplicity.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-08-04 15:05:17 +02:00
Florian Grandel a4cd5cee40 drivers: ieee802154: consistent high res timestamps
The IEEE 802.15.4 API and networking subsystem were using several
inconsistent timestamp resolutions and types. This change defines all
timestamps with nanosecond resolution and reduces the number of
available types to represent timestamps to two:
* `struct net_ptp_time` for PTP timestamps
* `net_time_t` for all other high resolution timestamps

All timestamps (including PTP timestamps) are now referred to a
"virtual" local network subsystem clock source based on the well-defined
types above. It is the responsibility of network subsystem L2/driver
implementations (notably Ethernet and IEEE 802.15.4 L2 stacks) to ensure
consistency of all timestamps and radio timer values exposed by the
driver API to such a network subsystem uptime reference clock
independent of internal implementation details.

The "virtual" network clock source may be implemented based on arbitrary
hardware peripherals (e.g. a coarse low power RTC counter during sleep
time plus a high resolution/high precision radio timer while receiving
or sending). Such implementation details must be hidden from API
clients, as if the driver used a single high resolution clock source
instead.

For IEEE 802.15.4, whenever timestamps refer to packet send or receive
times, they are measured when the end of the IEEE 802.15.4 SFD (message
timestamp point) is present at the local antenna (reference plane).

Due to its limited range of ~290 years, net_time_t timestamps (and
therefore net_pkt timestamps and times) must not be used to represent
absolute points in time referred to an external epoch independent of
system uptime (e.g.  UTC, TAI, PTP, NTP, ...).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-28 09:06:35 +00:00
Robert Lubos cf15f0e48e tests: net: socket: tls: Verify accept is interrupted correctly on close
Add similar test as for TCP, that verifies that accept() call is
interrupted correctly when the socket is closed from another thread.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-29 14:34:03 -04:00
Robert Lubos af8c980e51 tests: net: socket: tcp: Verify accept is interrupted correctly on close
Add test that verifies that accept() call is interrupted correctly when
the socket is closed from another thread.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-29 14:34:03 -04:00
Robert Lubos 1d5b3af3c1 tests: net: socket: tcp: Verify recv is interrupted correctly on close
Add test that verifies that recv() call is interrupted correctly when
the socket is closed from another thread.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-05-26 09:05:12 -04:00
Anas Nashif 75c11c0564 tests: net: socket: fix test identifier
Remove definition of testcases in yaml file, those are now detected from
binary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-25 04:44:11 -04:00
Sjors Hettinga a28a656aa0 net: tcp: Avoid double acknowlegding retransmitted data
In the FIN_WAIT_1 any incoming data is dropped, but anknowledged. Add a
check to see if the data is already acknowleged to prevent double
acknowledging of the data and bringing the acknowlegde counter out of
sync. When the acknowledge counter gets out of sync, the connection will
never properly terminate any more.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
2023-05-15 15:25:51 +02:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Joshua Lilly f12ffaea1a tests: net: Disable test for mps2_an385
This test seems to run out of memory for this platform.
Temp. disabling it.

Signed-off-by: Joshua Lilly <jgl@meta.com>
2023-04-28 02:26:26 -04:00
Gerard Marull-Paretas 1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Daniel Nejezchleb 42854bdf7b tests: net: socket: asynchronous connect
Added tests to check async socket connect

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2023-04-17 11:35:20 +02:00
Kenny Johansson 76e2b346e5 tests: net: Set explicit loopback MTU for TCP tests
Set explicit loopback MTU for TCP tests for clarity,
 and to avoid breaking tests if changed elsewhere.

Signed-off-by: Kenny Johansson <wirehell@gmail.com>
2023-04-17 10:17:09 +02:00
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