diff options
| author | Michael Biebl <biebl@debian.org> | 2025-02-12 13:46:50 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2025-02-12 13:46:50 +0100 |
| commit | 8bdf070ff046f482f6eb5e2b15ebc216f5d1e3da (patch) | |
| tree | f706478d189d54c6532e8863d4b0d5ff5575af60 /src/core/platform/tests | |
| parent | 818258cf34b83fbc754633295e1052d4752d7b15 (diff) | |
New upstream version 1.51.90 upstream/1.51.90
Diffstat (limited to 'src/core/platform/tests')
| -rw-r--r-- | src/core/platform/tests/test-common.c | 24 | ||||
| -rw-r--r-- | src/core/platform/tests/test-common.h | 32 | ||||
| -rw-r--r-- | src/core/platform/tests/test-link.c | 34 | ||||
| -rw-r--r-- | src/core/platform/tests/test-route.c | 30 | ||||
| -rw-r--r-- | src/core/platform/tests/test-tc.c | 2 |
5 files changed, 62 insertions, 60 deletions
diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c index 99b8bc45..26f8b26b 100644 --- a/src/core/platform/tests/test-common.c +++ b/src/core/platform/tests/test-common.c @@ -224,7 +224,7 @@ _nmtstp_platform_ip_addresses_assert(const char *filename, else g_error("%s:%d: invalid IP address in argument: %s", filename, lineno, addrstr); - addrs_bin[i] = (IPAddressesAssertData){ + addrs_bin[i] = (IPAddressesAssertData) { .addr_family = addr_family, .addr = a, .found = FALSE, @@ -1117,7 +1117,7 @@ again: link = nmtstp_link_gre_add(NULL, EX, test_ifname, - &((const NMPlatformLnkGre){ + &((const NMPlatformLnkGre) { .local = nmtst_inet4_from_string("192.168.233.204"), .remote = nmtst_inet4_from_string("172.168.10.25"), .parent_ifindex = 0, @@ -1129,7 +1129,7 @@ again: link = nmtstp_link_ipip_add(NULL, EX, test_ifname, - &((const NMPlatformLnkIpIp){ + &((const NMPlatformLnkIpIp) { .local = nmtst_inet4_from_string("1.2.3.4"), .remote = nmtst_inet4_from_string("5.6.7.8"), .parent_ifindex = 0, @@ -1140,7 +1140,7 @@ again: link = nmtstp_link_ip6tnl_add(NULL, EX, test_ifname, - &((const NMPlatformLnkIp6Tnl){ + &((const NMPlatformLnkIp6Tnl) { .local = nmtst_inet6_from_string("fd01::15"), .remote = nmtst_inet6_from_string("fd01::16"), .tclass = 20, @@ -1152,7 +1152,7 @@ again: link = nmtstp_link_ip6gre_add(NULL, EX, test_ifname, - &((const NMPlatformLnkIp6Tnl){ + &((const NMPlatformLnkIp6Tnl) { .local = nmtst_inet6_from_string("fd01::42"), .remote = nmtst_inet6_from_string("fd01::aaaa"), .tclass = 21, @@ -1163,7 +1163,7 @@ again: link = nmtstp_link_sit_add(NULL, EX, test_ifname, - &((const NMPlatformLnkSit){ + &((const NMPlatformLnkSit) { .local = nmtst_inet4_from_string("192.168.200.1"), .remote = nmtst_inet4_from_string("172.25.100.14"), .ttl = 0, @@ -1174,7 +1174,7 @@ again: link = nmtstp_link_vti_add(NULL, EX, test_ifname, - &((const NMPlatformLnkVti){ + &((const NMPlatformLnkVti) { .local = nmtst_inet4_from_string("192.168.212.204"), .remote = nmtst_inet4_from_string("172.168.11.25"), .ikey = 12, @@ -1184,7 +1184,7 @@ again: link = nmtstp_link_vti6_add(NULL, EX, test_ifname, - &((const NMPlatformLnkVti6){ + &((const NMPlatformLnkVti6) { .local = nmtst_inet6_from_string("fd01::1"), .remote = nmtst_inet6_from_string("fd02::2"), .ikey = 13, @@ -1891,11 +1891,11 @@ nmtstp_ip4_address_add(NMPlatform *platform, external_command, TRUE, ifindex, - &((NMIPAddr){ + &((NMIPAddr) { .addr4 = address, }), plen, - &((NMIPAddr){ + &((NMIPAddr) { .addr4 = peer_address, }), lifetime, @@ -3592,7 +3592,7 @@ nmtstp_acd_defender_new(int ifindex, in_addr_t ip_addr, const NMEtherAddr *mac_a g_assert_cmpint(r, ==, 0); g_assert(probe_config); - n_acd_probe_config_set_ip(probe_config, (struct in_addr){ip_addr}); + n_acd_probe_config_set_ip(probe_config, (struct in_addr) {ip_addr}); n_acd_probe_config_set_timeout(probe_config, 0); r = n_acd_probe(nacd, &probe, probe_config); @@ -3600,7 +3600,7 @@ nmtstp_acd_defender_new(int ifindex, in_addr_t ip_addr, const NMEtherAddr *mac_a g_assert(probe); defender = g_slice_new(NMTstpAcdDefender); - *defender = (NMTstpAcdDefender){ + *defender = (NMTstpAcdDefender) { .ifindex = ifindex, .ip_addr = ip_addr, .nacd = g_steal_pointer(&nacd), diff --git a/src/core/platform/tests/test-common.h b/src/core/platform/tests/test-common.h index 12d6e7ce..85ed7961 100644 --- a/src/core/platform/tests/test-common.h +++ b/src/core/platform/tests/test-common.h @@ -372,21 +372,21 @@ void _nmtstp_platform_ip_addresses_assert(const char *filename, guint addrs_len, const char *const *addrs); -#define nmtstp_platform_ip_addresses_assert(self, \ - ifindex, \ - force_exact_4, \ - force_exact_6, \ - ignore_ll6, \ - ...) \ - _nmtstp_platform_ip_addresses_assert(__FILE__, \ - __LINE__, \ - (self), \ - (ifindex), \ - (force_exact_4), \ - (force_exact_6), \ - (ignore_ll6), \ - NM_NARG(__VA_ARGS__), \ - ((const char *const[]){"dummy", ##__VA_ARGS__, NULL}) \ +#define nmtstp_platform_ip_addresses_assert(self, \ + ifindex, \ + force_exact_4, \ + force_exact_6, \ + ignore_ll6, \ + ...) \ + _nmtstp_platform_ip_addresses_assert(__FILE__, \ + __LINE__, \ + (self), \ + (ifindex), \ + (force_exact_4), \ + (force_exact_6), \ + (ignore_ll6), \ + NM_NARG(__VA_ARGS__), \ + ((const char *const[]) {"dummy", ##__VA_ARGS__, NULL}) \ + 1) /*****************************************************************************/ @@ -540,7 +540,7 @@ gboolean nmtstp_ensure_module(const char *module_name); /*****************************************************************************/ #define nmtst_object_new_mptcp_addr(...) \ - nmp_object_new(NMP_OBJECT_TYPE_MPTCP_ADDR, &((const NMPlatformMptcpAddr){__VA_ARGS__})) + nmp_object_new(NMP_OBJECT_TYPE_MPTCP_ADDR, &((const NMPlatformMptcpAddr) {__VA_ARGS__})) /*****************************************************************************/ diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index bcb135d3..4cadfe4d 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -174,7 +174,7 @@ software_add(NMLinkType link_type, const char *name) return NMTST_NM_ERR_SUCCESS(nm_platform_link_vlan_add(NM_PLATFORM_GET, name, parent_ifindex, - &((NMPlatformLnkVlan){ + &((NMPlatformLnkVlan) { .id = VLAN_ID, .protocol = ETH_P_8021Q, }), @@ -289,7 +289,7 @@ test_port(int controller, int port_type, SignalData *controller_changed) prio_supported = (lnk->mode == 1); prio_has = nmtst_get_rand_bool() && prio_supported; - bond_port = (NMPlatformLinkBondPort){ + bond_port = (NMPlatformLinkBondPort) { .queue_id = 5, .prio_has = prio_has, .prio = prio_has ? 6 : 0, @@ -315,7 +315,7 @@ test_port(int controller, int port_type, SignalData *controller_changed) lnk = nm_platform_link_get_lnk_bridge(NM_PLATFORM_GET, controller, NULL); g_assert(lnk); - bridge_port = (NMPlatformLinkBridgePort){ + bridge_port = (NMPlatformLinkBridgePort) { .path_cost = 100, .priority = 614, .hairpin = 0, @@ -724,7 +724,7 @@ test_bridge_addr(void) g_assert_cmpint(plink->l_address.len, ==, sizeof(addr)); g_assert(!memcmp(plink->l_address.data, addr, sizeof(addr))); - info_data = (const NMPlatformLinkSetBridgeInfoData){ + info_data = (const NMPlatformLinkSetBridgeInfoData) { .vlan_default_pvid_val = nmtst_rand_select(0, 5, 42, 1048), .vlan_default_pvid_has = nmtst_get_rand_bool(), .vlan_filtering_val = nmtst_get_rand_bool(), @@ -743,7 +743,7 @@ test_bridge_addr(void) "/sys/class/net/" DEVICE_NAME "/bridge/vlan_filtering", info_data.vlan_filtering_val && info_data.vlan_filtering_has ? "1" : "0"); - info_data = (const NMPlatformLinkSetBridgeInfoData){ + info_data = (const NMPlatformLinkSetBridgeInfoData) { .vlan_default_pvid_val = 55, .vlan_default_pvid_has = TRUE, .vlan_filtering_val = !info_data.vlan_filtering_val, @@ -1275,7 +1275,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode) peers = g_array_new(FALSE, TRUE, sizeof(NMPWireGuardPeer)); - lnk_wireguard = (NMPlatformLnkWireGuard){ + lnk_wireguard = (NMPlatformLnkWireGuard) { .listen_port = 50754, .fwmark = 0x1102, }; @@ -1295,7 +1295,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode) NMPWireGuardAllowedIP *allowed_ips; if ((i % 2) == 1) { - endpoint = (NMSockAddrUnion){ + endpoint = (NMSockAddrUnion) { .in = { .sin_family = AF_INET, @@ -1305,7 +1305,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode) }, }; } else { - endpoint = (NMSockAddrUnion){ + endpoint = (NMSockAddrUnion) { .in6 = { .sin6_family = AF_INET6, @@ -1337,7 +1337,7 @@ _test_wireguard_change(NMPlatform *platform, int ifindex, int test_mode) } } - peer = (NMPWireGuardPeer){ + peer = (NMPWireGuardPeer) { .persistent_keepalive_interval = 60 + i, .endpoint = endpoint, .allowed_ips = n_allowed_ips > 0 ? allowed_ips : NULL, @@ -1803,7 +1803,7 @@ test_software_detect(gconstpointer user_data) switch (test_data->test_mode) { case 0: - lnk_tun = (NMPlatformLnkTun){ + lnk_tun = (NMPlatformLnkTun) { .type = nmtst_get_rand_bool() ? IFF_TUN : IFF_TAP, .owner = owner_valid ? getuid() : 0, .owner_valid = owner_valid, @@ -2702,7 +2702,7 @@ test_link_set_properties(void) NMPlatformLinkChangeFlags flags; int ifindex; - props = (NMPlatformLinkProps){ + props = (NMPlatformLinkProps) { .tx_queue_length = 599, .gso_max_size = 10001, .gso_max_segments = 512, @@ -3814,7 +3814,7 @@ test_sysctl_set_async(void) cancellable = g_cancellable_new(); proc_writable = access(PATH, W_OK) == 0; - data = (SetAsyncData){ + data = (SetAsyncData) { .loop = loop, .path = PATH, .expected_success = proc_writable, @@ -3823,7 +3823,7 @@ test_sysctl_set_async(void) nm_platform_sysctl_set_async(PL, NMP_SYSCTL_PATHID_ABSOLUTE(PATH), - (const char *[]){"2", NULL}, + (const char *[]) {"2", NULL}, sysctl_set_async_cb, &data, cancellable); @@ -3831,7 +3831,7 @@ test_sysctl_set_async(void) if (!nmtst_main_loop_run(loop, 1000)) g_assert_not_reached(); - data = (SetAsyncData){ + data = (SetAsyncData) { .loop = loop, .path = PATH, .expected_success = proc_writable, @@ -3840,7 +3840,7 @@ test_sysctl_set_async(void) nm_platform_sysctl_set_async(PL, NMP_SYSCTL_PATHID_ABSOLUTE(PATH), - (const char *[]){"2", "0", "1", "0", "1", NULL}, + (const char *[]) {"2", "0", "1", "0", "1", NULL}, sysctl_set_async_cb, &data, cancellable); @@ -3867,7 +3867,7 @@ test_sysctl_set_async_fail(void) loop = g_main_loop_new(NULL, FALSE); cancellable = g_cancellable_new(); - data = (SetAsyncData){ + data = (SetAsyncData) { .loop = loop, .path = PATH, .expected_success = FALSE, @@ -3875,7 +3875,7 @@ test_sysctl_set_async_fail(void) nm_platform_sysctl_set_async(PL, NMP_SYSCTL_PATHID_ABSOLUTE(PATH), - (const char *[]){"2", NULL}, + (const char *[]) {"2", NULL}, sysctl_set_async_cb, &data, cancellable); diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c index 9aa21a9a..a05362f2 100644 --- a/src/core/platform/tests/test-route.c +++ b/src/core/platform/tests/test-route.c @@ -574,6 +574,7 @@ test_ip4_route_get(void) result = nm_platform_ip_route_get(NM_PLATFORM_GET, AF_INET, &a, + 0, nmtst_get_rand_uint32() % 2 ? 0 : ifindex, &route); @@ -638,7 +639,7 @@ test_ip4_route_options(gconstpointer test_data) switch (TEST_IDX) { case 1: - rts_add[rts_n++] = ((NMPlatformIP4Route){ + rts_add[rts_n++] = ((NMPlatformIP4Route) { .ifindex = IFINDEX, .rt_source = NM_IP_CONFIG_SOURCE_USER, .network = nmtst_inet4_from_string("172.16.1.0"), @@ -658,7 +659,7 @@ test_ip4_route_options(gconstpointer test_data) }); break; case 2: - addr[addr_n++] = ((NMPlatformIP4Address){ + addr[addr_n++] = ((NMPlatformIP4Address) { .ifindex = IFINDEX, .address = nmtst_inet4_from_string("172.16.1.5"), .peer_address = nmtst_inet4_from_string("172.16.1.5"), @@ -667,7 +668,7 @@ test_ip4_route_options(gconstpointer test_data) .preferred = NM_PLATFORM_LIFETIME_PERMANENT, .n_ifa_flags = 0, }); - rts_add[rts_n++] = ((NMPlatformIP4Route){ + rts_add[rts_n++] = ((NMPlatformIP4Route) { .ifindex = IFINDEX, .rt_source = NM_IP_CONFIG_SOURCE_USER, .network = nmtst_inet4_from_string("172.17.1.0"), @@ -676,7 +677,7 @@ test_ip4_route_options(gconstpointer test_data) .metric = 20, .n_nexthops = 1, }); - rts_add[rts_n++] = ((NMPlatformIP4Route){ + rts_add[rts_n++] = ((NMPlatformIP4Route) { .ifindex = IFINDEX, .rt_source = NM_IP_CONFIG_SOURCE_USER, .network = nmtst_inet4_from_string("172.19.1.0"), @@ -766,6 +767,7 @@ test_ip6_route_get(void) result = nm_platform_ip_route_get(NM_PLATFORM_GET, AF_INET6, a, + 0, nmtst_get_rand_uint32() % 2 ? 0 : ifindex, &route); @@ -801,7 +803,7 @@ test_ip6_route_options(gconstpointer test_data) switch (TEST_IDX) { case 1: - rts_add[rts_n++] = ((NMPlatformIP6Route){ + rts_add[rts_n++] = ((NMPlatformIP6Route) { .ifindex = IFINDEX, .rt_source = NM_IP_CONFIG_SOURCE_USER, .network = nmtst_inet6_from_string("2001:db8:a:b:0:0:0:0"), @@ -817,7 +819,7 @@ test_ip6_route_options(gconstpointer test_data) }); break; case 2: - addr[addr_n++] = ((NMPlatformIP6Address){ + addr[addr_n++] = ((NMPlatformIP6Address) { .ifindex = IFINDEX, .address = nmtst_inet6_from_string("2000::2"), .plen = 128, @@ -826,7 +828,7 @@ test_ip6_route_options(gconstpointer test_data) .preferred = NM_PLATFORM_LIFETIME_PERMANENT, .n_ifa_flags = 0, }); - rts_add[rts_n++] = ((NMPlatformIP6Route){ + rts_add[rts_n++] = ((NMPlatformIP6Route) { .ifindex = IFINDEX, .rt_source = NM_IP_CONFIG_SOURCE_USER, .network = nmtst_inet6_from_string("1010::1"), @@ -837,7 +839,7 @@ test_ip6_route_options(gconstpointer test_data) }); break; case 3: - addr[addr_n++] = ((NMPlatformIP6Address){ + addr[addr_n++] = ((NMPlatformIP6Address) { .ifindex = IFINDEX, .address = nmtst_inet6_from_string("2001:db8:8086::5"), .plen = 128, @@ -846,7 +848,7 @@ test_ip6_route_options(gconstpointer test_data) .preferred = NM_PLATFORM_LIFETIME_PERMANENT, .n_ifa_flags = 0, }); - rts_add[rts_n++] = ((NMPlatformIP6Route){ + rts_add[rts_n++] = ((NMPlatformIP6Route) { .ifindex = IFINDEX, .rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER), .network = nmtst_inet6_from_string("2001:db8:8086::"), @@ -854,7 +856,7 @@ test_ip6_route_options(gconstpointer test_data) .metric = 10021, .mss = 0, }); - rts_add[rts_n++] = ((NMPlatformIP6Route){ + rts_add[rts_n++] = ((NMPlatformIP6Route) { .ifindex = IFINDEX, .rt_source = nmp_utils_ip_config_source_round_trip_rtprot(NM_IP_CONFIG_SOURCE_USER), .network = nmtst_inet6_from_string("2001:db8:abad:c0de::"), @@ -1595,7 +1597,7 @@ test_rule(gconstpointer test_data) #define RR(...) \ nmp_object_new(NMP_OBJECT_TYPE_ROUTING_RULE, \ - (const NMPlatformObject *) &((NMPlatformRoutingRule){__VA_ARGS__})) + (const NMPlatformObject *) &((NMPlatformRoutingRule) {__VA_ARGS__})) objs = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref); @@ -1926,11 +1928,11 @@ test_blackhole(gconstpointer test_data) rtn_type = nmtst_rand_select(RTN_BLACKHOLE, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_THROW); if (IS_IPv4) { - rr.r4 = (const NMPlatformIP4Route){ + rr.r4 = (const NMPlatformIP4Route) { .type_coerced = nm_platform_route_type_coerce(rtn_type), }; } else { - rr.r6 = (const NMPlatformIP6Route){ + rr.r6 = (const NMPlatformIP6Route) { .type_coerced = nm_platform_route_type_coerce(rtn_type), .metric = 1000, }; @@ -1987,7 +1989,7 @@ again: if (p == -1) { static gsize lock; - const NMPlatformMptcpAddr mptcp_addr = (NMPlatformMptcpAddr){ + const NMPlatformMptcpAddr mptcp_addr = (NMPlatformMptcpAddr) { .id = 1, .addr_family = AF_INET, .addr.addr4 = nmtst_inet4_from_string("1.2.3.4"), diff --git a/src/core/platform/tests/test-tc.c b/src/core/platform/tests/test-tc.c index 832fbea6..dc4dafc0 100644 --- a/src/core/platform/tests/test-tc.c +++ b/src/core/platform/tests/test-tc.c @@ -16,7 +16,7 @@ qdisc_new(int ifindex, const char *kind, guint32 parent) NMPObject *obj; obj = nmp_object_new(NMP_OBJECT_TYPE_QDISC, NULL); - obj->qdisc = (NMPlatformQdisc){ + obj->qdisc = (NMPlatformQdisc) { .ifindex = ifindex, .kind = kind, .parent = parent, |