test-dhcp-server.c revision 6f08fb7b34b4eebf664de83c8bc7b9941658aeb4
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2013 Intel Corporation. All rights reserved.
Copyright (C) 2014 Tom Gundersen
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 <netinet/if_ether.h>
#include <assert.h>
#include <errno.h>
#include "sd-event.h"
#include "event-util.h"
#include "sd-dhcp-server.h"
#include "dhcp-server-internal.h"
struct in_addr address_lo = {
};
struct in_addr address_any = {
};
int r;
/* attach to loopback interface */
r = sd_dhcp_server_start(server);
if (r == -EPERM)
return EXIT_TEST_SKIP;
assert_se(r >= 0);
return 0;
}
static void test_message_handler(void) {
struct {
struct {
struct {
struct {
struct {
.end = DHCP_OPTION_END,
};
struct in_addr address_lo = {
};
/* TODO, shouldn't this fail? */
}
static void test_client_id_hash(void) {
DHCPClientId a = {
.length = 4,
}, b = {
.length = 4,
};
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
};
assert_se(client_id_compare_func(&a, &b) == 0);
a.length = 3;
assert_se(client_id_compare_func(&a, &b) != 0);
a.length = 4;
assert_se(client_id_compare_func(&a, &b) == 0);
b.length = 3;
assert_se(client_id_compare_func(&a, &b) != 0);
b.length = 4;
assert_se(client_id_compare_func(&a, &b) == 0);
assert_se(client_id_compare_func(&a, &b) != 0);
}
int r;
log_open();
assert_se(sd_event_new(&e) >= 0);
r = test_basic(e);
if (r != 0)
return r;
return 0;
}