From: Dmitry V. Levin Date: Fri, 1 Jun 2018 01:46:06 +0000 (+0000) Subject: tests: extend struct flock/flock64 decoding checks X-Git-Tag: v4.23~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbbe61067c68968502564103f39d9d5b171d7f48;p=strace tests: extend struct flock/flock64 decoding checks * 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. --- diff --git a/tests/fcntl-common.c b/tests/fcntl-common.c index 4e164bdd..92bf56c6 100644 --- a/tests/fcntl-common.c +++ b/tests/fcntl-common.c @@ -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); } diff --git a/tests/fcntl64.c b/tests/fcntl64.c index ac5a2179..965ba0a9 100644 --- a/tests/fcntl64.c +++ b/tests/fcntl64.c @@ -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); }