[PATCH 1/4] tests: add mkdir.test

Fei Jie feij.fnst at cn.fujitsu.com
Thu Apr 21 07:53:49 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 2f5f95e..fbced77 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -98,6 +98,7 @@ lstat64
 membarrier
 memfd_create
 mincore
+mkdir
 mkdirat
 mknod
 mlock2
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 295d221..ad9cddd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -148,6 +148,7 @@ check_PROGRAMS = \
 	membarrier \
 	memfd_create \
 	mincore \
+	mkdir \
 	mkdirat \
 	mknod \
 	mlock2 \
@@ -392,6 +393,7 @@ DECODER_TESTS = \
 	membarrier.test \
 	memfd_create.test \
 	mincore.test \
+	mkdir.test \
 	mkdirat.test \
 	mknod.test \
 	mlock2.test \
diff --git a/tests/mkdir.c b/tests/mkdir.c
new file mode 100644
index 0000000..9d8f99d
--- /dev/null
+++ b/tests/mkdir.c
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_mkdir
+
+# include <errno.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	static const char sample[] = "mkdir";
+	int rc = syscall(__NR_mkdir, sample, 0600);
+	printf("mkdir(\"%s\", 0600) = %d %s (%m)\n",
+	       sample, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EEXIST");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_mkdir")
+
+#endif
diff --git a/tests/mkdir.test b/tests/mkdir.test
new file mode 100755
index 0000000..98d5a52
--- /dev/null
+++ b/tests/mkdir.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check mkdir syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a21
-- 
1.8.3.1







More information about the Strace-devel mailing list