]> granicus.if.org Git - strace/commitdiff
tests/getrandom.c: use libtests
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 11:36:54 +0000 (11:36 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jan 2016 11:36:54 +0000 (11:36 +0000)
* tests/getrandom.c: Use SKIP_MAIN_UNDEFINED.
(main): Use perror_msg_and_skip.

tests/getrandom.c

index 4f1406790e7ba71a6c554e2b9bdbea6d83917a10..4c17c293afcd87fd23343a95a3fad96ef07088a0 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
  */
 
 #include "tests.h"
-#include <stdio.h>
-#include <unistd.h>
 #include <sys/syscall.h>
 
+#ifdef __NR_getrandom
+
+# include <stdio.h>
+# include <unistd.h>
+
 int
 main(void)
 {
-#ifdef __NR_getrandom
        unsigned char buf[4];
 
        if (syscall(__NR_getrandom, buf, sizeof(buf) - 1, 0) != sizeof(buf) - 1)
-               return 77;
+               perror_msg_and_skip("getrandom");
        printf("getrandom(\"\\x%02x\\x%02x\\x%02x\", 3, 0) = 3\n",
               (int) buf[0], (int) buf[1], (int) buf[2]);
 
        if (syscall(__NR_getrandom, buf, sizeof(buf), 1) != sizeof(buf))
-               return 77;
+               perror_msg_and_skip("getrandom");
        printf("getrandom(\"\\x%02x\\x%02x\\x%02x\"..., 4, GRND_NONBLOCK) = 4\n",
               (int) buf[0], (int) buf[1], (int) buf[2]);
 
        if (syscall(__NR_getrandom, buf, sizeof(buf), 0x3003) != -1)
-               return 77;
+               perror_msg_and_skip("getrandom");
        printf("getrandom(%p, 4, GRND_NONBLOCK|GRND_RANDOM|0x3000) = "
-              "-1 EINVAL (Invalid argument)\n", buf);
+              "-1 EINVAL (%m)\n", buf);
 
        puts("+++ exited with 0 +++");
        return 0;
+}
+
 #else
-       return 77;
+
+SKIP_MAIN_UNDEFINED("__NR_getrandom")
+
 #endif
-}