1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright (C) 2014 Intel Corporation. All rights reserved.
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 #include "event-util.h"
29 #include "sd-dhcp6-client.h"
30 #include "dhcp6-protocol.h"
32 static struct ether_addr mac_addr = {
33 .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}
36 static bool verbose = false;
38 static int test_client_basic(sd_event *e) {
39 sd_dhcp6_client *client;
42 printf("* %s\n", __FUNCTION__);
44 assert_se(sd_dhcp6_client_new(&client) >= 0);
47 assert_se(sd_dhcp6_client_attach_event(client, e, 0) >= 0);
49 assert_se(sd_dhcp6_client_set_index(client, 15) == 0);
50 assert_se(sd_dhcp6_client_set_index(client, -42) == -EINVAL);
51 assert_se(sd_dhcp6_client_set_index(client, -1) == 0);
52 assert_se(sd_dhcp6_client_set_index(client, 42) >= 0);
54 assert_se(sd_dhcp6_client_set_mac(client, &mac_addr) >= 0);
56 assert_se(sd_dhcp6_client_set_callback(client, NULL, NULL) >= 0);
58 assert_se(sd_dhcp6_client_detach_event(client) >= 0);
59 assert_se(!sd_dhcp6_client_unref(client));
64 int main(int argc, char *argv[]) {
65 _cleanup_event_unref_ sd_event *e;
67 assert_se(sd_event_new(&e) >= 0);
69 log_set_max_level(LOG_DEBUG);
70 log_parse_environment();