summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2023-04-06 18:18:35 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2023-04-06 18:18:35 +0200
commit0d80c1cbaa98b200335a966df4d47333f54b1e71 (patch)
tree3ab1b0a2c6edc1dd1149bb5e1948f07056984de3
parente56710c6e58f22522dab752046896dc074f221c7 (diff)
downloadstrace-esyr/trace-fds.tar.gz
tests: expand symlink test, add symlink-P testesyr/trace-fds
* 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/.gitignore1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/gen_tests.in3
-rw-r--r--tests/symlink-P.c2
-rw-r--r--tests/symlink.c41
5 files changed, 45 insertions, 3 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index e54fb5e26..394999662 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1045,6 +1045,7 @@ strace-xx
swap
sxetmask
symlink
+symlink-P
symlinkat
sync
sync_file_range
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4aaedb626..9b4a3be23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -389,6 +389,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 8fdfdf7b1..e40532e98 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -1043,7 +1043,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;