]> granicus.if.org Git - strace/commitdiff
tests: move F_OFD_SETLK* checks from fcntl64.c to fcntl-common.c
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Jun 2018 01:46:06 +0000 (01:46 +0000)
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.

tests/fcntl-common.c
tests/fcntl.c
tests/fcntl64.c

index b86230026ca3340260fe9b229589e4e115436555..d5cb102832dddc73629e5a00bf3521c227b9e2de 100644 (file)
@@ -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
index 9f39a8ff76ae73dff422cef327e68217ed05c4c7..ac4ca19e713add62571e0ca3c8ab4c694aa0d659 100644 (file)
@@ -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
 }
 
index 34cee7b3e7f46662386f89f84e871a60cf7ee424..b48b6a3455ae8ac47dfe573b4415358c0fc9057e 100644 (file)
 # 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,