]> granicus.if.org Git - strace/commitdiff
tests: add kcmp-y test
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sat, 16 Sep 2017 01:04:40 +0000 (03:04 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 17 Sep 2017 12:04:11 +0000 (12:04 +0000)
It is not very useful as of now, but it will allow tracking changes
in fd output once they are implemented.

* tests/gen_tests.in (kcmp-y): New test.
* tests/kcmp-y.c: New file, wrapper for kcmp.c
* tests/kcmp.c: Add opening of some files for which info may be printed
in the future.
* tests/pure_executables.list: Add kcmp-y.
* tests/.gitignore: Likewise.

tests/.gitignore
tests/gen_tests.in
tests/kcmp-y.c [new file with mode: 0644]
tests/kcmp.c
tests/pure_executables.list

index e8e6d89943b4475f0e92179d58b6fb11c02caced..14a64a95df1c872c6baf853b8b9bafeff5128953 100644 (file)
@@ -150,6 +150,7 @@ ipc_sem
 ipc_shm
 is_linux_mips_n64
 kcmp
+kcmp-y
 kexec_file_load
 kexec_load
 keyctl
@@ -218,8 +219,8 @@ netlink_unix_diag
 netlink_xfrm
 newfstatat
 nlattr
-nlattr_crypto_user_alg
 nlattr_br_port_msg
+nlattr_crypto_user_alg
 nlattr_dcbmsg
 nlattr_fib_rule_hdr
 nlattr_ifaddrlblmsg
index 9f398e03510009364d82f6b91032e90417d8833e..a7b5676122e1c7bf5fac5b6c12d5484e06300835 100644 (file)
@@ -144,6 +144,7 @@ ipc_msg     +ipc.sh
 ipc_sem        +ipc.sh
 ipc_shm        +ipc.sh
 kcmp   -a22
+kcmp-y -a22 -y -e trace=kcmp
 kexec_file_load        -s9
 kexec_load     -s9
 keyctl -a31 -s10
diff --git a/tests/kcmp-y.c b/tests/kcmp-y.c
new file mode 100644 (file)
index 0000000..02ad90e
--- /dev/null
@@ -0,0 +1,3 @@
+#define VERBOSE_FD 1
+
+#include "kcmp.c"
index 62a24d91517aed0d8aa0eaedaecd1d3e3cb5fe7f..652352e918b0046273213b76d498a9c952f0999c 100644 (file)
 
 #ifdef __NR_kcmp
 
+# include <fcntl.h>
 # include <stdio.h>
 # include <unistd.h>
 
+# ifndef VERBOSE_FD
+#  define VERBOSE_FD 0
+# endif
 
 /*
  * We prefer to use system headers in order to catch some possible deviations in
 #  define KCMP_SYSVSEM 6
 # endif
 
+static const char null_path[] = "/dev/null";
+static const char zero_path[] = "/dev/zero";
+
+# define NULL_FD 23
+# define ZERO_FD 42
+
 static void
 printpidfd(const char *prefix, pid_t pid, unsigned fd)
 {
@@ -103,6 +113,27 @@ main(void)
        static const kernel_ulong_t bogus_idx2 =
                (kernel_ulong_t) 0xba5e1e55deadc0deULL;
 
+       int fd;
+
+       /* Open some files to test printpidfd */
+       fd = open(null_path, O_RDONLY);
+       if (fd < 0)
+               perror_msg_and_fail("open(\"%s\")", null_path);
+       if (fd != NULL_FD) {
+               if (dup2(fd, NULL_FD) < 0)
+                       perror_msg_and_fail("dup2(fd, NULL_FD)");
+               close(fd);
+       }
+
+       fd = open(zero_path, O_RDONLY);
+       if (fd < 0)
+               perror_msg_and_fail("open(\"%s\")", zero_path);
+       if (fd != ZERO_FD) {
+               if (dup2(fd, ZERO_FD) < 0)
+                       perror_msg_and_fail("dup2(fd, ZERO_FD)");
+               close(fd);
+       }
+
        /* Invalid values */
        do_kcmp(bogus_pid1, bogus_pid2, bogus_type, NULL, bogus_idx1,
                bogus_idx2);
@@ -112,6 +143,7 @@ main(void)
        /* KCMP_FILE is the only type which has additional args */
        do_kcmp(3141592653U, 2718281828U, ARG_STR(KCMP_FILE), bogus_idx1,
                bogus_idx2);
+       do_kcmp(-1, -1, ARG_STR(KCMP_FILE), NULL_FD, ZERO_FD);
 
        /* Types without additional args */
        do_kcmp(-1, -1, ARG_STR(KCMP_VM), bogus_idx1, bogus_idx2);
index 8210c91049d167d09370198f5f308733bea7ee53..957674a25c718387eaeacf56e778448861812176 100755 (executable)
@@ -122,6 +122,7 @@ ipc_msgbuf
 ipc_sem
 ipc_shm
 kcmp
+kcmp-y
 kexec_file_load
 kexec_load
 keyctl