Repository navigation
Commit 0efd6e0
committed
testing/nettest: Add TCP bind() and listen() cases.
Six cases in cmocka_net_tcp (IPv4 on the loopback address), with the
rules of Linux:
- test_tcp_bind_reuseaddr_timewait: a server closes first, so its
connection stays in TIME_WAIT. bind() of the port fails with
EADDRINUSE without SO_REUSEADDR and succeeds with it.
- test_tcp_bind_reuseaddr_connected: a connection stays after its
listener closed. bind() with SO_REUSEADDR succeeds only if the
listener had SO_REUSEADDR too.
- test_tcp_bind_reuseaddr_listener: bind() of the port of a listener
fails with EADDRINUSE, also with SO_REUSEADDR.
- test_tcp_accept_inherit: an accepted socket has the SO_KEEPALIVE,
TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT values of its listener,
and its MSS is not larger than TCP_MAXSEG of the listener.
- test_tcp_listen_again: listen() on a listening socket returns 0, sets
the new backlog and keeps the connection in the queue.
- test_tcp_listen_connected: listen() on a connected socket fails with
EINVAL.
The three bind() cases and test_tcp_accept_inherit need
CONFIG_NET_SOCKOPTS. Its TCP_MAXSEG check needs
CONFIG_NET_TCPPROTO_OPTIONS and its TCP_KEEP* checks need
CONFIG_NET_TCP_KEEPALIVE. A teardown closes the sockets that a failed
case leaves open.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>1 parent 72e5a3c commit 0efd6e0
5 files changed
Lines changed: 600 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
45 | 65 | | |
46 | 66 | | |
47 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
74 | 124 | | |
75 | 125 | | |
76 | 126 | | |
| |||
0 commit comments