[PATCH 3/4] tests: add access.test
Fei Jie
feij.fnst at cn.fujitsu.com
Thu Apr 21 07:53:51 UTC 2016
* tests/access.c: New file.
* tests/access.test: New test.
* tests/.gitignore: Add access.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add access.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/access.c | 31 +++++++++++++++++++++++++++++++
tests/access.test | 15 +++++++++++++++
4 files changed, 49 insertions(+)
create mode 100644 tests/access.c
create mode 100755 tests/access.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 7e67427..5bb24a5 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -6,6 +6,7 @@
*.tmp.*
*.trs
_newselect
+access
acct
adjtimex
aio
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc05d98..ceea3ae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ LDADD = libtests.a
check_PROGRAMS = \
_newselect \
+ access \
acct \
adjtimex \
aio \
@@ -311,6 +312,7 @@ endif
DECODER_TESTS = \
_newselect.test \
+ access.test \
acct.test \
adjtimex.test \
aio.test \
diff --git a/tests/access.c b/tests/access.c
new file mode 100644
index 0000000..2763710
--- /dev/null
+++ b/tests/access.c
@@ -0,0 +1,31 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_access
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+ static const char sample[] = "access_sample";
+ int rc = syscall(__NR_access, sample, F_OK);
+ printf("access(\"%s\", F_OK) = %d %s (%m)\n",
+ sample, rc,
+ errno == ENOSYS ? "ENOSYS" : "ENOENT");
+
+ rc = syscall(__NR_access, sample, R_OK|W_OK|X_OK);
+ printf("access(\"%s\", R_OK|W_OK|X_OK) = %d %s (%m)\n",
+ sample, rc,
+ errno == ENOSYS ? "ENOSYS" : "ENOENT");
+
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_access")
+
+#endif
diff --git a/tests/access.test b/tests/access.test
new file mode 100755
index 0000000..272f17c
--- /dev/null
+++ b/tests/access.test
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Check access syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+check_prog grep
+run_prog > /dev/null
+run_strace -eaccess -a30 $args > "$EXP"
+
+# Filter out access() call made by strace.
+grep -F access_sample < "$LOG" > "$OUT"
+match_diff "$OUT" "$EXP"
+
+rm -f "$EXP" "$OUT"
--
1.8.3.1
More information about the Strace-devel
mailing list