/*
- * 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
-}