[PATCH 2/3] tests: add getcwd.test
Fei Jie
feij.fnst at cn.fujitsu.com
Tue Mar 15 08:38:35 UTC 2016
* tests/getcwd.c: New file.
* tests/getcwd.test: New test.
* tests/.gitignore: Add getcwd.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add getcwd.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/getcwd.c | 26 ++++++++++++++++++++++++++
tests/getcwd.test | 11 +++++++++++
4 files changed, 40 insertions(+)
create mode 100644 tests/getcwd.c
create mode 100755 tests/getcwd.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 6059af9..8312930 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -42,6 +42,7 @@ fstat64
fstatat64
ftruncate
ftruncate64
+getcwd
getdents
getdents64
getrandom
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6d1c771..2a2f3a3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -92,6 +92,7 @@ check_PROGRAMS = \
fstatat64 \
ftruncate \
ftruncate64 \
+ getcwd \
getdents \
getdents64 \
getrandom \
@@ -266,6 +267,7 @@ TESTS = \
fstatat64.test \
ftruncate.test \
ftruncate64.test \
+ getcwd.test \
getdents.test \
getdents64.test \
getrandom.test \
diff --git a/tests/getcwd.c b/tests/getcwd.c
new file mode 100644
index 0000000..7683d27
--- /dev/null
+++ b/tests/getcwd.c
@@ -0,0 +1,26 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_getcwd
+
+# include <stdio.h>
+# include <unistd.h>
+
+static char buf[8192];
+
+int
+main(void)
+{
+ int rc = syscall(__NR_getcwd, buf, 8192);
+ printf("getcwd(\"%s\", 8192) = %d\n",
+ buf, rc);
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_getcwd")
+
+#endif
diff --git a/tests/getcwd.test b/tests/getcwd.test
new file mode 100755
index 0000000..48e7a91
--- /dev/null
+++ b/tests/getcwd.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check getcwd syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -egetcwd -a23 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
--
1.8.3.1
More information about the Strace-devel
mailing list