summaryrefslogtreecommitdiff
path: root/src/libsystemd-rtnl/test-rtnl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-11-30 01:24:29 +0100
committerTom Gundersen <teg@jklm.no>2013-12-04 14:15:13 +0100
commit8cec01b9e9b7264639fd1fc0fe373ef4d5baaf49 (patch)
tree6db638964058da2a30a7839fc7fe03de9b3c3732 /src/libsystemd-rtnl/test-rtnl.c
parenta02113d2ea96467dc9f1ec196d5f62a34dd99314 (diff)
rtnl: add callback support
sd_rtnl_add_match allows you to add a callback function for when given types of messages are received.
Diffstat (limited to 'src/libsystemd-rtnl/test-rtnl.c')
-rw-r--r--src/libsystemd-rtnl/test-rtnl.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsystemd-rtnl/test-rtnl.c b/src/libsystemd-rtnl/test-rtnl.c
index 4b62c02361..a512a7b2f7 100644
--- a/src/libsystemd-rtnl/test-rtnl.c
+++ b/src/libsystemd-rtnl/test-rtnl.c
@@ -230,6 +230,21 @@ static void test_container(void) {
*/
}
+static void test_match(void) {
+ _cleanup_sd_rtnl_unref_ sd_rtnl *rtnl = NULL;
+
+ assert(sd_rtnl_open(0, &rtnl) >= 0);
+
+ assert(sd_rtnl_add_match(rtnl, 0, &link_handler, NULL) == -EINVAL);
+
+ assert(sd_rtnl_add_match(rtnl, RTMGRP_LINK, &link_handler, NULL) >= 0);
+ assert(sd_rtnl_add_match(rtnl, RTMGRP_LINK, &link_handler, NULL) >= 0);
+
+ assert(sd_rtnl_remove_match(rtnl, RTMGRP_LINK, &link_handler, NULL) == 1);
+ assert(sd_rtnl_remove_match(rtnl, RTMGRP_LINK, &link_handler, NULL) == 1);
+ assert(sd_rtnl_remove_match(rtnl, RTMGRP_LINK, &link_handler, NULL) == 0);
+}
+
int main(void) {
sd_rtnl *rtnl;
sd_rtnl_message *m;
@@ -240,6 +255,8 @@ int main(void) {
unsigned int mtu = 0;
unsigned int *mtu_reply;
+ test_match();
+
test_multiple();
test_route();