[PATCH 3/4] tests: add symlinkat.test

Fei Jie feij.fnst at cn.fujitsu.com
Tue Apr 19 07:38:34 UTC 2016


* tests/symlinkat.c: New file.
* tests/symlinkat.test: New test.
* tests/.gitignore: Add symlinkat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add symlinkat.test.
---
 tests/.gitignore     |  1 +
 tests/Makefile.am    |  2 ++
 tests/symlinkat.c    | 29 +++++++++++++++++++++++++++++
 tests/symlinkat.test |  6 ++++++
 4 files changed, 38 insertions(+)
 create mode 100644 tests/symlinkat.c
 create mode 100755 tests/symlinkat.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 31e39b4..fd5909b 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -155,6 +155,7 @@ stat
 stat64
 statfs
 swap
+symlinkat
 sync_file_range
 sync_file_range2
 sysinfo
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 44bc44b..7231818 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -205,6 +205,7 @@ check_PROGRAMS = \
 	stat64 \
 	statfs \
 	swap \
+	symlinkat \
 	sync_file_range \
 	sync_file_range2 \
 	sysinfo \
@@ -411,6 +412,7 @@ DECODER_TESTS = \
 	statfs.test \
 	sun_path.test \
 	swap.test \
+	symlinkat.test \
 	sync_file_range.test \
 	sync_file_range2.test \
 	sysinfo.test \
diff --git a/tests/symlinkat.c b/tests/symlinkat.c
new file mode 100644
index 0000000..5d1c032
--- /dev/null
+++ b/tests/symlinkat.c
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_symlinkat
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+   const long int fd = (long int) 0xdeadbeefffffffff;
+   static const char oldpath[] = "symlink_old";
+   static const char newpath[] = "symlink_new";
+   int rc = syscall(__NR_symlinkat, oldpath, fd, newpath);
+   printf("symlinkat(\"%s\", %d, \"%s\") = %d %s (%m)\n",
+          oldpath, (int) fd, newpath, rc,
+          errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+   puts("+++ exited with 0 +++");
+   return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_symlinkat")
+
+#endif
diff --git a/tests/symlinkat.test b/tests/symlinkat.test
new file mode 100755
index 0000000..d8501ff
--- /dev/null
+++ b/tests/symlinkat.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check symlinkat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff
-- 
1.8.3.1







More information about the Strace-devel mailing list