]> granicus.if.org Git - strace/commitdiff
tests: extend struct flock/flock64 decoding checks
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)
* tests/fcntl-common.c (test_flock_einval, test_flock): Create
struct_kernel_flock object using tail_alloc.
(test_flock64_einval): Create struct_kernel_flock64 object using
tail_alloc.
* tests/fcntl64.c (test_flock64_lk64): Likewise.

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

index 4e164bdd7d6ec108fd8058f6c3ba2df443f99496..92bf56c66c448c99e2aa8b2e2ed67ed0acada5bb 100644 (file)
@@ -60,15 +60,16 @@ invoke_test_syscall(const unsigned int fd, const unsigned int cmd, void *const p
 static void
 test_flock_einval(const int cmd, const char *name)
 {
-       struct_kernel_flock fl = {
-               .l_type = F_RDLCK,
-               .l_start = (TYPEOF_FLOCK_OFF_T) 0xdefaced1facefeedULL,
-               .l_len = (TYPEOF_FLOCK_OFF_T) 0xdefaced2cafef00dULL
-       };
-       invoke_test_syscall(0, cmd, &fl);
+       TAIL_ALLOC_OBJECT_CONST_PTR(struct_kernel_flock, fl);
+       memset(fl, 0, sizeof(*fl));
+       fl->l_type = F_RDLCK;
+       fl->l_start = (TYPEOF_FLOCK_OFF_T) 0xdefaced1facefeedULL;
+       fl->l_len = (TYPEOF_FLOCK_OFF_T) 0xdefaced2cafef00dULL;
+
+       invoke_test_syscall(0, 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, errstr);
+              (intmax_t) fl->l_start, (intmax_t) fl->l_len, errstr);
 }
 
 /*
@@ -78,15 +79,16 @@ test_flock_einval(const int cmd, const char *name)
 void
 test_flock64_einval(const int cmd, const char *name)
 {
-       struct_kernel_flock64 fl = {
-               .l_type = F_RDLCK,
-               .l_start = 0xdefaced1facefeedULL,
-               .l_len = 0xdefaced2cafef00dULL
-       };
-       invoke_test_syscall(0, cmd, &fl);
+       TAIL_ALLOC_OBJECT_CONST_PTR(struct_kernel_flock64, fl);
+       memset(fl, 0, sizeof(*fl));
+       fl->l_type = F_RDLCK;
+       fl->l_start = (TYPEOF_FLOCK_OFF_T) 0xdefaced1facefeedULL;
+       fl->l_len = (TYPEOF_FLOCK_OFF_T) 0xdefaced2cafef00dULL;
+
+       invoke_test_syscall(0, 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, errstr);
+              (intmax_t) fl->l_start, (intmax_t) fl->l_len, errstr);
 }
 
 static void
@@ -95,24 +97,25 @@ test_flock(void)
        TEST_FLOCK_EINVAL(F_SETLK);
        TEST_FLOCK_EINVAL(F_SETLKW);
 
-       struct_kernel_flock fl = {
-               .l_type = F_RDLCK,
-               .l_len = FILE_LEN
-       };
-       long rc = invoke_test_syscall(0, F_SETLK, &fl);
+       TAIL_ALLOC_OBJECT_CONST_PTR(struct_kernel_flock, fl);
+       memset(fl, 0, sizeof(*fl));
+       fl->l_type = F_RDLCK;
+       fl->l_len = FILE_LEN;
+
+       long rc = invoke_test_syscall(0, F_SETLK, fl);
        printf("%s(0, F_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_GETLK, &fl);
+       invoke_test_syscall(0, F_GETLK, fl);
        printf("%s(0, F_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_SETLK, &fl);
-       printf("%s(0, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET"
+       invoke_test_syscall(0, F_SETLKW, fl);
+       printf("%s(0, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET"
               ", l_start=0, l_len=%d}) = 0\n",
               TEST_SYSCALL_STR, FILE_LEN);
 }
index ac5a217998918c2b288197f5eca4ce60bbd28a55..965ba0a9c5413ec6fddb48285b25791cc47d560a 100644 (file)
@@ -41,11 +41,12 @@ test_flock64_lk64(void)
        TEST_FLOCK64_EINVAL(F_SETLK64);
        TEST_FLOCK64_EINVAL(F_SETLKW64);
 
-       struct_kernel_flock64 fl = {
-               .l_type = F_RDLCK,
-               .l_len = FILE_LEN
-       };
-       long rc = invoke_test_syscall(0, F_SETLK64, &fl);
+       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_SETLK64, fl);
        printf("%s(0, F_SETLK64, {l_type=F_RDLCK, l_whence=SEEK_SET"
               ", l_start=0, l_len=%d}) = %s\n",
               TEST_SYSCALL_STR, FILE_LEN, errstr);
@@ -53,13 +54,13 @@ test_flock64_lk64(void)
        if (rc)
                return;
 
-       invoke_test_syscall(0, F_GETLK64, &fl);
+       invoke_test_syscall(0, F_GETLK64, fl);
        printf("%s(0, F_GETLK64, {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_SETLK64, &fl);
-       printf("%s(0, F_SETLK64, {l_type=F_UNLCK, l_whence=SEEK_SET"
+       invoke_test_syscall(0, F_SETLKW64, fl);
+       printf("%s(0, F_SETLKW64, {l_type=F_UNLCK, l_whence=SEEK_SET"
               ", l_start=0, l_len=%d}) = 0\n",
               TEST_SYSCALL_STR, FILE_LEN);
 }