]> granicus.if.org Git - strace/commitdiff
tests: add fsync.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Thu, 31 Mar 2016 08:06:50 +0000 (16:06 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Apr 2016 23:34:33 +0000 (23:34 +0000)
* 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
tests/Makefile.am
tests/fsync.c [new file with mode: 0644]
tests/fsync.test [new file with mode: 0755]

index b709f4999774efe00609f33b6599810162dfb895..68236a8bf0ba67f43d3a31e13ab1b2fbf7894c8d 100644 (file)
@@ -42,6 +42,7 @@ fork-f
 fstat
 fstat64
 fstatat64
+fsync
 ftruncate
 ftruncate64
 getcwd
index 98be3a49d5ac3fd5d5e31705a4ee6f931a1b7c14..4d18fe6ebc20903edcdbc38ab972de578cefb2b8 100644 (file)
@@ -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 (file)
index 0000000..774420e
--- /dev/null
@@ -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 (executable)
index 0000000..a58b67b
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check fsync syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a10