From 28028b26b3371756811e95d894f709f4b1207c00 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Wed, 18 Dec 2019 18:29:24 +0100 Subject: New upstream version 1.22.0 --- src/dhcp/tests/test-dhcp-utils.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/dhcp/tests/test-dhcp-utils.c') diff --git a/src/dhcp/tests/test-dhcp-utils.c b/src/dhcp/tests/test-dhcp-utils.c index e4d4c348..d0389069 100644 --- a/src/dhcp/tests/test-dhcp-utils.c +++ b/src/dhcp/tests/test-dhcp-utils.c @@ -1,19 +1,6 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * +// SPDX-License-Identifier: GPL-2.0+ +/* * Copyright (C) 2008 - 2014 Red Hat, Inc. - * */ #include "nm-default.h" -- cgit 1.3.0-6-gf8a5 From 724bcc5c7be3aed3646ed2b2989c34d438217176 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 26 Dec 2019 06:49:35 +0100 Subject: New upstream version 1.22.2 --- src/dhcp/tests/test-dhcp-utils.c | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src/dhcp/tests/test-dhcp-utils.c') 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 @@ -199,6 +199,60 @@ test_vendor_option_metered (void) g_hash_table_destroy (options); } +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, @@ -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 (); } -- cgit 1.3.0-6-gf8a5