From d476d264def4a433e0130a3e66053badaa08bf9f Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 1 Jun 2018 01:46:06 +0000 Subject: [PATCH] tests: extend F_OFD_* decoding checks Check that non-faulty F_OFD_* fcntl operations are decoded properly. * tests/fcntl-common.c: Include . (test_flock64_ofd): New function. (test_flock64): Invoke it, remove [F_OFD_SETLK]. --- tests/fcntl-common.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tests/fcntl-common.c b/tests/fcntl-common.c index ebe27a70..4e164bdd 100644 --- a/tests/fcntl-common.c +++ b/tests/fcntl-common.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "flock.h" @@ -116,16 +117,43 @@ test_flock(void) TEST_SYSCALL_STR, FILE_LEN); } -static void test_flock64_lk64(void); - static void -test_flock64(void) +test_flock64_ofd(void) { -# ifdef F_OFD_SETLK +#if defined F_OFD_GETLK && defined F_OFD_SETLK && defined F_OFD_SETLKW TEST_FLOCK64_EINVAL(F_OFD_SETLK); TEST_FLOCK64_EINVAL(F_OFD_SETLKW); -# endif + TAIL_ALLOC_OBJECT_CONST_PTR(struct_kernel_flock64, fl); + memset(fl, 0, sizeof(*fl)); + fl->l_type = F_RDLCK; + fl->l_len = FILE_LEN; + + long rc = invoke_test_syscall(0, F_OFD_SETLK, fl); + printf("%s(0, F_OFD_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET" + ", l_start=0, l_len=%d}) = %s\n", + TEST_SYSCALL_STR, FILE_LEN, errstr); + if (rc) + return; + + invoke_test_syscall(0, F_OFD_GETLK, fl); + printf("%s(0, F_OFD_GETLK, {l_type=F_UNLCK, l_whence=SEEK_SET" + ", l_start=0, l_len=%d, l_pid=0}) = 0\n", + TEST_SYSCALL_STR, FILE_LEN); + + invoke_test_syscall(0, F_OFD_SETLKW, fl); + printf("%s(0, F_OFD_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET" + ", l_start=0, l_len=%d}) = 0\n", + TEST_SYSCALL_STR, FILE_LEN); +#endif /* F_OFD_GETLK && F_OFD_SETLK && F_OFD_SETLKW */ +} + +static void test_flock64_lk64(void); + +static void +test_flock64(void) +{ + test_flock64_ofd(); test_flock64_lk64(); } -- 2.49.0