From: Daniel Wagner <wagi@monom.org>
To: ell@lists.01.org
Subject: [PATCH 2/3] unit: Add unit test for l_rtnl_route6_{dump|extract}
Date: Fri, 14 Feb 2020 19:52:52 +0100 [thread overview]
Message-ID: <20200214185253.32658-3-wagi@monom.org> (raw)
In-Reply-To: <20200214185253.32658-1-wagi@monom.org>
[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]
---
unit/test-rtnl.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/unit/test-rtnl.c b/unit/test-rtnl.c
index c0659c4378da..37db73dc6f2f 100644
--- a/unit/test-rtnl.c
+++ b/unit/test-rtnl.c
@@ -139,6 +139,37 @@ static void test_route4_dump(struct l_netlink *rtnl, void *user_data)
NULL, route4_dump_destroy_cb));
}
+static void route6_dump_cb(int error,
+ uint16_t type, const void *data,
+ uint32_t len, void *user_data)
+{
+ const struct rtmsg *rtmsg = data;
+ char *dst = NULL, *gateway = NULL, *src = NULL;
+ uint32_t idx;
+
+ test_assert(!error);
+ test_assert(type == RTM_NEWROUTE);
+
+ l_rtnl_route6_extract(rtmsg, len, &idx, &dst, &gateway, &src);
+
+ l_info("idx %d dst %s gateway %s src %s", idx, dst, gateway, src);
+
+ l_free(dst);
+ l_free(gateway);
+ l_free(src);
+}
+
+static void route6_dump_destroy_cb(void *user_data)
+{
+ test_next();
+}
+
+static void test_route6_dump(struct l_netlink *rtnl, void *user_data)
+{
+ test_assert(l_rtnl_route6_dump(rtnl, route6_dump_cb,
+ NULL, route6_dump_destroy_cb));
+}
+
static void ifaddr4_dump_cb(int error,
uint16_t type, const void *data,
uint32_t len, void *user_data)
@@ -211,6 +242,7 @@ int main(int argc, char *argv[])
return -1;
test_add("Dump IPv4 routing table", test_route4_dump, NULL);
+ 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);
--
2.25.0
next prev parent reply other threads:[~2020-02-14 18:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 18:52 [PATCH 0/3] rtnl: add missing APIs Daniel Wagner
2020-02-14 18:52 ` [PATCH 1/3] rtnl: Add l_rtnl_route6_dump() and l_rtnl_route6_extract() Daniel Wagner
2020-02-14 18:52 ` Daniel Wagner [this message]
2020-02-14 18:52 ` [PATCH 3/3] rtnl: Extract table, priority and pref Daniel Wagner
2020-02-14 19:05 ` [PATCH 0/3] rtnl: add missing APIs Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200214185253.32658-3-wagi@monom.org \
--to=wagi@monom.org \
--cc=ell@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.