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

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


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

diff --git a/tests/.gitignore b/tests/.gitignore
index d1fb6d4..42d8ad1 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -65,6 +65,7 @@ lstat64
 membarrier
 memfd_create
 mincore
+mknod
 mlock2
 mmap
 mmap64
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a08025c..5c07692 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -114,6 +114,7 @@ check_PROGRAMS = \
 	membarrier \
 	memfd_create \
 	mincore \
+	mknod \
 	mlock2 \
 	mmap \
 	mmap64 \
@@ -281,6 +282,7 @@ DECODER_TESTS = \
 	membarrier.test \
 	memfd_create.test \
 	mincore.test \
+	mknod.test \
 	mlock2.test \
 	mmap.test \
 	mmap64.test \
diff --git a/tests/mknod.c b/tests/mknod.c
new file mode 100644
index 0000000..7e80582
--- /dev/null
+++ b/tests/mknod.c
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_mknod
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/stat.h>
+# include <unistd.h>
+
+# define TMP_FILE "mknod"
+
+int
+main(void)
+{
+	int rc = syscall(__NR_mknod, TMP_FILE, S_IFREG|0600, 0);
+	printf("mknod(\"%s\", S_IFREG|0600) = %d %s (%m)\n",
+	       TMP_FILE, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EEXIST");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_mknod")
+
+#endif
diff --git a/tests/mknod.test b/tests/mknod.test
new file mode 100755
index 0000000..a780353
--- /dev/null
+++ b/tests/mknod.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check mknod syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -emknod -a29 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list