summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/test-dhcp-server.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-06-13 19:11:31 +0200
committerTom Gundersen <teg@jklm.no>2014-06-13 19:11:31 +0200
commit6f08fb7b34b4eebf664de83c8bc7b9941658aeb4 (patch)
treeeae94721e9230c566f6c4eee5498a1ef6c1986f9 /src/libsystemd-network/test-dhcp-server.c
parent223217749e57996336d5730b0a28716cca56d45d (diff)
sd-dhcp-server: test - skip when lacking perms
Diffstat (limited to 'src/libsystemd-network/test-dhcp-server.c')
-rw-r--r--src/libsystemd-network/test-dhcp-server.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c
index 6b3b4d0ab0..a9bdb9ab8b 100644
--- a/src/libsystemd-network/test-dhcp-server.c
+++ b/src/libsystemd-network/test-dhcp-server.c
@@ -30,7 +30,7 @@
#include "sd-dhcp-server.h"
#include "dhcp-server-internal.h"
-static void test_basic(sd_event *event) {
+static int test_basic(sd_event *event) {
_cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL;
struct in_addr address_lo = {
.s_addr = htonl(INADDR_LOOPBACK),
@@ -38,6 +38,7 @@ static void test_basic(sd_event *event) {
struct in_addr address_any = {
.s_addr = htonl(INADDR_ANY),
};
+ int r;
/* attach to loopback interface */
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
@@ -64,11 +65,18 @@ static void test_basic(sd_event *event) {
assert_se(sd_dhcp_server_set_lease_pool(server, &address_lo, 1) >= 0);
assert_se(sd_dhcp_server_set_lease_pool(server, &address_lo, 1) == -EBUSY);
- assert_se(sd_dhcp_server_start(server) >= 0);
+ r = sd_dhcp_server_start(server);
+
+ if (r == -EPERM)
+ return EXIT_TEST_SKIP;
+ assert_se(r >= 0);
+
assert_se(sd_dhcp_server_start(server) == -EBUSY);
assert_se(sd_dhcp_server_stop(server) >= 0);
assert_se(sd_dhcp_server_stop(server) >= 0);
assert_se(sd_dhcp_server_start(server) >= 0);
+
+ return 0;
}
static void test_message_handler(void) {
@@ -224,6 +232,7 @@ static void test_client_id_hash(void) {
int main(int argc, char *argv[]) {
_cleanup_event_unref_ sd_event *e;
+ int r;
log_set_max_level(LOG_DEBUG);
log_parse_environment();
@@ -231,7 +240,10 @@ int main(int argc, char *argv[]) {
assert_se(sd_event_new(&e) >= 0);
- test_basic(e);
+ r = test_basic(e);
+ if (r != 0)
+ return r;
+
test_message_handler();
test_client_id_hash();