From: Fei Jie Date: Tue, 15 Mar 2016 08:38:34 +0000 (+0800) Subject: tests: add flock.test X-Git-Tag: v4.12~510 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b824f9872b37a124eececf5ec56973c30ef1a70a;p=strace tests: add flock.test * tests/flock.c: New file. * tests/flock.test: New test. * tests/.gitignore: Add flock. * tests/Makefile.am (check_PROGRAMS): Likewise. (TESTS): Add flock.test. --- diff --git a/tests/.gitignore b/tests/.gitignore index ecbb17ea..93ffa0b0 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 2a8b147b..6590f95e 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 \ @@ -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 index 00000000..cd25185c --- /dev/null +++ b/tests/flock.c @@ -0,0 +1,28 @@ +#include "tests.h" +#include + +#ifdef __NR_flock + +# include +# include +# include +# include + +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 00000000..771af7d0 --- /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"