[PATCH v2 1/2] tests: add getcwd.test

Fei Jie feij.fnst at cn.fujitsu.com
Thu Mar 17 09:32:11 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 93ffa0b..d5c4a2c 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 6590f95..c6c293e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -92,6 +92,7 @@ check_PROGRAMS = \
 	fstatat64 \
 	ftruncate \
 	ftruncate64 \
+	getcwd \
 	getdents \
 	getdents64 \
 	getrandom \
@@ -267,6 +268,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..ae93307
--- /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, sizeof(buf));
+	printf("getcwd(\"%s\", %u) = %d\n",
+	       buf, (unsigned) sizeof(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..12f77ed
--- /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 -a18 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list