From: Dmitry V. Levin Date: Wed, 6 Jan 2016 16:03:23 +0000 (+0000) Subject: tests/struct_flock.c: use libtests X-Git-Tag: v4.12~679 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e65922a32161fdd56ef6cdfabdfab611f980611;p=strace tests/struct_flock.c: use libtests * tests/struct_flock.c (create_sample): Return void, all callers changed. Use perror_msg_and_fail. * tests/fcntl.c: Use SKIP_MAIN_UNDEFINED. * tests/fcntl64.c: Likewise. --- diff --git a/tests/fcntl.c b/tests/fcntl.c index 64e7c9ee..a55703c5 100644 --- a/tests/fcntl.c +++ b/tests/fcntl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ # define TEST_SYSCALL_NAME fcntl # include "struct_flock.c" -#define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd) +# define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd) static void test_flock64_einval(const int cmd, const char *name) @@ -67,9 +67,7 @@ test_flock64(void) int main(void) { - if (create_sample()) - return 77; - + create_sample(); test_flock(); test_flock64(); @@ -79,10 +77,6 @@ main(void) #else -int -main(void) -{ - return 77; -} +SKIP_MAIN_UNDEFINED("__NR_fcntl") #endif diff --git a/tests/fcntl64.c b/tests/fcntl64.c index 427630b6..960c4dca 100644 --- a/tests/fcntl64.c +++ b/tests/fcntl64.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ # define TEST_SYSCALL_NAME fcntl64 # include "struct_flock.c" -#define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd) +# define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd) static void test_flock64_einval(const int cmd, const char *name) @@ -54,10 +54,10 @@ test_flock64(void) { TEST_FLOCK64_EINVAL(F_SETLK64); TEST_FLOCK64_EINVAL(F_SETLKW64); -#ifdef F_OFD_SETLK +# ifdef F_OFD_SETLK TEST_FLOCK64_EINVAL(F_OFD_SETLK); TEST_FLOCK64_EINVAL(F_OFD_SETLKW); -#endif +# endif struct_kernel_flock64 fl = { .l_type = F_RDLCK, @@ -85,9 +85,7 @@ test_flock64(void) int main(void) { - if (create_sample()) - return 77; - + create_sample(); test_flock(); test_flock64(); @@ -97,10 +95,6 @@ main(void) #else -int -main(void) -{ - return 77; -} +SKIP_MAIN_UNDEFINED("__NR_fcntl64") #endif diff --git a/tests/struct_flock.c b/tests/struct_flock.c index 7ab07ed8..0acba90c 100644 --- a/tests/struct_flock.c +++ b/tests/struct_flock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Dmitry V. Levin + * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,11 +87,16 @@ test_flock(void) TEST_SYSCALL_STR, FILE_LEN); } -static int +static void create_sample(void) { char fname[] = TEST_SYSCALL_STR "_XXXXXX"; (void) close(0); - return mkstemp(fname) || unlink(fname) || ftruncate(0, FILE_LEN) ? 77 : 0; + if (mkstemp(fname)) + perror_msg_and_fail("mkstemp: %s", fname); + if (unlink(fname)) + perror_msg_and_fail("unlink: %s", fname); + if (ftruncate(0, FILE_LEN)) + perror_msg_and_fail("ftruncate"); }