[PATCH 1/2] tests: add mount.test

Fei Jie feij.fnst at cn.fujitsu.com
Thu May 19 07:58:36 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 26c18ec..dad488d 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -125,6 +125,7 @@ mlockall
 mmap
 mmap64
 mmsg
+mount
 move_pages
 mq
 munlockall
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 64c1879..ed0bf28 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -178,6 +178,7 @@ check_PROGRAMS = \
 	mmap \
 	mmap64 \
 	mmsg \
+	mount \
 	move_pages \
 	mq \
 	munlockall \
@@ -464,6 +465,7 @@ DECODER_TESTS = \
 	mmap.test \
 	mmap64.test \
 	mmsg.test \
+	mount.test \
 	move_pages.test \
 	mq.test \
 	munlockall.test \
diff --git a/tests/mount.c b/tests/mount.c
new file mode 100644
index 0000000..c6e4a36
--- /dev/null
+++ b/tests/mount.c
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_mount
+
+# include <sys/mount.h>
+# include <stdio.h>
+# include <unistd.h>
+
+# define MS_INVAL (1 << 26)
+
+int
+main(void)
+{
+	static const char source[] = "mount_source";
+	static const char target[] = "mount_target";
+	long rc = syscall(__NR_mount, source, target, "ext2", MS_INVAL, NULL);
+	printf("mount(\"%s\", \"%s\", \"ext2\", %#x /* MS_??? */, NULL)"
+	       " = %ld %s (%m)\n", source, target, MS_INVAL, rc, errno2name());
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_mount")
+
+#endif
diff --git a/tests/mount.test b/tests/mount.test
new file mode 100755
index 0000000..f3c4fe6
--- /dev/null
+++ b/tests/mount.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check mount syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff
-- 
1.8.3.1







More information about the Strace-devel mailing list