Skip to content

Commit 6ac2ab7

Browse files
rluboskartben
authored andcommitted
tests: net: misc: Use different subnets on test interfaces
The test interfaces registered addresses within the same subnet. As now only the subnet part of the address is verified when choosing source address or interface, it was not deterministic which interface would be selected. Therefore, make the two interfaces use two different subnets so that tests that verified which address/interface was used work reliably as earlier. Signed-off-by: Robert Lubos <[email protected]>
1 parent a32d339 commit 6ac2ab7

File tree

1 file changed

+4
-4
lines changed
  • tests/net/socket/misc/src

1 file changed

+4
-4
lines changed

tests/net/socket/misc/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ ZTEST_USER(socket_misc_test_suite, test_inet_pton)
5353
zassert_equal(res, 0, "");
5454
}
5555

56-
#define TEST_MY_IPV4_ADDR "192.0.2.1"
56+
#define TEST_MY_IPV4_ADDR "192.0.1.1"
5757
#define TEST_PEER_IPV4_ADDR "192.0.2.2"
5858
#define TEST_MY_IPV6_ADDR "2001:db8::1"
5959
#define TEST_PEER_IPV6_ADDR "2001:db8::2"
6060

6161
static struct in6_addr my_ipv6_addr1 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0,
6262
0, 0, 0, 0, 0, 0, 0, 0x1 } } };
63-
static struct in_addr my_ipv4_addr1 = { { { 192, 0, 2, 1 } } };
63+
static struct in_addr my_ipv4_addr1 = { { { 192, 0, 1, 1 } } };
6464

6565
static struct in6_addr my_ipv6_addr2 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0,
6666
0, 0, 0, 0, 0, 0, 0, 0x2 } } };
@@ -300,7 +300,7 @@ void test_ipv4_so_bindtodevice(void)
300300
struct sockaddr_in peer_addr_1 = {
301301
.sin_family = AF_INET,
302302
.sin_port = htons(DST_PORT),
303-
.sin_addr = { { { 192, 0, 2, 1 } } },
303+
.sin_addr = { { { 192, 0, 1, 1 } } },
304304
};
305305
struct sockaddr_in peer_addr_2 = {
306306
.sin_family = AF_INET,
@@ -729,7 +729,7 @@ void test_ipv4_mapped_to_ipv6_server(void)
729729
*/
730730
srv_addr.sa_family = AF_INET;
731731
net_sin(&srv_addr)->sin_port = htons(MAPPING_PORT);
732-
ret = zsock_inet_pton(AF_INET, "192.0.2.1",
732+
ret = zsock_inet_pton(AF_INET, "192.0.1.1",
733733
&net_sin(&srv_addr)->sin_addr);
734734
zassert_equal(ret, 1, "inet_pton failed");
735735

0 commit comments

Comments
 (0)