diff options
Diffstat (limited to 'src/dhcp-manager/tests/test-dhcp-utils.c')
-rw-r--r-- | src/dhcp-manager/tests/test-dhcp-utils.c | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/src/dhcp-manager/tests/test-dhcp-utils.c b/src/dhcp-manager/tests/test-dhcp-utils.c index 53688a5b1..618188dfd 100644 --- a/src/dhcp-manager/tests/test-dhcp-utils.c +++ b/src/dhcp-manager/tests/test-dhcp-utils.c @@ -72,7 +72,7 @@ static void test_generic_options (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; const NMPlatformIP4Route *route; guint32 tmp; @@ -147,7 +147,7 @@ static void test_wins_options (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; guint32 tmp; const char *expected_wins1 = "63.12.199.5"; @@ -176,6 +176,31 @@ test_wins_options (void) } static void +test_vendor_option_metered (void) +{ + GHashTable *options; + gs_unref_object NMIP4Config *ip4_config = NULL; + static const Option data[] = { + { "vendor_encapsulated_options", "ANDROID_METERED" }, + { NULL, NULL } + }; + + options = fill_table (generic_options, NULL); + ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0); + g_assert (ip4_config); + g_assert (nm_ip4_config_get_metered (ip4_config) == FALSE); + g_hash_table_destroy (options); + g_clear_object (&ip4_config); + + options = fill_table (generic_options, NULL); + options = fill_table (data, options); + ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0); + g_assert (ip4_config); + g_assert (nm_ip4_config_get_metered (ip4_config) == TRUE); + g_hash_table_destroy (options); +} + +static void ip4_test_route (NMIP4Config *ip4_config, guint route_num, const char *expected_dest, @@ -208,7 +233,7 @@ static void test_classless_static_routes_1 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_route2_dest = "10.0.0.0"; @@ -236,7 +261,7 @@ static void test_classless_static_routes_2 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_route2_dest = "10.0.0.0"; @@ -264,7 +289,7 @@ static void test_fedora_dhclient_classless_static_routes (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "129.210.177.128"; const char *expected_route1_gw = "192.168.0.113"; const char *expected_route2_dest = "2.0.0.0"; @@ -296,7 +321,7 @@ static void test_dhclient_invalid_classless_routes_1 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static const Option data[] = { @@ -325,7 +350,7 @@ static void test_dhcpcd_invalid_classless_routes_1 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; @@ -359,7 +384,7 @@ static void test_dhclient_invalid_classless_routes_2 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; @@ -392,7 +417,7 @@ static void test_dhcpcd_invalid_classless_routes_2 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; @@ -427,7 +452,7 @@ static void test_dhclient_invalid_classless_routes_3 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static const Option data[] = { @@ -455,7 +480,7 @@ static void test_dhcpcd_invalid_classless_routes_3 (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static Option data[] = { @@ -483,7 +508,7 @@ static void test_dhclient_gw_in_classless_routes (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_gateway = "192.2.3.4"; @@ -511,7 +536,7 @@ static void test_dhcpcd_gw_in_classless_routes (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_gateway = "192.2.3.4"; @@ -539,7 +564,7 @@ static void test_escaped_domain_searches (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const char *expected_search0 = "host1"; const char *expected_search1 = "host2"; const char *expected_search2 = "host3"; @@ -566,7 +591,7 @@ static void test_invalid_escaped_domain_searches (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; static const Option data[] = { { "domain_search", "host1\\aahost2\\032host3" }, { NULL, NULL } @@ -591,7 +616,7 @@ static void test_ip4_missing_prefix (const char *ip, guint32 expected_prefix) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; options = fill_table (generic_options, NULL); @@ -631,7 +656,7 @@ static void test_ip4_prefix_classless (void) { GHashTable *options; - NMIP4Config *ip4_config; + gs_unref_object NMIP4Config *ip4_config = NULL; const NMPlatformIP4Address *address; /* Ensure that the missing-subnet-mask handler doesn't mangle classless @@ -716,6 +741,7 @@ int main (int argc, char **argv) g_test_add_func ("/dhcp/ip4-missing-prefix-8", test_ip4_missing_prefix_8); g_test_add_func ("/dhcp/ip4-prefix-classless", test_ip4_prefix_classless); g_test_add_func ("/dhcp/client-id-from-string", test_client_id_from_string); + g_test_add_func ("/dhcp/vendor-option-metered", test_vendor_option_metered); return g_test_run (); } |