]> granicus.if.org Git - strace/commitdiff
tests/umount.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 4 Jan 2016 23:47:59 +0000 (23:47 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 00:14:36 +0000 (00:14 +0000)
* tests/umount.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_fail.

tests/umount.c

index 612767fd61249b89712e5ea27abd4a7c2899972e..9ad88284b5638d4ee7e9c2d101572558ef5022a7 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
@@ -25,6 +25,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "tests.h"
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
 # endif
 #endif
 
+#ifdef __NR_oldumount
+
 int
 main(void)
 {
-#ifdef __NR_oldumount
        static const char sample[] = "umount.sample";
-       if (mkdir(sample, 0700)) {
-               perror(sample);
-               return 77;
-       }
+       const char *errno_text;
+       if (mkdir(sample, 0700))
+               perror_msg_and_fail("mkdir: %s", sample);
        (void) syscall(__NR_oldumount, sample);
-       printf("%s(\"%s\") = -1 ", TEST_SYSCALL_STR, sample);
        switch (errno) {
                case ENOSYS:
-                       printf("ENOSYS (%m)\n");
+                       errno_text = "ENOSYS";
                        break;
                case EPERM:
-                       printf("EPERM (%m)\n");
+                       errno_text = "EPERM";
                        break;
                default:
-                       printf("EINVAL (%m)\n");
+                       errno_text = "EINVAL";
        }
-       (void) rmdir(sample);
+       printf("%s(\"%s\") = -1 %s (%m)\n",
+              TEST_SYSCALL_STR, sample, errno_text);
+       if (rmdir(sample))
+               perror_msg_and_fail("rmdir: %s", sample);
        puts("+++ exited with 0 +++");
        return 0;
+}
+
 #else
-       return 77;
+
+SKIP_MAIN_UNDEFINED("__NR_oldumount")
+
 #endif
-}