diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-18 19:32:45 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-18 19:32:45 +0100 |
commit | b25ef18b334d85d54f50478446bf81fe214cb2fc (patch) | |
tree | 2565dc0bc9d540ad173600ca8a90eb0d8054a022 /src/libsystemd/test-dhcp-client.c | |
parent | 35bbea48dcb74ed2ecc1cab1ca7306acf6d6bb65 (diff) |
sd-dhcp-client: refactor client_{free,new}
Make them more simiar to sd_bus and friends. Also factor out the event attachment. In the future,
we will likely want to support external main-loops, so this is a first step. For the time being,
we are still requiring an sd_event to be attached though.
Diffstat (limited to 'src/libsystemd/test-dhcp-client.c')
-rw-r--r-- | src/libsystemd/test-dhcp-client.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libsystemd/test-dhcp-client.c b/src/libsystemd/test-dhcp-client.c index 929b869ec3..56a10b3dfc 100644 --- a/src/libsystemd/test-dhcp-client.c +++ b/src/libsystemd/test-dhcp-client.c @@ -42,12 +42,18 @@ static int test_fd[2]; static void test_request_basic(sd_event *e) { + int r; + sd_dhcp_client *client; - client = sd_dhcp_client_new(e); + r = sd_dhcp_client_new(&client); + assert(r >= 0); assert(client); + r = sd_dhcp_client_attach_event(client, e, 0); + assert(r >= 0); + assert(sd_dhcp_client_set_request_option(NULL, 0) == -EINVAL); assert(sd_dhcp_client_set_request_address(NULL, NULL) == -EINVAL); assert(sd_dhcp_client_set_index(NULL, 0) == -EINVAL); @@ -199,11 +205,15 @@ int dhcp_network_send_udp_socket(int s, be32_t server_address, static void test_discover_message(sd_event *e) { sd_dhcp_client *client; - int res; + int res, r; - client = sd_dhcp_client_new(e); + r = sd_dhcp_client_new(&client); + assert(r >= 0); assert(client); + r = sd_dhcp_client_attach_event(client, e, 0); + assert(r >= 0); + assert(sd_dhcp_client_set_index(client, 42) >= 0); assert(sd_dhcp_client_set_mac(client, &mac_addr) >= 0); |