casaroli opened a new pull request, #4001: URL: https://github.com/apache/nuttx-apps/pull/4001
depends-on: apache/nuttx/pull/21612 ## Summary No test in nuttx-apps covers UDP sockets of `AF_INET` and `AF_INET6` on one port. This PR adds the cmocka program `cmocka_net_udp` to `testing/nettest`, in a new directory `udp/`, under `CONFIG_TESTING_NET_UDP` (default y, like the other nettest programs). It runs over the loopback device. The 23 tests: - `IPV6_V6ONLY`: `test_udp_v6only_default` (0 by default), `_mapped` (without it, an IPv6 socket on `[::]` gets an IPv4 datagram from an IPv4-mapped address), `_set0` (1 then 0 before `bind()`: IPv4 again), `_set1` (with it, no IPv4 datagram), `_both` (an IPv6 socket with it, then an IPv4 socket on the same port: the IPv4 datagram goes to the IPv4 socket), `_send` (with it, `sendto()` and `connect()` to `::ffff:127.0.0.1` give `ENETUNREACH`), `_bound` (after `bind()`, setting it gives `EINVAL`); with `NET_TCP` and `NET_TCPBACKLOG`: `_tcp_set1`, `_tcp_set0` (`ENOPROTOOPT`, get 1), `_tcp_ipv4` (an IPv6 listener gets no IPv4 connection), `_tcp_bound` (`EINVAL` after `bind()`). - Delivery: `test_udp_family_alone` (an IPv4 socket gets no IPv6 datagram), `_both` (an IPv4 socket and an IPv6 socket with `IPV6_V6ONLY` on one port: the IPv6 datagram goes to the IPv6 socket), `_v6addr` (an IPv6 socket on `::1` gets no IPv4 datagram), `_connect` (after `connect()` to `[::]`, a datagram goes to `::1`), `_sendto6` and `_sendto4` (`sendto()` to `[::]` and to `0.0.0.0` without `connect()` reach the loopback address). - `bind()`: `test_udp_bind_v6_v4` and `_v4_v6` (a dual-stack IPv6 socket and an IPv4 socket on one port: the second `bind()` gives `EADDRINUSE`, both orders), `_v6only_v4` and `_v4_v6only` (with `IPV6_V6ONLY`, both binds succeed), `_reuse` (with `SO_REUSEADDR` on both, both binds succeed), `_v6addr` (an IPv6 socket on `::1` next to an IPv4 socket on the same port). Each test keeps its sockets in the cmocka state, and the teardown closes them, also when an assertion ends the test. The fix is the nuttx PR in the depends-on line. ## Impact New test only. The option is `default y`, as the other nettest options, and depends on `NET_UDP`, `NET_IPv4`, `NET_IPv6`, `NET_LOOPBACK` and `NET_SOCKOPTS`. The other nettest programs do not change. No documentation change. ## Testing qemu-armv8a (arm64, HVF, 1 CPU), make, apps on 19cbea35a with this PR. knsh: kernel build, the program built by `make import` and run from `/system/bin`. nsh: flat build, the program as a builtin. Options: `NET_IPv4`, `NET_IPv6`, `NET_LOOPBACK`, `NET_TCP`, `NET_UDP`, `NET_SOCKOPTS`, `DEBUG_ASSERTIONS` and others of a shared network rig (`NET_UDP_WRITE_BUFFERS` in knsh only); for cmocka `ALLOW_MIT_COMPONENTS`, `LIBC_REGEX` and `ARCH_SETJMP_H`; `TESTING_NET_TEST` and `TESTING_NET_UDP`. `TESTING_NET_OTHERS` is off: in the kernel build `others/test_others_bufpool.c` does not find `../../nuttx/net/utils/utils.h` (older than this PR). | Configuration | nuttx master c8c0661c997 | the nuttx PR of branch udp-dualstack-up | |---|---|---| | qemu-armv8a:knsh | 23 run, 4 passed, 19 failed | 23 run, 23 passed | | qemu-armv8a:nsh | 23 run, 4 passed, 19 failed | 23 run, 23 passed | On master, `test_udp_v6only_mapped`, `test_udp_v6only_tcp_ipv4`, `test_udp_bind_reuse` and `test_udp_bind_v6addr` pass: they check behaviour that the nuttx PR keeps. Builds: qemu-armv8a:netnsh with `EXTRAFLAGS=-Werror` (make) with `cmocka_net_udp`; CMake (Ninja) with an earlier version of this PR with the same build files. `tools/checkpatch.sh -c -u -m -g` passes. Not run: the protected build, sim, other arches. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
