[PATCH 1/4] tests: add linkat.test

Fei Jie feij.fnst at cn.fujitsu.com
Wed Apr 6 06:18:48 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index c856bff..85a3491 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -65,6 +65,7 @@ ipc_shm
 ksysent
 ksysent.h
 libtests.a
+linkat
 llseek
 lseek
 lstat
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0ebdf71..e03b619 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -114,6 +114,7 @@ check_PROGRAMS = \
 	ipc_sem \
 	ipc_shm \
 	ksysent \
+	linkat \
 	llseek \
 	lseek \
 	lstat \
@@ -306,6 +307,7 @@ DECODER_TESTS = \
 	ipc_msgbuf.test \
 	ipc_sem.test \
 	ipc_shm.test \
+	linkat.test \
 	llseek.test \
 	lseek.test \
 	lstat.test \
diff --git a/tests/linkat.c b/tests/linkat.c
new file mode 100644
index 0000000..e709c22
--- /dev/null
+++ b/tests/linkat.c
@@ -0,0 +1,30 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_linkat
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	static const char sample_1[] = "sample_old";
+	static const char sample_2[] = "sample_new";
+	const long int fd_old = (long int) 0xdeadbeefffffffff;
+	const long int fd_new = (long int) 0xdeadbeeffffffffe;
+	int rc = syscall(__NR_linkat, fd_old, sample_1, fd_new, sample_2, 0);
+	printf("linkat(%d, \"%s\", %d, \"%s\", 0) = %d %s (%m)\n",
+	       (int) fd_old, sample_1, (int) fd_new, sample_2, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_linkat")
+
+#endif
diff --git a/tests/linkat.test b/tests/linkat.test
new file mode 100755
index 0000000..5627de7
--- /dev/null
+++ b/tests/linkat.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check linkat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff
-- 
1.8.3.1







More information about the Strace-devel mailing list