[PATCH 2/4] tests: add fchdir.test

Fei Jie feij.fnst at cn.fujitsu.com
Thu Apr 21 07:53:50 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index fbced77..7e67427 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -38,6 +38,7 @@ execveat
 execveat-v
 faccessat
 fanotify_mark
+fchdir
 fchmod
 fchmodat
 fchown
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ad9cddd..bc05d98 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -90,6 +90,7 @@ check_PROGRAMS = \
 	execveat-v \
 	faccessat \
 	fanotify_mark \
+	fchdir \
 	fchmod \
 	fchmodat \
 	fchown \
@@ -338,6 +339,7 @@ DECODER_TESTS = \
 	execveat.test \
 	faccessat.test \
 	fanotify_mark.test \
+	fchdir.test \
 	fchmod.test \
 	fchmodat.test \
 	fchown.test \
diff --git a/tests/fchdir.c b/tests/fchdir.c
new file mode 100644
index 0000000..9a58f50
--- /dev/null
+++ b/tests/fchdir.c
@@ -0,0 +1,27 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_fchdir
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	const long int fd = (long int) 0xdeadbeefffffffff;
+	int rc = syscall(__NR_fchdir, fd);
+	printf("fchdir(%d) = %d %s (%m)\n",
+	       (int) fd, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_fchdir")
+
+#endif
diff --git a/tests/fchdir.test b/tests/fchdir.test
new file mode 100755
index 0000000..3a4296e
--- /dev/null
+++ b/tests/fchdir.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check fchdir syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a11
-- 
1.8.3.1







More information about the Strace-devel mailing list