[systemd-commits] src/libsystemd-network
Tom Gundersen
tomegun at kemper.freedesktop.org
Fri Jun 13 10:11:37 PDT 2014
src/libsystemd-network/test-dhcp-server.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
New commits:
commit 6f08fb7b34b4eebf664de83c8bc7b9941658aeb4
Author: Tom Gundersen <teg at jklm.no>
Date: Fri Jun 13 19:11:31 2014 +0200
sd-dhcp-server: test - skip when lacking perms
diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c
index 6b3b4d0..a9bdb9a 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();
More information about the systemd-commits
mailing list