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

index ecbb17ea8f5593066657c2262d67f87959ecb095..93ffa0b01f9d2fb43657e1f1d732fbeeac75ff92 100644 (file)
@@ -35,6 +35,7 @@ fcntl
 fcntl64
 file_handle
 filter-unavailable
+flock
 fork-f
 fstat
 fstat64
index 2a8b147b8adc2328035005f5044d1986715f47a3..6590f95e70085e26c332ac34babfb1dab0f85d0a 100644 (file)
@@ -85,6 +85,7 @@ check_PROGRAMS = \
        fcntl64 \
        file_handle \
        filter-unavailable \
+       flock \
        fork-f \
        fstat \
        fstat64 \
@@ -259,6 +260,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 (file)
index 0000000..cd25185
--- /dev/null
@@ -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 (executable)
index 0000000..771af7d
--- /dev/null
@@ -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"