[PATCH 1/3] tests: add flock.test
Fei Jie
feij.fnst at cn.fujitsu.com
Tue Mar 15 08:38:34 UTC 2016
* tests/flock.c: New file.
* tests/flock.test: New test.
* tests/.gitignore: Add flock.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add flock.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/flock.c | 28 ++++++++++++++++++++++++++++
tests/flock.test | 11 +++++++++++
4 files changed, 42 insertions(+)
create mode 100644 tests/flock.c
create mode 100755 tests/flock.test
diff --git a/tests/.gitignore b/tests/.gitignore
index b89796a..6059af9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -35,6 +35,7 @@ fcntl
fcntl64
file_handle
filter-unavailable
+flock
fork-f
fstat
fstat64
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 59e7e78..6d1c771 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -85,6 +85,7 @@ check_PROGRAMS = \
fcntl64 \
file_handle \
filter-unavailable \
+ flock \
fork-f \
fstat \
fstat64 \
@@ -258,6 +259,7 @@ TESTS = \
fcntl64.test \
file_handle.test \
filter-unavailable.test \
+ flock.test \
fork-f.test \
fstat.test \
fstat64.test \
diff --git a/tests/flock.c b/tests/flock.c
new file mode 100644
index 0000000..cd25185
--- /dev/null
+++ b/tests/flock.c
@@ -0,0 +1,28 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_flock
+
+# include <errno.h>
+# include <sys/file.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+ const unsigned long fd = (long int) 0xdeadbeefffffffff;
+ int rc = syscall(__NR_flock, fd, LOCK_SH);
+ printf("flock(%d, LOCK_SH) = %d %s (%m)\n",
+ (int) fd, rc,
+ errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_flock")
+
+#endif
diff --git a/tests/flock.test b/tests/flock.test
new file mode 100755
index 0000000..771af7d
--- /dev/null
+++ b/tests/flock.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check flock syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -eflock -a19 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
--
1.8.3.1
More information about the Strace-devel
mailing list