]> granicus.if.org Git - strace/commitdiff
openat.test: robustify against libcs invoking openat syscall on their own
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 28 Mar 2016 00:16:02 +0000 (00:16 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 28 Mar 2016 00:16:02 +0000 (00:16 +0000)
* tests/openat.c (main): Rename fname to sample, change its value
to "openat.sample".
* tests/openat.test: Use -P option to filter out openat syscalls
made by libc and dynamic linker.

tests/openat.c
tests/openat.test

index 63d0393a949600cd91a7c522ce2e5ecffb57d78e..f769f6e978fe256d9175ea9850632f10ee5b0bbf 100644 (file)
 int
 main(void)
 {
-       static const char fname[] = "openat_test_file";
+       static const char sample[] = "openat.sample";
        int fd;
 
-       fd = syscall(__NR_openat, -100, fname, O_RDONLY|O_CREAT, 0400);
+       fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
        if (fd == -1) {
                if (errno == ENOSYS) {
                        printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT"
-                              ", 0400) = -1 ENOSYS (%m)\n", fname);
+                              ", 0400) = -1 ENOSYS (%m)\n", sample);
                } else {
                        perror_msg_and_fail("openat");
                }
        } else {
                printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT"
-                      ", 0400) = %d\n", fname, fd);
+                      ", 0400) = %d\n", sample, fd);
                close(fd);
-               if (unlink(fname) == -1)
+               if (unlink(sample) == -1)
                        perror_msg_and_fail("unlink");
-               fd = syscall(__NR_openat, -100, fname, O_RDONLY);
+               fd = syscall(__NR_openat, -100, sample, O_RDONLY);
                if (fd == -1 && errno == ENOENT) {
                        printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d ENOENT"
-                              " (%m)\n", fname, fd);
+                              " (%m)\n", sample, fd);
                } else {
                        perror_msg_and_fail("openat");
                }
index 7f52d8202ad40ac220b5a79d26795fb7f6f69601..a498c32327527cbf88b4d033813df3962b2e8177 100755 (executable)
@@ -4,8 +4,14 @@
 
 . "${srcdir=.}/init.sh"
 
+# strace -P is implemented using /proc/self/fd
+[ -d /proc/self/fd/ ] ||
+       framework_skip_ '/proc/self/fd/ is not available'
+
 run_prog > /dev/null
 OUT="$LOG.out"
-run_strace -eopenat $args > "$OUT"
+syscall=${ME_%.test}
+sample=$syscall.sample
+run_strace -e$syscall -P$sample $args > "$OUT"
 match_diff "$LOG" "$OUT"
 rm -f "$OUT"