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

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


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 42d8ad1..63a3d1e 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -20,6 +20,7 @@ clock_nanosleep
 clock_xettime
 copy_file_range
 count-f
+creat
 dup
 dup2
 dup3
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5c07692..679fb90 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -71,6 +71,7 @@ check_PROGRAMS = \
 	clock_xettime \
 	copy_file_range \
 	count-f \
+	creat \
 	dup \
 	dup2 \
 	dup3 \
@@ -242,6 +243,7 @@ DECODER_TESTS = \
 	clock_nanosleep.test \
 	clock_xettime.test \
 	copy_file_range.test \
+	creat.test \
 	dup.test \
 	dup2.test \
 	dup3.test \
diff --git a/tests/creat.c b/tests/creat.c
new file mode 100644
index 0000000..d922dd7
--- /dev/null
+++ b/tests/creat.c
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_creat
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/stat.h>
+# include <unistd.h>
+
+# define TMP_FILE "creat"
+
+int
+main(void)
+{
+	int rc = syscall(__NR_creat, TMP_FILE, S_IRUSR);
+	printf("creat(\"%s\", %#o) = %d %s (%m)\n",
+	       TMP_FILE, S_IRUSR, rc,
+	       errno == ENOSYS ? "ENOSYS" : "ETXTBSY");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_creat")
+
+#endif
diff --git a/tests/creat.test b/tests/creat.test
new file mode 100755
index 0000000..a692e19
--- /dev/null
+++ b/tests/creat.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check creat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -ecreat -a21 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list