diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2023-04-06 18:18:35 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-04-22 08:00:00 +0000 |
commit | 116006e28889820e19f1f730fbfb449696143924 (patch) | |
tree | 49269e3829c69cecf5beeb450f60828473b56b32 | |
parent | 10aa58e55b7b3f7572777d888a218cc5e4318f61 (diff) | |
download | strace-116006e28889820e19f1f730fbfb449696143924.tar.gz |
tests: expand symlink test, add symlink-P test
* tests/.gitignore: Add symlink-P.
* tests/Makefile.am (check_PROGRAMS): Likewise.
* tests/gen_tests.in (symlink): Change the alignment from 32 to 20
columns.
(symlink-P): New test.
* tests/symlink-P.c: New file.
* tests/symlink.c: Add checks, print the output based on the presence
of the PATH_TRACING macro.
-rw-r--r-- | tests/.gitignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/gen_tests.in | 3 | ||||
-rw-r--r-- | tests/symlink-P.c | 2 | ||||
-rw-r--r-- | tests/symlink.c | 41 |
5 files changed, 45 insertions, 3 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index eff845cdd..62f1fd0f4 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1048,6 +1048,7 @@ strace-xx swap sxetmask symlink +symlink-P symlinkat sync sync_file_range diff --git a/tests/Makefile.am b/tests/Makefile.am index 6cb13c28f..b2734b77b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -392,6 +392,7 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \ strace-Y-0123456789 \ strace-p-Y-p2 \ strace-p1-Y-p \ + symlink-P \ syslog-success \ tgkill--pidns-translation \ threads-execve \ diff --git a/tests/gen_tests.in b/tests/gen_tests.in index cf5bf17b2..94f91e485 100644 --- a/tests/gen_tests.in +++ b/tests/gen_tests.in @@ -1045,7 +1045,8 @@ strace-x -e trace=chdir -x -a 12 strace-xx -e trace=chdir -xx -a 18 swap -a23 -e trace=swapon,swapoff sxetmask -a11 -e trace=sgetmask,ssetmask -symlink -a34 +symlink -a20 +symlink-P -a32 -e trace=symlink -P "symlink.sample" symlinkat sync -a7 sync_file_range diff --git a/tests/symlink-P.c b/tests/symlink-P.c new file mode 100644 index 000000000..53a3d183e --- /dev/null +++ b/tests/symlink-P.c @@ -0,0 +1,2 @@ +#define PATH_TRACING +#include "symlink.c" diff --git a/tests/symlink.c b/tests/symlink.c index c47ad842d..7b61bc71e 100644 --- a/tests/symlink.c +++ b/tests/symlink.c @@ -11,15 +11,52 @@ #ifdef __NR_symlink # include <stdio.h> +# include <string.h> # include <unistd.h> int main(int ac, char **av) { - static const char sample[] = "symlink.sample"; + static const char sample_str[] = "symlink.sample"; + static const char target_str[] = "symlink.target"; - long rc = syscall(__NR_symlink, sample, av[0]); + TAIL_ALLOC_OBJECT_CONST_ARR(char, sample, sizeof(sample_str)); + TAIL_ALLOC_OBJECT_CONST_ARR(char, target, sizeof(target_str)); + TAIL_ALLOC_OBJECT_CONST_ARR(char, short_sample, sizeof(sample_str) - 1); + TAIL_ALLOC_OBJECT_CONST_ARR(char, short_target, sizeof(target_str) - 1); + + long rc; + + memcpy(sample, sample_str, sizeof(sample_str)); + memcpy(target, target_str, sizeof(target_str)); + memcpy(short_sample, sample_str, sizeof(sample_str) - 1); + memcpy(short_target, target_str, sizeof(target_str) - 1); + + rc = syscall(__NR_symlink, NULL, NULL); +# ifndef PATH_TRACING + printf("symlink(NULL, NULL) = %s\n", sprintrc(rc)); +# endif + + rc = syscall(__NR_symlink, NULL, sample); + printf("symlink(NULL, \"%s\") = %s\n", sample, sprintrc(rc)); + + rc = syscall(__NR_symlink, short_target, sample); + printf("symlink(%p, \"%s\") = %s\n", + short_target, sample, sprintrc(rc)); + + rc = syscall(__NR_symlink, target, short_sample); +# ifndef PATH_TRACING + printf("symlink(\"%s\", %p) = %s\n", + target, short_sample, sprintrc(rc)); +# endif + + rc = syscall(__NR_symlink, sample, av[0]); +# ifndef PATH_TRACING printf("symlink(\"%s\", \"%s\") = %s\n", sample, av[0], sprintrc(rc)); +# endif + + rc = syscall(__NR_symlink, target, sample); + printf("symlink(\"%s\", \"%s\") = %s\n", target, sample, sprintrc(rc)); puts("+++ exited with 0 +++"); return 0; |