[PATCH] tests: extend for decoding of udev_monitor_netlink_header
Harsha Sharma
harshasharmaiitr at gmail.com
Wed Mar 7 18:14:50 UTC 2018
*tests/netlink_kobject_uevent.c: Add test_nlmsg_type_udev.
---
tests/netlink_kobject_uevent.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tests/netlink_kobject_uevent.c b/tests/netlink_kobject_uevent.c
index cacab5fd..2853f02b 100644
--- a/tests/netlink_kobject_uevent.c
+++ b/tests/netlink_kobject_uevent.c
@@ -30,6 +30,25 @@
#include <stdio.h>
#include <sys/socket.h>
#include "netlink.h"
+#include "netlink_kobject_uevent.h"
+
+static void
+test_nlmsg_type_udev(const int fd)
+{
+ long ret;
+ struct udev_monitor_netlink_header uh = {
+ .prefix = "libudev",
+ .header_size = sizeof(uh),
+ };
+
+ ret = sendto(fd, &uh, sizeof(uh), MSG_DONTWAIT, NULL, 0);
+ printf("sendto(%d, {{prefix=\"%s\", magic=htonl(0)"
+ ", header_size=%u, properties_off=0, properties_len=0"
+ ", filter_subsystem_hash=htonl(0), filter_devtype_hash=htonl(0)"
+ ", filter_tag_bloom_hi=htonl(0), filter_tag_bloom_lo=htonl(0)}}"
+ ", %u, MSG_DONTWAIT, NULL, 0) = %s\n", fd, uh.prefix, uh.header_size,
+ (unsigned) sizeof(uh), sprintrc(ret));
+}
int
main(void)
@@ -39,6 +58,7 @@ main(void)
long rc;
int fd = create_nl_socket(NETLINK_KOBJECT_UEVENT);
+ test_nlmsg_type_udev(fd);
/* test using data that looks like a zero-length C string */
char *const buf = tail_alloc(DEFAULT_STRLEN + 1);
buf[0] = '=';
--
2.14.1
More information about the Strace-devel
mailing list