casaroli opened a new pull request, #4103:
URL: https://github.com/apache/nuttx-apps/pull/4103
## Summary
The loopback server of `cmocka_net_tcp` (`nettest_lo_listener()`) gives
`select()` a timeout with `tv_sec = -1` to wait with no end. Since apache/nuttx
03db4966d8c ("fs/vfs: validate nfds bounds and timeout in select and poll"),
`select()` returns `EINVAL` for a negative timeout, as POSIX requires. The
server thread then ends at once: `test_tcp_connect_ipv4` and
`test_tcp_connect_ipv6` fail with `ECONNREFUSED`, and so does the group
teardown.
The server also ends when `select()` fails with `EINTR`. A signal to the
test process can go to the server thread: `test_tcp_reset_send` gets `SIGPIPE`.
The cases after it and the group teardown then fail, in flat and kernel builds.
This PR gives `select()` a NULL timeout and calls `select()` again after
`EINTR`. The first commit fixes the old nxstyle errors of the file (checkpatch
checks the whole file): each case of `nettest_lo_addr()` gets its own block, so
a declaration does not follow a case label.
## Impact
Only `testing/nettest/utils/nettest_tcpserver.c`. No other app in the tree
passes a negative timeout to `select()` (`git grep` for negative `tv_sec` and
`tv_usec`).
## Testing
`cmocka_net_tcp`, run twice in one boot, qemu-armv8a under HVF, NuttX master
0e350f26fb6:
| | apps master | without the last commit | this PR |
|---|---|---|---|
| knsh, 1 CPU | `test_tcp_connect_ipv4`, `test_tcp_connect_ipv6` and the
group teardown fail (`ECONNREFUSED`) | the group teardown fails | 14 of 14
PASS, both runs |
| knsh, 4 CPUs | | the group teardown fails; the second run stops the kernel
with an assertion at `tcp/tcp_conn.c:820` | 14 of 14 PASS, both runs |
| flat nsh, 1 CPU | | the group teardown fails | 13 of 14 PASS, both runs
(`test_tcp_reset_send`, below) |
In the flat build `test_tcp_reset_send` fails before and after this PR: the
`SIGPIPE` handler does not run in the thread that sends. That is a NuttX defect
(the signal goes to another thread of the process), not a defect of the server.
`tools/checkpatch.sh -c -u -m -g` passes.
--
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]