diff options
| author | Michael Biebl <biebl@debian.org> | 2019-12-26 06:49:35 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-12-26 06:49:35 +0100 |
| commit | 724bcc5c7be3aed3646ed2b2989c34d438217176 (patch) | |
| tree | e46ca78149b3517bc5ebc9fd31d6d9d11a6561b6 /src/dhcp/tests/test-dhcp-utils.c | |
| parent | 28028b26b3371756811e95d894f709f4b1207c00 (diff) | |
New upstream version 1.22.2 upstream/1.22.2
Diffstat (limited to 'src/dhcp/tests/test-dhcp-utils.c')
| -rw-r--r-- | src/dhcp/tests/test-dhcp-utils.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/dhcp/tests/test-dhcp-utils.c b/src/dhcp/tests/test-dhcp-utils.c index d0389069..e601534e 100644 --- a/src/dhcp/tests/test-dhcp-utils.c +++ b/src/dhcp/tests/test-dhcp-utils.c @@ -200,6 +200,60 @@ test_vendor_option_metered (void) } static void +test_parse_search_list (void) +{ + guint8 *data; + char **domains; + + data = (guint8 []) { + 0x05, 'l', 'o', 'c', 'a', 'l', + 0x00 + }; + domains = nm_dhcp_parse_search_list (data, 7); + g_assert (domains); + g_assert_cmpint (g_strv_length (domains), ==, 1); + g_assert_cmpstr (domains[0], ==, "local"); + g_strfreev (domains); + + data = (guint8 []) { + 0x04, 't', 'e', 's', 't', + 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e', + 0x03, 'c', 'o', 'm', + 0x00, + 0xc0, 0x05, + 0x03, 'a', 'b', 'c', + 0xc0, 0x0d, + 0x06, 'f', 'o', 'o', 'b', 'a', 'r', + 0x00 + }; + domains = nm_dhcp_parse_search_list (data, 34); + g_assert (domains); + g_assert_cmpint (g_strv_length (domains), ==, 4); + g_assert_cmpstr (domains[0], ==, "test.example.com"); + g_assert_cmpstr (domains[1], ==, "example.com"); + g_assert_cmpstr (domains[2], ==, "abc.com"); + g_assert_cmpstr (domains[3], ==, "foobar"); + g_strfreev (domains); + + data = (guint8 []) { + 0x40, 'b', 'a', 'd', + }; + domains = nm_dhcp_parse_search_list (data, 4); + g_assert (!domains); + + data = (guint8 []) { + 0x04, 'o', 'k', 'a', 'y', + 0x00, + 0x40, 'b', 'a', 'd', + }; + domains = nm_dhcp_parse_search_list (data, 10); + g_assert (domains); + g_assert_cmpint (g_strv_length (domains), ==, 1); + g_assert_cmpstr (domains[0], ==, "okay"); + g_strfreev (domains); +} + +static void ip4_test_route (NMIP4Config *ip4_config, guint route_num, const char *expected_dest, @@ -732,6 +786,7 @@ int main (int argc, char **argv) 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); + g_test_add_func ("/dhcp/parse-search-list", test_parse_search_list); return g_test_run (); } |