From: Dmitry V. Levin Date: Fri, 1 Jun 2018 01:46:06 +0000 (+0000) Subject: tests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c X-Git-Tag: v4.23~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c7052f4031fefc1a4f2c8f38c75da60f525eec2;p=strace tests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c This change enables F_OFD_SETLK* tests for fcntl as well. * tests/fcntl64.c (test_flock64): Rename to test_flock64_lk64. [F_OFD_SETLK]: Remove. (test_flock64_einval): Move ... * tests/fcntl-common.c: ... here. (test_flock64_lk64): New protype. (test_flock64_einval, test_flock64): New functions. * tests/fcntl.c (test_flock64_einval): Rename to test_flock64_undecoded. (TEST_FLOCK64_UNDECODED): New macro. (test_flock64): Rename to test_flock64_lk64, replace TEST_FLOCK64_EINVAL with TEST_FLOCK64_UNDECODED. --- diff --git a/tests/fcntl-common.c b/tests/fcntl-common.c index b8623002..d5cb1028 100644 --- a/tests/fcntl-common.c +++ b/tests/fcntl-common.c @@ -66,6 +66,24 @@ test_flock_einval(const int cmd, const char *name) (intmax_t) fl.l_start, (intmax_t) fl.l_len, sprintrc(rc)); } +/* + * This function is not declared static to avoid potential + * "defined but not used" warning when included by fcntl.c + */ +void +test_flock64_einval(const int cmd, const char *name) +{ + struct_kernel_flock64 fl = { + .l_type = F_RDLCK, + .l_start = 0xdefaced1facefeedULL, + .l_len = 0xdefaced2cafef00dULL + }; + long rc = invoke_test_syscall(cmd, &fl); + printf("%s(0, %s, {l_type=F_RDLCK, l_whence=SEEK_SET" + ", l_start=%jd, l_len=%jd}) = %s\n", TEST_SYSCALL_STR, name, + (intmax_t) fl.l_start, (intmax_t) fl.l_len, sprintrc(rc)); +} + static void test_flock(void) { @@ -94,7 +112,18 @@ test_flock(void) TEST_SYSCALL_STR, FILE_LEN); } -static void test_flock64(void); +static void test_flock64_lk64(void); + +static void +test_flock64(void) +{ +# ifdef F_OFD_SETLK + TEST_FLOCK64_EINVAL(F_OFD_SETLK); + TEST_FLOCK64_EINVAL(F_OFD_SETLKW); +# endif + + test_flock64_lk64(); +} /* * F_[GS]ETOWN_EX had conflicting values with F_[SG]ETLK64 diff --git a/tests/fcntl.c b/tests/fcntl.c index 9f39a8ff..ac4ca19e 100644 --- a/tests/fcntl.c +++ b/tests/fcntl.c @@ -36,7 +36,7 @@ # include "fcntl-common.c" static void -test_flock64_einval(const int cmd, const char *name) +test_flock64_undecoded(const int cmd, const char *name) { struct_kernel_flock64 fl = { .l_type = F_RDLCK, @@ -48,22 +48,24 @@ test_flock64_einval(const int cmd, const char *name) TEST_SYSCALL_STR, name, &fl, sprintrc(rc)); } +#define TEST_FLOCK64_UNDECODED(cmd) test_flock64_undecoded(cmd, #cmd) + static void -test_flock64(void) +test_flock64_lk64(void) { /* * F_[GS]ETOWN_EX had conflicting values with F_[GS]ETLK64 * in kernel revisions v2.6.32-rc1~96..v2.6.32-rc7~23. */ # if !defined(F_GETOWN_EX) || F_GETOWN_EX != F_SETLK64 - TEST_FLOCK64_EINVAL(F_SETLK64); + TEST_FLOCK64_UNDECODED(F_SETLK64); # endif /* F_GETLK and F_SETLKW64 have conflicting values on mips64 */ # if !defined(__mips64) || F_GETLK != F_SETLKW64 - TEST_FLOCK64_EINVAL(F_SETLKW64); + TEST_FLOCK64_UNDECODED(F_SETLKW64); # endif # if !defined(F_SETOWN_EX) || F_SETOWN_EX != F_GETLK64 - TEST_FLOCK64_EINVAL(F_GETLK64); + TEST_FLOCK64_UNDECODED(F_GETLK64); # endif } diff --git a/tests/fcntl64.c b/tests/fcntl64.c index 34cee7b3..b48b6a34 100644 --- a/tests/fcntl64.c +++ b/tests/fcntl64.c @@ -36,28 +36,10 @@ # include "fcntl-common.c" static void -test_flock64_einval(const int cmd, const char *name) -{ - struct_kernel_flock64 fl = { - .l_type = F_RDLCK, - .l_start = 0xdefaced1facefeedULL, - .l_len = 0xdefaced2cafef00dULL - }; - long rc = invoke_test_syscall(cmd, &fl); - printf("%s(0, %s, {l_type=F_RDLCK, l_whence=SEEK_SET" - ", l_start=%jd, l_len=%jd}) = %s\n", TEST_SYSCALL_STR, name, - (intmax_t) fl.l_start, (intmax_t) fl.l_len, sprintrc(rc)); -} - -static void -test_flock64(void) +test_flock64_lk64(void) { TEST_FLOCK64_EINVAL(F_SETLK64); TEST_FLOCK64_EINVAL(F_SETLKW64); -# ifdef F_OFD_SETLK - TEST_FLOCK64_EINVAL(F_OFD_SETLK); - TEST_FLOCK64_EINVAL(F_OFD_SETLKW); -# endif struct_kernel_flock64 fl = { .l_type = F_RDLCK,