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

Fei Jie feij.fnst at cn.fujitsu.com
Fri Mar 25 09:47:15 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 63a3d1e..8892c06 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -30,6 +30,7 @@ execve
 execve-v
 execveat
 execveat-v
+faccessat
 fanotify_mark
 fchmod
 fcntl
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 679fb90..02a858b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -81,6 +81,7 @@ check_PROGRAMS = \
 	execve-v \
 	execveat \
 	execveat-v \
+	faccessat \
 	fanotify_mark \
 	fchmod \
 	fcntl \
@@ -253,6 +254,7 @@ DECODER_TESTS = \
 	execve-v.test \
 	execveat.test \
 	execveat-v.test \
+	faccessat.test \
 	fanotify_mark.test \
 	fchmod.test \
 	fcntl.test \
diff --git a/tests/faccessat.c b/tests/faccessat.c
new file mode 100644
index 0000000..abf569f
--- /dev/null
+++ b/tests/faccessat.c
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_faccessat
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+# define TMP_FILE "faccessat_tmpfile"
+
+int
+main(void)
+{
+	const long int fd = (long int) 0xdeadbeefffffffff;
+	int rc = syscall(__NR_faccessat, fd, TMP_FILE, F_OK);
+	printf("faccessat(%d, \"%s\", F_OK) = %d %s (%m)\n",
+	       (int) fd, TMP_FILE, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_faccessat")
+
+#endif
diff --git a/tests/faccessat.test b/tests/faccessat.test
new file mode 100755
index 0000000..260497f
--- /dev/null
+++ b/tests/faccessat.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check faccessat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -efaccessat $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list