From 6ac2ab70a2a782a93feef120a8e513272a591a4b Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Thu, 28 Nov 2024 12:25:34 +0100 Subject: [PATCH] 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 --- tests/net/socket/misc/src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/net/socket/misc/src/main.c b/tests/net/socket/misc/src/main.c index 32b0430aeab..941e72c32bf 100644 --- a/tests/net/socket/misc/src/main.c +++ b/tests/net/socket/misc/src/main.c @@ -53,14 +53,14 @@ ZTEST_USER(socket_misc_test_suite, test_inet_pton) zassert_equal(res, 0, ""); } -#define TEST_MY_IPV4_ADDR "192.0.2.1" +#define TEST_MY_IPV4_ADDR "192.0.1.1" #define TEST_PEER_IPV4_ADDR "192.0.2.2" #define TEST_MY_IPV6_ADDR "2001:db8::1" #define TEST_PEER_IPV6_ADDR "2001:db8::2" static struct in6_addr my_ipv6_addr1 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; -static struct in_addr my_ipv4_addr1 = { { { 192, 0, 2, 1 } } }; +static struct in_addr my_ipv4_addr1 = { { { 192, 0, 1, 1 } } }; static struct in6_addr my_ipv6_addr2 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }; @@ -300,7 +300,7 @@ void test_ipv4_so_bindtodevice(void) struct sockaddr_in peer_addr_1 = { .sin_family = AF_INET, .sin_port = htons(DST_PORT), - .sin_addr = { { { 192, 0, 2, 1 } } }, + .sin_addr = { { { 192, 0, 1, 1 } } }, }; struct sockaddr_in peer_addr_2 = { .sin_family = AF_INET, @@ -729,7 +729,7 @@ void test_ipv4_mapped_to_ipv6_server(void) */ srv_addr.sa_family = AF_INET; net_sin(&srv_addr)->sin_port = htons(MAPPING_PORT); - ret = zsock_inet_pton(AF_INET, "192.0.2.1", + ret = zsock_inet_pton(AF_INET, "192.0.1.1", &net_sin(&srv_addr)->sin_addr); zassert_equal(ret, 1, "inet_pton failed");