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

Fei Jie feij.fnst at cn.fujitsu.com
Thu Mar 31 08:06:50 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index b709f49..68236a8 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -42,6 +42,7 @@ fork-f
 fstat
 fstat64
 fstatat64
+fsync
 ftruncate
 ftruncate64
 getcwd
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 98be3a4..4d18fe6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -93,6 +93,7 @@ check_PROGRAMS = \
 	fstat \
 	fstat64 \
 	fstatat64 \
+	fsync \
 	ftruncate \
 	ftruncate64 \
 	getcwd \
@@ -276,6 +277,7 @@ DECODER_TESTS = \
 	fstat.test \
 	fstat64.test \
 	fstatat64.test \
+	fsync.test \
 	ftruncate.test \
 	ftruncate64.test \
 	getcwd.test \
diff --git a/tests/fsync.c b/tests/fsync.c
new file mode 100644
index 0000000..774420e
--- /dev/null
+++ b/tests/fsync.c
@@ -0,0 +1,27 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_fsync
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	const long int fd = (long int) 0xdeadbeefffffffff;
+	int rc = syscall(__NR_fsync, fd);
+	printf("fsync(%d) = %d %s (%m)\n",
+	       (int) fd, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_fsync")
+
+#endif
diff --git a/tests/fsync.test b/tests/fsync.test
new file mode 100755
index 0000000..a58b67b
--- /dev/null
+++ b/tests/fsync.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check fsync syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a10
-- 
1.8.3.1







More information about the Strace-devel mailing list