diff options
Diffstat (limited to 'src/libsystemd-network/test-dhcp-server.c')
-rw-r--r-- | src/libsystemd-network/test-dhcp-server.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c index 7d8a1f6bd9..0ba9adff0a 100644 --- a/src/libsystemd-network/test-dhcp-server.c +++ b/src/libsystemd-network/test-dhcp-server.c @@ -22,14 +22,13 @@ #include <errno.h> +#include "sd-dhcp-server.h" #include "sd-event.h" -#include "event-util.h" -#include "sd-dhcp-server.h" #include "dhcp-server-internal.h" static void test_pool(struct in_addr *address, unsigned size, int ret) { - _cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL; + _cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL; assert_se(sd_dhcp_server_new(&server, 1) >= 0); @@ -37,7 +36,7 @@ static void test_pool(struct in_addr *address, unsigned size, int ret) { } static int test_basic(sd_event *event) { - _cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL; + _cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL; struct in_addr address_lo = { .s_addr = htonl(INADDR_LOOPBACK), }; @@ -86,7 +85,7 @@ static int test_basic(sd_event *event) { } static void test_message_handler(void) { - _cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL; + _cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL; struct { DHCPMessage message; struct { @@ -198,6 +197,15 @@ static void test_message_handler(void) { assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == 0); } +static uint64_t client_id_hash_helper(DHCPClientId *id, uint8_t key[HASH_KEY_SIZE]) { + struct siphash state; + + siphash24_init(&state, key); + client_id_hash_func(id, &state); + + return htole64(siphash24_finalize(&state)); +} + static void test_client_id_hash(void) { DHCPClientId a = { .length = 4, @@ -213,18 +221,18 @@ static void test_client_id_hash(void) { b.data = (uint8_t*)strdup("abcd"); assert_se(client_id_compare_func(&a, &b) == 0); - assert_se(client_id_hash_func(&a, hash_key) == client_id_hash_func(&b, hash_key)); + assert_se(client_id_hash_helper(&a, hash_key) == client_id_hash_helper(&b, hash_key)); a.length = 3; assert_se(client_id_compare_func(&a, &b) != 0); a.length = 4; assert_se(client_id_compare_func(&a, &b) == 0); - assert_se(client_id_hash_func(&a, hash_key) == client_id_hash_func(&b, hash_key)); + assert_se(client_id_hash_helper(&a, hash_key) == client_id_hash_helper(&b, hash_key)); 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_hash_func(&a, hash_key) == client_id_hash_func(&b, hash_key)); + assert_se(client_id_hash_helper(&a, hash_key) == client_id_hash_helper(&b, hash_key)); free(b.data); b.data = (uint8_t*)strdup("abce"); @@ -235,7 +243,7 @@ static void test_client_id_hash(void) { } int main(int argc, char *argv[]) { - _cleanup_event_unref_ sd_event *e; + _cleanup_(sd_event_unrefp) sd_event *e; int r; log_set_max_level(LOG_DEBUG); |