]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd-network/test-dhcp-client.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / libsystemd-network / test-dhcp-client.c
index 5c3ae170ed608102bdd76611c612ffe5315b8a6b..98e8a7e25a2cc15c717bebacfabcba88fe1ee9ad 100644 (file)
@@ -1,20 +1,8 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
   Copyright (C) 2013 Intel Corporation. All rights reserved.
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <errno.h>
@@ -75,6 +63,12 @@ static void test_request_basic(sd_event *e) {
         assert_se(sd_dhcp_client_set_ifindex(client, 0) == -EINVAL);
         assert_se(sd_dhcp_client_set_ifindex(client, 1) == 0);
 
+        assert_se(sd_dhcp_client_set_hostname(client, "host") == 1);
+        assert_se(sd_dhcp_client_set_hostname(client, "host.domain") == 1);
+        assert_se(sd_dhcp_client_set_hostname(client, NULL) == 1);
+        assert_se(sd_dhcp_client_set_hostname(client, "~host") == -EINVAL);
+        assert_se(sd_dhcp_client_set_hostname(client, "~host.domain") == -EINVAL);
+
         assert_se(sd_dhcp_client_set_request_option(client,
                                         SD_DHCP_OPTION_SUBNET_MASK) == -EEXIST);
         assert_se(sd_dhcp_client_set_request_option(client,
@@ -102,8 +96,8 @@ static void test_request_basic(sd_event *e) {
 
         /* RFC7844: option 33 (SD_DHCP_OPTION_STATIC_ROUTE) is set in the
          * default PRL when using Anonymize, so it is changed to other option
-         * that is not set by default, to check that it succed setting it.
-         * Ooptions not set by default (using or not anonymize) are option 17
+         * that is not set by default, to check that it was set successfully.
+         * Options not set by default (using or not anonymize) are option 17
          * (SD_DHCP_OPTION_ROOT_PATH) and 42 (SD_DHCP_OPTION_NTP_SERVER) */
         assert_se(sd_dhcp_client_set_request_option(client, 17) == 0);
         assert_se(sd_dhcp_client_set_request_option(client, 17) == -EEXIST);
@@ -294,7 +288,7 @@ static void test_discover_message(sd_event *e) {
 
         res = sd_dhcp_client_start(client);
 
-        assert_se(res == 0 || res == -EINPROGRESS);
+        assert_se(IN_SET(res, 0, -EINPROGRESS));
 
         sd_event_run(e, (uint64_t) -1);
 
@@ -513,7 +507,7 @@ static void test_addr_acq(sd_event *e) {
                                     test_dhcp_hangcheck, NULL) >= 0);
 
         res = sd_dhcp_client_start(client);
-        assert_se(res == 0 || res == -EINPROGRESS);
+        assert_se(IN_SET(res, 0, -EINPROGRESS));
 
         assert_se(sd_event_loop(e) >= 0);