---
unit/test-rtnl.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/unit/test-rtnl.c b/unit/test-rtnl.c
index 107f69a..9826272 100644
--- a/unit/test-rtnl.c
+++ b/unit/test-rtnl.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
+#include <netinet/in.h>
#include <ell/ell.h>
#include "ell/dbus-private.h"
@@ -232,6 +233,30 @@ static void test_ifaddr6_dump(struct l_netlink *rntl, void
*user_data)
NULL, ifaddr6_dump_destroy_cb));
}
+static void test_get_address(struct l_netlink *rntl, void *user_data)
+{
+ static const char ip[] = "192.0.2.1";
+ static const uint8_t prefix_len = 32;
+ struct l_rtnl_address *addr = NULL;
+ size_t buflen, badlen;
+
+ char buf[INET_ADDRSTRLEN];
+ buflen = L_ARRAY_SIZE(buf);
+ badlen = 4;
+
+ addr = l_rtnl_address_new(ip, prefix_len);
+ test_assert(addr);
+
+ test_assert(l_rtnl_address_get_address(addr, buf, buflen));
+ test_assert(!l_rtnl_address_get_address(addr, buf, badlen));
+
+ test_assert(strcmp(ip, buf) == 0);
+
+ l_rtnl_address_free(addr);
+
+ test_next();
+}
+
static void test_run(void)
{
success = false;
@@ -249,6 +274,7 @@ int main(int argc, char *argv[])
test_add("Dump IPv6 routing table", test_route6_dump, NULL);
test_add("Dump IPv4 addresses", test_ifaddr4_dump, NULL);
test_add("Dump IPv6 addresses", test_ifaddr6_dump, NULL);
+ test_add("Get address", test_get_address, NULL);
l_log_set_stderr();
--
2.32.0