summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp
new file mode 100644
index 00000000000..08337f537d1
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/getrandom.cpp
@@ -0,0 +1,22 @@
+// RUN: %clangxx -O2 %s -o %t && %run %t
+// UNSUPPORTED: android
+//
+
+#include <sys/types.h>
+
+#if !defined(__GLIBC_PREREQ)
+#define __GLIBC_PREREQ(a, b) 0
+#endif
+
+#if __GLIBC_PREREQ(2, 25)
+#include <sys/random.h>
+#endif
+
+int main() {
+ char buf[16];
+ ssize_t n = 1;
+#if __GLIBC_PREREQ(2, 25)
+ n = getrandom(buf, sizeof(buf), 0);
+#endif
+ return (int)(n <= 0);
+}
OpenPOWER on IntegriCloud