On 02/16 02:19, Harsha Sharma wrote: > * tests/netlink_kobject_uevent_libudev.c: New file. > * tests/gen_tests.in (netlink_kobject_uevent_libudev): New entry. > * tests/pure_executables.list: Add netlink_kobject_uevent_libudev. > * tests/.gitignore: Likewise. > > Signed-off-by: Harsha Sharma <harshasharmai...@gmail.com> > --- > tests/.gitignore | 1 + > tests/gen_tests.in | 1 + > tests/netlink_kobject_uevent_libudev.c | 88 > ++++++++++++++++++++++++++++++++++ > tests/pure_executables.list | 1 + > 4 files changed, 91 insertions(+) > create mode 100644 tests/netlink_kobject_uevent_libudev.c > > diff --git a/tests/.gitignore b/tests/.gitignore > index 2541ec24..623b98f8 100644 > --- a/tests/.gitignore > +++ b/tests/.gitignore > @@ -215,6 +215,7 @@ netlink_crypto > netlink_generic > netlink_inet_diag > netlink_kobject_uevent > +netlink_kobject_uevent_libudev > netlink_netfilter > netlink_netlink_diag > netlink_protocol > diff --git a/tests/gen_tests.in b/tests/gen_tests.in > index 18f36408..263479a5 100644 > --- a/tests/gen_tests.in > +++ b/tests/gen_tests.in > @@ -199,6 +199,7 @@ netlink_audit +netlink_sock_diag.test > netlink_crypto +netlink_sock_diag.test > netlink_generic +netlink_sock_diag.test > netlink_kobject_uevent +netlink_sock_diag.test > +netlink_kobject_uevent_libudev +netlink_sock_diag.test > netlink_netfilter +netlink_sock_diag.test > netlink_protocol -e trace=sendto > netlink_route +netlink_sock_diag.test > diff --git a/tests/netlink_kobject_uevent_libudev.c > b/tests/netlink_kobject_uevent_libudev.c > new file mode 100644 > index 00000000..8f0b2bfa > --- /dev/null > +++ b/tests/netlink_kobject_uevent_libudev.c > @@ -0,0 +1,88 @@ > +/* > + * Copyright (c) 2017 JingPiao Chen <chenjingp...@gmail.com> > + * Copyright (c) 2017 The strace developers. > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * 3. The name of the author may not be used to endorse or promote products > + * derived from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + */ > + > +#include "tests.h" > +#include <stdio.h> > +#include <string.h> > +#include <sys/socket.h> > +#include "netlink.h" > +#include "netlink_kobject_uevent.h" > +#include <sys/types.h> > +#include <unistd.h> > +#include <arpa/inet.h> > +#include <fcntl.h> > + > +int > +main(void) > +{ > + skip_if_unavailable("/proc/self/fd/"); > + > + int fd, ret; > + struct sockaddr_nl nls; > + struct udev_monitor_netlink_header uh; > + > + memset(&nls, 0, sizeof(nls)); > + nls.nl_family = AF_NETLINK; > + nls.nl_pid = getpid(); > + nls.nl_groups = -1; > + > + fd = socket(AF_NETLINK, (SOCK_DGRAM | SOCK_CLOEXEC), > + NETLINK_KOBJECT_UEVENT); > + if (fd < 0) > + perror_msg_and_skip("socket AF_NETLINK"); > + > + ret = bind(fd, (struct sockaddr *) &nls, sizeof(nls)); > + if (ret) > + perror_msg_and_skip("bind AF_NETLINK");
Replace with create_nl_socket(). > + > + printf("Waiting for events now...\n"); Why print this message? > + while (1) { > + int r = recv(fd, &uh, sizeof(uh), MSG_ERRQUEUE); > + if (r <= 0) > + perror_msg_and_skip("recv"); > + if (!strcmp(uh.prefix, "libudev")) > + printf("recvfrom(%i, {{prefix=\"%s\"" > + ", magic=htonl(%#x), header_size=%u" > + ", properties_off=%u, properties_len=%u" > + ", filter_subsystem_hash=htonl(%#x)" > + ", filter_devtype_hash=htonl(%#x)" > + ", filter_tag_bloom_hi=htonl(%#x)" > + ", filter_tag_bloom_lo=htonl(%#x)}}, %li" > + ", MSG_ERRQUEUE, NULL, NULL)\n", > + fd, uh.prefix, ntohl(uh.magic), uh.header_size, > + uh.properties_off, uh.properties_len, > + ntohl(uh.filter_subsystem_hash), > + ntohl(uh.filter_devtype_hash), > + ntohl(uh.filter_tag_bloom_hi), > + ntohl(uh.filter_tag_bloom_lo), sizeof(uh)); > + } I do not understand how this work. travis-ci is fail. netlink_kobject_uevent_libudev.gen.test source netlink_sock_diag.test, which only trace sendto syscall. > + > + close(fd); > + puts("+++ exited with 0 +++"); > + return 0; > +} > diff --git a/tests/pure_executables.list b/tests/pure_executables.list > index 2f602a93..1ed40d1f 100755 > --- a/tests/pure_executables.list > +++ b/tests/pure_executables.list > @@ -175,6 +175,7 @@ netlink_audit > netlink_crypto > netlink_generic > netlink_kobject_uevent > +netlink_kobject_uevent_libudev > netlink_netfilter > netlink_protocol > netlink_route > -- > 2.14.1 > -- Chen Jingpiao ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel