diff options
author | Dmitry V. Levin <ldv@strace.io> | 2023-04-27 08:00:00 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-04-28 08:00:00 +0000 |
commit | 4d9a6f0ac6bd8e8644340e3de3f6a2f4b164f2fe (patch) | |
tree | fa0996f8640ac1be24a761812714b03c49dfcb0e | |
parent | 3ed268876dd5b65263449f9aeb18a1cc2604c707 (diff) | |
download | strace-4d9a6f0ac6bd8e8644340e3de3f6a2f4b164f2fe.tar.gz |
tests: fix strace--syscall-limit test
* tests/strace--syscall-limit.c: Include "scno.h" and <fcntl.h>.
(test_rmdir): Invoke unlinkat syscall instead of rmdir because the
latter is not guaranteed to be present on all architectures nowadays.
* tests/strace--syscall-limit.test: Filter unlinkat syscall instead of
rmdir.
Fixes: v6.2-15-g628b7eb7449e "tests: check -l/--syscall-limit options"
-rw-r--r-- | tests/strace--syscall-limit.c | 15 | ||||
-rwxr-xr-x | tests/strace--syscall-limit.test | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/tests/strace--syscall-limit.c b/tests/strace--syscall-limit.c index 590ba6623..260337d49 100644 --- a/tests/strace--syscall-limit.c +++ b/tests/strace--syscall-limit.c @@ -8,8 +8,10 @@ */ #include "tests.h" +#include "scno.h" #include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -60,10 +62,17 @@ test_chdir(int pid, bool print) static void test_rmdir(int pid, bool print) { - if (rmdir(invalid_path) == 0) - error_msg_and_fail("rmdir: %s", invalid_path); +#ifndef AT_FDCWD +# define AT_FDCWD -100 +#endif +#ifndef AT_REMOVEDIR +# define AT_REMOVEDIR 0x200 +#endif + if (syscall(__NR_unlinkat, AT_FDCWD, "invalid.dir", AT_REMOVEDIR) == 0) + error_msg_and_fail("unlinkat: %s", invalid_path); if (print) - printf("%-5u rmdir(\"%s\") = %s\n", pid, invalid_path, sprintrc(-1)); + printf("%-5u unlinkat(AT_FDCWD, \"%s\", AT_REMOVEDIR) = %s\n", + pid, invalid_path, sprintrc(-1)); } int diff --git a/tests/strace--syscall-limit.test b/tests/strace--syscall-limit.test index 410c24a3d..bcc4a9545 100755 --- a/tests/strace--syscall-limit.test +++ b/tests/strace--syscall-limit.test @@ -10,7 +10,7 @@ . "${srcdir=.}/init.sh" prog_args="../$NAME" -set -- --syscall-limit=3 --trace='chdir,rmdir' "$@" +set -- --syscall-limit=3 --trace='chdir,unlinkat' "$@" run_prog > /dev/null echo 0 > exp_status |