test-dhcp-client.c revision 5bac5235934fabe5a3e6a9d47f4812f81034c427
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack This file is part of systemd.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack Copyright (C) 2013 Intel Corporation. All rights reserved.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack systemd is free software; you can redistribute it and/or modify it
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack under the terms of the GNU Lesser General Public License as published by
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack the Free Software Foundation; either version 2.1 of the License, or
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack (at your option) any later version.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack systemd is distributed in the hope that it will be useful, but
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack WITHOUT ANY WARRANTY; without even the implied warranty of
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack Lesser General Public License for more details.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack You should have received a copy of the GNU Lesser General Public License
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack along with systemd; If not, see <http://www.gnu.org/licenses/>.
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mackstatic uint8_t mac_addr[] = {'A', 'B', 'C', '1', '2', '3'};
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Macktypedef int (*test_callback_recv_t)(size_t size, DHCPMessage *dhcp);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mackstatic bool verbose = true;
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mackstatic int test_dhcp_hangcheck(sd_event_source *s, uint64_t usec,
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_not_reached("Test case should have completed in 2 seconds");
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_request_option(NULL, 0) == -EINVAL);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_request_address(NULL, NULL) == -EINVAL);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_index(NULL, 0) == -EINVAL);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_index(client, 15) == 0);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_index(client, -42) == -EINVAL);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_index(client, -1) == -EINVAL);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_index(client, 0) == -EINVAL);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_index(client, 1) == 0);
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_request_option(client,
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_request_option(client,
bb7dd0b04a6e89674100476eed0bbd05c6a4cbd8Daniel Mack assert_se(sd_dhcp_client_set_request_option(client,
== -EEXIST);
== -EINVAL);
static void test_checksum(void)
if (verbose)
void *user_data)
switch(code) {
assert_se(s >= 0);
return -errno;
return test_fd[0];
int res;
if (verbose)
int res, r;
if (verbose)
assert_se(r >= 0);
assert_se(r >= 0);
void *userdata) {
if (verbose)
sd_event_exit(e, 0);
int res;
if (verbose)
sizeof(test_addr_acq_ack));
if (verbose)
int res;
if (verbose)
sizeof(test_addr_acq_offer));
if (verbose)
int res, r;
if (verbose)
assert_se(r >= 0);
assert_se(r >= 0);
xid = 0;
log_open();
test_addr_acq(e);