diff options
Diffstat (limited to 'tests/t_socket.c')
| -rw-r--r-- | tests/t_socket.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/t_socket.c b/tests/t_socket.c index 8e917a3..6f07f95 100644 --- a/tests/t_socket.c +++ b/tests/t_socket.c | |||
| @@ -342,6 +342,24 @@ static void case_bind_failure(void) { | |||
| 342 | CHECK_INT(next_descriptor(), before); | 342 | CHECK_INT(next_descriptor(), before); |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | /* The holder binds the way the tracker does, which lets a second socket in | ||
| 346 | beside it, and that is what the probe is there to see through. */ | ||
| 347 | static void case_a_taken_udp_address_is_noticed(void) { | ||
| 348 | char ip[16]; | ||
| 349 | uint16_t port; | ||
| 350 | int holder; | ||
| 351 | |||
| 352 | test_case("a udp address somebody holds is reported as taken"); | ||
| 353 | holder = socket_udp_bind(ip_loopback, 0, SOCKET_SHARED); | ||
| 354 | CHECK(holder != -1); | ||
| 355 | bound_address(holder, ip, &port); | ||
| 356 | CHECK_INT(socket_udp_is_taken(ip_loopback, port), 1); | ||
| 357 | |||
| 358 | test_case("and as free again once it is let go"); | ||
| 359 | close(holder); | ||
| 360 | CHECK_INT(socket_udp_is_taken(ip_loopback, port), 0); | ||
| 361 | } | ||
| 362 | |||
| 345 | #ifdef WANT_SYNC_LIVE | 363 | #ifdef WANT_SYNC_LIVE |
| 346 | /* Reading an IPv4 multicast option back: Linux answers with an int, the BSDs | 364 | /* Reading an IPv4 multicast option back: Linux answers with an int, the BSDs |
| 347 | with a single byte, so ask how much was written. */ | 365 | with a single byte, so ask how much was written. */ |
| @@ -391,6 +409,7 @@ void test_socket(void) { | |||
| 391 | case_deferred_accept(); | 409 | case_deferred_accept(); |
| 392 | case_connect_refused(); | 410 | case_connect_refused(); |
| 393 | case_bind_failure(); | 411 | case_bind_failure(); |
| 412 | case_a_taken_udp_address_is_noticed(); | ||
| 394 | #ifdef WANT_SYNC_LIVE | 413 | #ifdef WANT_SYNC_LIVE |
| 395 | case_mcast_sender(); | 414 | case_mcast_sender(); |
| 396 | #endif | 415 | #endif |
