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

Fei Jie feij.fnst at cn.fujitsu.com
Wed May 11 07:07:28 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 96533fb..44ae1a9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -104,6 +104,7 @@ ksysent.h
 lchown
 lchown32
 libtests.a
+link
 linkat
 llseek
 lseek
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ce26306..27aecd2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -157,6 +157,7 @@ check_PROGRAMS = \
 	ksysent \
 	lchown \
 	lchown32 \
+	link \
 	linkat \
 	llseek \
 	lseek \
@@ -440,6 +441,7 @@ DECODER_TESTS = \
 	kill.test \
 	lchown.test \
 	lchown32.test \
+	link.test \
 	linkat.test \
 	llseek.test \
 	lseek.test \
diff --git a/tests/link.c b/tests/link.c
new file mode 100644
index 0000000..4b84e41
--- /dev/null
+++ b/tests/link.c
@@ -0,0 +1,27 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_link
+
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	static const char sample_1[] = "link_sample_old";
+	static const char sample_2[] = "link_sample_new";
+
+	long rc = syscall(__NR_link, sample_1, sample_2);
+	printf("link(\"%s\", \"%s\") = %ld %s (%m)\n",
+	       sample_1, sample_2, rc, errno2name());
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_link")
+
+#endif
diff --git a/tests/link.test b/tests/link.test
new file mode 100755
index 0000000..cfa2b0c
--- /dev/null
+++ b/tests/link.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check link syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff
-- 
1.8.3.1







More information about the Strace-devel mailing list