cederom commented on PR #4168:
URL: https://github.com/apache/nuttx-apps/pull/4168#issuecomment-7247843147
A few comments:
1. **`cmocka_net_local` now needs pthreads.** `test_local_accept.c` calls
`pthread_create()` and is built only on `CONFIG_NET_LOCAL_STREAM &&
CONFIG_NET_SOCKOPTS`. `TESTING_NET_LOCAL` does not depend on
`!DISABLE_PTHREAD`. Before this PR, `cmocka_net_local` used no threads outside
`TESTING_NET_LOCAL_DGRAM`, and that option depends on `!DISABLE_PTHREAD`. So a
`CONFIG_DISABLE_PTHREAD` config with local stream sockets would fail to link.
Please add `!CONFIG_DISABLE_PTHREAD` to the three guards (Makefile,
CMakeLists.txt, `test_local.c`). `cmocka_net_tcp` already uses threads in other
cases, so the TCP side is fine as it is.
2. **Kernel behaviour from #22430 that no test covers yet:**
- `addrlen == 0`. The `fs/socket/accept` commit says the old code stopped
there in a build with assertions. A loop step with `*addrlen = 0` would check
that nothing is written and that `addrlen` comes back as `sizeof(struct
sockaddr_in)`.
- `addr` with `addrlen == NULL` gives `EFAULT`. On Linux this check
happens after the connection is taken off the queue, but on NuttX it happens
before. To keep the case portable, call it while a connection is pending, and
assert only `-1`/`EFAULT`, not the state of the queue afterwards.
- Optional: IPv6 truncation. A peer address is 28 bytes, so passing a
`struct sockaddr_in` buffer is the case programs actually hit. Also optional:
`sun_path` truncation for a local stream socket.
3. **Cleanup when `test_local_accept_rcvtimeo` fails early (nit).** If
`bind()`, `listen()` or `setsockopt()` fails, the listener stays open and the
socket name stays in `P_tmpdir`. `test_local_peercred` behaves the same way, so
this is consistent with the existing code. It only matters if more cases get
added to this binary.
4. **Duplicated code (nit).** `test_local_late()` and `tcp_bl_late()` are
the same, apart from the socket family and the address, and
`TEST_ACCEPT_TIMEO`/`TEST_ACCEPT_LATE` are defined twice. One helper in
`utils/` that takes a `sockaddr` and its length would remove the copy, but it
can also stay as it is.
5. **Commit message (nit).** "waiting for ever" should be "waiting forever".
--
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]