]> granicus.if.org Git - strace/commitdiff
tests/struct_flock.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 16:03:23 +0000 (16:03 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 16:06:35 +0000 (16:06 +0000)
* 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.

tests/fcntl.c
tests/fcntl64.c
tests/struct_flock.c

index 64e7c9ee62143581d8369d1e16e496bea4e7929c..a55703c519561e15e6d4f6b64e834074904cfa17 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * 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
index 427630b60f45ca9bb50be1bd5d40de4f1416c20f..960c4dca03dabf4014f8ca20f3801e72c4c846c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * 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
index 7ab07ed8fa5af5fe4c3c4a6c78bf41329201eb6a..0acba90c65e906afb79a53e3ac89816d6fb1848c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * 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");
 }