Repository navigation
Conversation
This was referenced Nov 3, 2026
No test in apps covers connect() and poll() of Unix domain datagram sockets. Add the cmocka test cmocka_net_local_dgram (CONFIG_TESTING_NET_LOCAL_DGRAM). It has 20 cases: - connect() sets the destination, connect(AF_UNSPEC) removes it and a second connect() changes it. - send(), write() and sendto() with a NULL address go to the destination. getpeername() gives its name. - A connected socket takes datagrams from its peer only. - poll() and select() report POLLIN and POLLOUT. poll() wakes up when a datagram arrives. A datagram that is too large causes no POLLHUP. - recv() with MSG_DONTWAIT or O_NONBLOCK fails with EAGAIN. - connect() to a missing name fails with ENOENT, connect() to a regular file with ECONNREFUSED. send() after the receiver is closed fails with ECONNREFUSED. - connect() and send() to an abstract name. A watchdog (alarm()) stops the program if a case does not end. The optional argument is a writable directory for the socket names. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
apps-local-dgram-test-up
branch
from
November 4, 2026 09:33
6830185 to
8e415df
Compare
xiaoxiang781216
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
No test in nuttx-apps covers
connect()andpoll()of Unix domain datagram sockets. This PR adds the cmocka testcmocka_net_local_dgramtotesting/nettest/local(CONFIG_TESTING_NET_LOCAL_DGRAM), next tocmocka_net_local.The 20 cases:
connect()to a bound socket;getpeername();send(),write()andsendto()with a NULL address go to the peer;poll(POLLIN)with no datagram, after a send and while a thread sends after 200 ms; noPOLLHUPwhen a datagram is too large;poll(POLLOUT);select();recv(MSG_DONTWAIT)andO_NONBLOCKon an empty socket (EAGAIN); a connected socket takes datagrams from its peer only;connect(AF_UNSPEC)removes the peer; a secondconnect()changes it;ENOENTfor a missing name;ECONNREFUSEDfor a regular file and after the receiver is closed; an abstract name.Each case makes its own sockets in its setup, so a failed case does not change the next one. A watchdog (
alarm(), 10 s) stops the program when a case does not end. The optional argument is a writable directory for the socket names (defaultP_tmpdir).depends-on: apache/nuttx/pull/21416
Impact
New test only,
default yunderTESTING_NET_TEST, asTESTING_NET_LOCALandTESTING_NET_OTHERS. It depends onNET_LOCAL && NET_LOCAL_DGRAM,!DISABLE_PTHREADand!DISABLE_POSIX_TIMERS. No defconfig enablesTESTING_NET_TEST, so no CI build changes. No change to the other nettest programs. The nettest page in Documentation/applications/testing describes the programs in general; no change.Testing
QEMU qemu-armv8a with HVF, 1 CPU, with
NET,NET_LOCAL,NET_LOCAL_STREAM,NET_LOCAL_DGRAM,PIPES,NETDEV_LATEINIT,NET_SOCKOPTS, the cmocka options andCONFIG_TESTING_NET_LOCAL_DGRAM=y. knsh runs the test as an ELF in/system/bin(names in/system), nsh (flat) as a builtin (names in/tmp):cmocka_net_local_dgramon knsh (kernel)dontwait,nonblock), 6 FAIL, 12 setup errors:connect()fails withENOSYScmocka_net_local_dgramon nsh (flat)dontwait,nonblock), 6 FAIL, 12 setup errors:connect()fails withENOSYSmps2-an500:knsh (protected build, Cortex-M7, QEMU TCG, names in a tmpfs on
/tmp) on apache/nuttx#21416: 20/20 PASS, ostest status 0.Builds with
CONFIG_TESTING_NET_LOCAL_DGRAM=yandEXTRAFLAGS="-Wno-cpp -Werror"on apache/nuttx#21416, each OK, no warning in the test: qemu-armv8a:nsh (make and CMake), rv-virt:nsh64, mps2-an500:knsh (protected). qemu-armv8a:nsh withCONFIG_NET_LOCAL_DGRAMoff: the option is off and nothing of the test is built. On master the test also builds and runs; only the cases fail.tools/checkpatch.sh -c -u -m -gpasses.