[PATCH 4/4] tests: add symlink.test

Fei Jie feij.fnst at cn.fujitsu.com
Mon Apr 25 08:18:23 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 4ce2b06..e17b26c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -199,6 +199,7 @@ stat
 stat64
 statfs
 swap
+symlink
 symlinkat
 sync_file_range
 sync_file_range2
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 92d4310..d23d0d8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -250,6 +250,7 @@ check_PROGRAMS = \
 	stat64 \
 	statfs \
 	swap \
+	symlink \
 	symlinkat \
 	sync_file_range \
 	sync_file_range2 \
@@ -498,6 +499,7 @@ DECODER_TESTS = \
 	statfs.test \
 	sun_path.test \
 	swap.test \
+	symlink.test \
 	symlinkat.test \
 	sync_file_range.test \
 	sync_file_range2.test \
diff --git a/tests/symlink.c b/tests/symlink.c
new file mode 100644
index 0000000..bb324aa
--- /dev/null
+++ b/tests/symlink.c
@@ -0,0 +1,26 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_symlink
+
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+    static const char sample_1[] = "symlink_new";
+    static const char sample_2[] = "symlink";
+	long rc = syscall(__NR_symlink, sample_1, sample_2);
+	printf("symlink(\"%s\", \"%s\") = %ld %s (%m)\n",
+	       sample_1, sample_2, rc, errno2name());
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_symlink")
+
+#endif
diff --git a/tests/symlink.test b/tests/symlink.test
new file mode 100755
index 0000000..79b93ba
--- /dev/null
+++ b/tests/symlink.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check symlink syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a34
-- 
1.8.3.1







More information about the Strace-devel mailing list