diff options
| author | Michael Biebl <biebl@debian.org> | 2022-02-14 19:23:28 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2022-02-14 19:23:28 +0100 |
| commit | 2f94dba7385fd0e0ef19a06eb4a2fcf6c43d7946 (patch) | |
| tree | e2222f5577115985dd52044d2991253403cdd952 /src/nm-initrd-generator/tests/test-cmdline-reader.c | |
| parent | 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c (diff) | |
New upstream version 1.35.91 upstream/1.35.91
Diffstat (limited to 'src/nm-initrd-generator/tests/test-cmdline-reader.c')
| -rw-r--r-- | src/nm-initrd-generator/tests/test-cmdline-reader.c | 471 |
1 files changed, 271 insertions, 200 deletions
diff --git a/src/nm-initrd-generator/tests/test-cmdline-reader.c b/src/nm-initrd-generator/tests/test-cmdline-reader.c index 2cb1b2f4..d7b7b3cb 100644 --- a/src/nm-initrd-generator/tests/test-cmdline-reader.c +++ b/src/nm-initrd-generator/tests/test-cmdline-reader.c @@ -27,9 +27,10 @@ const char *const *const _ARGV = (ARGV); \ char **const _out_hostname = (out_hostname); \ gint64 *const _out_carrier_timeout_sec = (out_carrier_timeout_sec); \ - GHashTable * _connections; \ + GHashTable *_connections; \ \ - _connections = nmi_cmdline_reader_parse(TEST_INITRD_DIR "/sysfs", \ + _connections = nmi_cmdline_reader_parse(NULL, \ + TEST_INITRD_DIR "/sysfs", \ _ARGV, \ _out_hostname, \ _out_carrier_timeout_sec); \ @@ -41,7 +42,7 @@ #define _parse_cons(ARGV) \ ({ \ - GHashTable * _con_connections; \ + GHashTable *_con_connections; \ gs_free char *_con_hostname = NULL; \ gint64 _con_carrier_timeout_sec = 0; \ \ @@ -57,7 +58,7 @@ #define _parse_con(ARGV, connection_name) \ ({ \ gs_unref_hashtable GHashTable *_1_connections = NULL; \ - NMConnection * _1_connection; \ + NMConnection *_1_connection; \ const char *const _1_connection_name = (connection_name); \ \ g_assert(_1_connection_name); \ @@ -89,12 +90,12 @@ static void test_auto(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=auto"); + const char *const *ARGV = NM_MAKE_STRV("ip=auto"); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -140,13 +141,13 @@ static void test_dhcp_with_hostname(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=::::host1::dhcp,dhcp6"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("ip=::::host1::dhcp,dhcp6"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -198,10 +199,10 @@ test_dhcp_with_mtu(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV[i], "default_connection"); @@ -259,9 +260,9 @@ test_dhcp_timeout(void) for (i = 0; i < G_N_ELEMENTS(data); i++) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(data[i].cmdline, "default_connection"); @@ -300,12 +301,12 @@ test_dhcp_timeout(void) static void test_if_auto_with_mtu(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth0:dhcp,dhcp6:1666", "="); + const char *const *ARGV = NM_MAKE_STRV("ip=eth0:dhcp,dhcp6:1666", "="); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "eth0"); @@ -340,10 +341,10 @@ test_if_auto_with_mtu(void) static void test_if_dhcp6(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth1:dhcp6"); + const char *const *ARGV = NM_MAKE_STRV("ip=eth1:dhcp6"); gs_unref_object NMConnection *connection = NULL; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "eth1"); @@ -365,11 +366,11 @@ test_if_dhcp6(void) static void test_if_auto_with_mtu_and_mac(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth2:auto6:2048:00:53:ef:12:34:56"); + const char *const *ARGV = NM_MAKE_STRV("ip=eth2:auto6:2048:00:53:ef:12:34:56"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "eth2"); @@ -397,16 +398,16 @@ static void test_if_ip4_manual(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:255.255.255.0:" - "hostname0.example.com:eth3:none:192.0.2.53", + const char *const *ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:255.255.255.0:" + "hostname0.example.com:eth3:none:192.0.2.53", "ip=203.0.113.2::203.0.113.1:26:" - "hostname1.example.com:eth4"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; - gs_free char * hostname = NULL; + "hostname1.example.com:eth4"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -477,12 +478,12 @@ test_if_ip4_manual(void) static void test_if_ip4_manual_no_dev(void) { - const char *const * ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:24:::", "=foo"); - NMConnection * connection; + const char *const *ARGV = NM_MAKE_STRV("ip=192.0.2.2::192.0.2.1:24:::", "=foo"); + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; connection = _parse_con(ARGV, "default_connection"); g_assert_cmpstr(nm_connection_get_id(connection), ==, "Wired Connection"); @@ -518,12 +519,12 @@ static void test_if_ip6_manual(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=[2001:0db8::02]/64::[2001:0db8::01]::" - "hostname0.example.com:eth4::[2001:0db8::53]"); - NMConnection * connection; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("ip=[2001:0db8::02]/64::[2001:0db8::01]::" + "hostname0.example.com:eth4::[2001:0db8::53]"); + NMConnection *connection; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -557,13 +558,13 @@ static void test_if_off(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=off", + const char *const *ARGV = NM_MAKE_STRV("ip=off", "ip=ens3:off", "ip=10.0.0.8:::::ens4:off", "ip=[2001:DB8::8]:::::ens5:off"); - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; struct { const char name[32]; const char ipv4_method[32]; @@ -599,13 +600,13 @@ static void test_if_mac_ifname(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=[2001:0db8::42]/64::[2001:0db8::01]::" - "hostname0:00-11-22-33-44-55::[2001:0db8::53]"); - NMConnection * connection; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMIPAddress * ip_addr; - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("ip=[2001:0db8::42]/64::[2001:0db8::01]::" + "hostname0:00-11-22-33-44-55::[2001:0db8::53]"); + NMConnection *connection; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMIPAddress *ip_addr; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -646,11 +647,11 @@ test_multiple_merge(void) const char *const *ARGV = NM_MAKE_STRV("ip=192.0.2.2/16:::::eth0", "ip=[2001:db8::2]:::56::eth0"); gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPAddress * ip_addr; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPAddress *ip_addr; connection = _parse_con(ARGV, "eth0"); @@ -699,10 +700,10 @@ test_multiple_bootdev(void) "ip=eth5:link6", "bootdev=eth4"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -745,9 +746,9 @@ static void test_bootdev(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("vlan=vlan2:ens5", "bootdev=ens3"); - NMConnection * connection; - NMSettingConnection * s_con; + const char *const *ARGV = NM_MAKE_STRV("vlan=vlan2:ens5", "bootdev=ens3"); + NMConnection *connection; + NMSettingConnection *s_con; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -793,7 +794,7 @@ static void test_some_more(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bootdev=eth1", + const char *const *ARGV = NM_MAKE_STRV("bootdev=eth1", "hail", "nameserver=[2001:DB8:3::53]", "satan", @@ -802,12 +803,12 @@ test_some_more(void) "doom", "rd.peerdns=0", "rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMIPRoute * ip_route; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMIPRoute *ip_route; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -883,17 +884,17 @@ static void test_bond(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("rd.route=192.0.2.53::bong0", + const char *const *ARGV = NM_MAKE_STRV("rd.route=192.0.2.53::bong0", "bond=bong0:eth0,eth1:mode=balance-rr:9000", "nameserver=203.0.113.53"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBond * s_bond; - NMSettingWired * s_wired; - NMIPRoute * ip_route; - const char * master_uuid; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBond *s_bond; + NMSettingWired *s_wired; + NMIPRoute *ip_route; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -976,18 +977,18 @@ static void test_bond_ip(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = + const char *const *ARGV = NM_MAKE_STRV("bond=bond0:eth0,eth1", "ip=192.168.1.1::192.168.1.254:24::bond0:none:1480:01:02:03:04:05:06", "nameserver=4.8.15.16"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMSettingBond * s_bond; - NMIPAddress * ip_addr; - const char * master_uuid; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMSettingBond *s_bond; + NMIPAddress *ip_addr; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -1073,13 +1074,13 @@ static void test_bond_default(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bond"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBond * s_bond; - const char * master_uuid; + const char *const *ARGV = NM_MAKE_STRV("bond"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBond *s_bond; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1136,16 +1137,16 @@ static void test_bridge(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bridge=bridge0:eth0,eth1", + const char *const *ARGV = NM_MAKE_STRV("bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0", "rd.net.timeout.dhcp=10"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBridge * s_bridge; - NMIPRoute * ip_route; - const char * master_uuid; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBridge *s_bridge; + NMIPRoute *ip_route; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -1232,13 +1233,13 @@ static void test_bridge_default(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("bridge"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingBridge * s_bridge; - const char * master_uuid; + const char *const *ARGV = NM_MAKE_STRV("bridge"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingBridge *s_bridge; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1295,16 +1296,16 @@ static void test_bridge_ip(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = + const char *const *ARGV = NM_MAKE_STRV("ip=bridge123:auto:1280:00:11:22:33:CA:fe", "bridge=bridge123:eth0,eth1,eth2,eth3,eth4,eth5,eth6,eth7,eth8,eth9"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMSettingBridge * s_bridge; - const char * master_uuid; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingWired *s_wired; + NMSettingBridge *s_bridge; + const char *master_uuid; guint i; connections = _parse_cons(ARGV); @@ -1364,13 +1365,13 @@ static void test_team(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("team=team0:eth0,eth1", "ip=team0:dhcp6"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingTeam * s_team; - const char * master_uuid; + const char *const *ARGV = NM_MAKE_STRV("team=team0:eth0,eth1", "ip=team0:dhcp6"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingTeam *s_team; + const char *master_uuid; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 3); @@ -1448,10 +1449,10 @@ test_vlan(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingVlan * s_vlan; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingVlan *s_vlan; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1513,10 +1514,10 @@ test_vlan_with_dhcp_on_parent(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingVlan * s_vlan; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingVlan *s_vlan; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1585,10 +1586,10 @@ test_vlan_over_bond(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingVlan * s_vlan; + NMConnection *connection; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingVlan *s_vlan; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 4); @@ -1649,8 +1650,8 @@ test_vlan_over_bond(void) static void test_ibft_ip_dev(void) { - const char *const * ARGV = NM_MAKE_STRV("ip=eth0:ibft"); - NMSettingConnection *s_con; + const char *const *ARGV = NM_MAKE_STRV("ip=eth0:ibft"); + NMSettingConnection *s_con; gs_unref_object NMConnection *connection = NULL; connection = _parse_con(ARGV, "eth0"); @@ -1666,8 +1667,8 @@ test_ibft_ip_dev(void) static void test_ibft_ip_dev_mac(void) { - const char *const * ARGV = NM_MAKE_STRV("ip=00-53-06-66-ab-01:ibft"); - NMSettingConnection *s_con; + const char *const *ARGV = NM_MAKE_STRV("ip=00-53-06-66-ab-01:ibft"); + NMSettingConnection *s_con; gs_unref_object NMConnection *connection = NULL; connection = _parse_con(ARGV, "00:53:06:66:AB:01"); @@ -1684,7 +1685,7 @@ static void _test_ibft_ip(const char *const *ARGV) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; + NMConnection *connection; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -1721,7 +1722,7 @@ static void test_ignore_extra(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("blabla", "extra", "lalala"); + const char *const *ARGV = NM_MAKE_STRV("blabla", "extra", "lalala"); connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 0); @@ -1736,10 +1737,10 @@ test_rd_znet(void) "ip=slc600:dhcp", "rd.znet=qeth,0.0.0800,0.0.0801,0.0.0802,layer2=0,portno=1", "rd.znet=ctc,0.0.0600,0.0.0601,layer2=0,portno=0"); - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWired * s_wired; - const char *const * v_subchannels; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + const char *const *v_subchannels; const NMUtilsNamedValue s390_options[] = { {.name = "layer2", .value_str = "0"}, {.name = "portno", .value_str = "1"}, @@ -1778,9 +1779,9 @@ test_rd_znet(void) for (i_s390_options_keys = 0; i_s390_options_keys < G_N_ELEMENTS(s390_options); i_s390_options_keys++) { const NMUtilsNamedValue *s390_option = &s390_options[i_s390_options_keys]; - const char * k; - const char * v; - const char * v2; + const char *k; + const char *v; + const char *v2; g_assert(s390_option->name); g_assert(s390_option->value_str); @@ -1830,9 +1831,9 @@ test_rd_znet_legacy(void) "rd.znet=ctc,0.0.0600,0.0.0601,layer2=0,portno=0", "ip=ctc0:dhcp", "net.ifnames=0"); - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - gs_free char * hostname = NULL; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -1897,13 +1898,82 @@ test_rd_znet_malformed(void) } static void +test_rd_znet_ifnames(void) +{ + gs_unref_hashtable GHashTable *connections = NULL; + const char *const *const ARGV = + NM_MAKE_STRV("rd.znet_ifname=zeth1:0.0.0600,0.0.0601", + "rd.znet=qeth,0.0.0800,0.0.0801,0.0.0802,layer2=0,portno=1,foo", + "rd.znet=ctc,0.0.0600,0.0.0601", + "rd.znet_ifname=zeth0:0.0.0800,0.0.0801,0.0.0802", + "ip=zeth0:dhcp", + "ip=zeth1:dhcp"); + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + gs_free char *hostname = NULL; + gint64 carrier_timeout_sec = 0; + const char *const *v_subchannels; + + connections = _parse(ARGV, &hostname, &carrier_timeout_sec); + g_assert_cmpint(g_hash_table_size(connections), ==, 2); + + connection = g_hash_table_lookup(connections, "zeth0"); + g_assert(NM_IS_CONNECTION(connection)); + + s_con = nm_connection_get_setting_connection(connection); + g_assert(NM_IS_SETTING_CONNECTION(s_con)); + g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), + ==, + NM_SETTING_WIRED_SETTING_NAME); + g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "zeth0"); + g_assert_cmpstr(nm_setting_connection_get_interface_name(s_con), ==, "zeth0"); + + s_wired = nm_connection_get_setting_wired(connection); + g_assert_cmpstr(nm_setting_wired_get_s390_nettype(s_wired), ==, "qeth"); + g_assert(s_wired); + + v_subchannels = nm_setting_wired_get_s390_subchannels(s_wired); + g_assert(v_subchannels); + g_assert_cmpstr(v_subchannels[0], ==, "0.0.0800"); + g_assert_cmpstr(v_subchannels[1], ==, "0.0.0801"); + g_assert_cmpstr(v_subchannels[2], ==, "0.0.0802"); + g_assert_cmpstr(v_subchannels[3], ==, NULL); + + nmtst_assert_connection_verifies_without_normalization(connection); + + connection = g_hash_table_lookup(connections, "zeth1"); + g_assert(NM_IS_CONNECTION(connection)); + + s_con = nm_connection_get_setting_connection(connection); + g_assert(NM_IS_SETTING_CONNECTION(s_con)); + g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), + ==, + NM_SETTING_WIRED_SETTING_NAME); + g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "zeth1"); + g_assert_cmpstr(nm_setting_connection_get_interface_name(s_con), ==, "zeth1"); + + s_wired = nm_connection_get_setting_wired(connection); + g_assert_cmpstr(nm_setting_wired_get_s390_nettype(s_wired), ==, "ctc"); + g_assert(s_wired); + + v_subchannels = nm_setting_wired_get_s390_subchannels(s_wired); + g_assert(v_subchannels); + g_assert_cmpstr(v_subchannels[0], ==, "0.0.0600"); + g_assert_cmpstr(v_subchannels[1], ==, "0.0.0601"); + g_assert_cmpstr(v_subchannels[2], ==, NULL); + + nmtst_assert_connection_verifies_without_normalization(connection); +} + +static void test_bootif_ip(void) { - const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03", "ip=dhcp"); + const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03", "ip=dhcp"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -1928,11 +1998,11 @@ test_bootif_ip(void) static void test_neednet_no_args(void) { - const char *const *ARGV = NM_MAKE_STRV("rd.neednet"); + const char *const *ARGV = NM_MAKE_STRV("rd.neednet"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -1960,12 +2030,12 @@ static void test_neednet_args(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("rd.neednet", + const char *const *ARGV = NM_MAKE_STRV("rd.neednet", "ip=eno1:dhcp", "ip=172.25.1.100::172.25.1.1:24::eno2", "bridge=br0:eno3"); - NMConnection * connection; - NMSettingConnection * s_con; + NMConnection *connection; + NMSettingConnection *s_con; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 4); @@ -2008,11 +2078,11 @@ test_neednet_args(void) static void test_bootif_no_ip(void) { - const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03"); + const char *const *ARGV = NM_MAKE_STRV("BOOTIF=00:53:AB:cd:02:03"); gs_unref_object NMConnection *connection = NULL; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connection = _parse_con(ARGV, "default_connection"); @@ -2043,10 +2113,10 @@ test_bootif_hwtype(void) for (i = 0; i < G_N_ELEMENTS(ARGV); i++) { gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *connection; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connections = _parse_cons(ARGV[i]); g_assert_cmpint(g_hash_table_size(connections), ==, 2); @@ -2108,16 +2178,16 @@ static void test_nameserver(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = + const char *const *ARGV = NM_MAKE_STRV("nameserver=1.1.1.1", "ip=eth0:dhcp", "ip=eth1:auto6", "ip=10.11.12.13::10.11.12.1:24:foo.example.com:eth2:none", "nameserver=1.0.0.1", "nameserver=[2606:4700:4700::1111]"); - NMConnection * connection; + NMConnection *connection; NMSettingIPConfig *s_ip; - gs_free char * hostname = NULL; + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -2165,10 +2235,10 @@ test_bootif_off(void) static void test_dhcp_vendor_class_id(void) { - const char *const *ARGV; + const char *const *ARGV; gs_unref_object NMConnection *connection = NULL; - NMSettingIP4Config * s_ip4; - gs_free char * vci_long = NULL; + NMSettingIP4Config *s_ip4; + gs_free char *vci_long = NULL; char vci_arg_long[512] = {0}; ARGV = NM_MAKE_STRV("rd.net.dhcp.vendor-class=testvci", "ip=eno1:dhcp"); @@ -2196,9 +2266,9 @@ test_dhcp_vendor_class_id(void) static void test_infiniband_iface(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=ib1:dhcp"); + const char *const *ARGV = NM_MAKE_STRV("ip=ib1:dhcp"); gs_unref_object NMConnection *connection = NULL; - NMSettingInfiniband * s_ib; + NMSettingInfiniband *s_ib; connection = _parse_con(ARGV, "ib1"); @@ -2215,7 +2285,7 @@ test_infiniband_mac(void) const char *const *ARGV = NM_MAKE_STRV("ip=00-11-22-33-44-55-66-77-88-99-aa-bb-cc-dd-ee-ff-00-11-22-33:dhcp"); gs_unref_object NMConnection *connection = NULL; - NMSettingInfiniband * s_ib; + NMSettingInfiniband *s_ib; connection = _parse_con(ARGV, "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33"); @@ -2233,12 +2303,12 @@ test_infiniband_mac(void) static void test_infiniband_pkey(void) { - const char *const *const ARGV = NM_MAKE_STRV("ib.pkey=ib0.8004", "ip=ib0.8004:dhcp"); + const char *const *const ARGV = NM_MAKE_STRV("ib.pkey=ib0.8004", "ip=ib0.8004:dhcp"); gs_unref_hashtable GHashTable *connections = NULL; - NMConnection * connection; - NMSettingInfiniband * s_ib; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; + NMConnection *connection; + NMSettingInfiniband *s_ib; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; connections = _parse_cons(ARGV); g_assert_cmpint(g_hash_table_size(connections), ==, 1); @@ -2268,8 +2338,8 @@ static void test_carrier_timeout(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("rd.net.timeout.carrier=20"); - gs_free char * hostname = NULL; + const char *const *ARGV = NM_MAKE_STRV("rd.net.timeout.carrier=20"); + gs_free char *hostname = NULL; gint64 carrier_timeout_sec = 0; connections = _parse(ARGV, &hostname, &carrier_timeout_sec); @@ -2295,7 +2365,7 @@ test_carrier_timeout(void) G_STMT_START \ { \ gs_unref_object NMConnection *_connection = NULL; \ - NMSettingWired * _s_wired; \ + NMSettingWired *_s_wired; \ typeof(speed) _speed = speed; \ \ _connection = _parse_con(strv, "eth0"); \ @@ -2482,6 +2552,7 @@ main(int argc, char **argv) g_test_add_func("/initrd/cmdline/rd_znet/legacy", test_rd_znet_legacy); g_test_add_func("/initrd/cmdline/rd_znet/no_ip", test_rd_znet_no_ip); g_test_add_func("/initrd/cmdline/rd_znet/empty", test_rd_znet_malformed); + g_test_add_func("/initrd/cmdline/rd_znet/ifnames", test_rd_znet_ifnames); g_test_add_func("/initrd/cmdline/bootif/ip", test_bootif_ip); g_test_add_func("/initrd/cmdline/bootif/no_ip", test_bootif_no_ip); g_test_add_func("/initrd/cmdline/bootif/hwtype", test_bootif_hwtype); |