From: Dmitry V. Levin Date: Mon, 28 Mar 2016 00:16:02 +0000 (+0000) Subject: openat.test: robustify against libcs invoking openat syscall on their own X-Git-Tag: v4.12~488 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=347a5d45ec3b4a1a2e0e47cc3216e6f183a11073;p=strace openat.test: robustify against libcs invoking openat syscall on their own * 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. --- diff --git a/tests/openat.c b/tests/openat.c index 63d0393a..f769f6e9 100644 --- a/tests/openat.c +++ b/tests/openat.c @@ -38,27 +38,27 @@ 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"); } diff --git a/tests/openat.test b/tests/openat.test index 7f52d820..a498c323 100755 --- a/tests/openat.test +++ b/tests/openat.test @@ -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"