]> git.lizzy.rs Git - rust.git/commitdiff
Add test
authorAaron Hill <aa1ronham@gmail.com>
Sun, 4 Aug 2019 19:53:49 +0000 (15:53 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sun, 4 Aug 2019 20:12:24 +0000 (16:12 -0400)
tests/run-pass/linux-getrandom.rs [new file with mode: 0644]

diff --git a/tests/run-pass/linux-getrandom.rs b/tests/run-pass/linux-getrandom.rs
new file mode 100644 (file)
index 0000000..ded5596
--- /dev/null
@@ -0,0 +1,12 @@
+// only-linux: Uses Linux-only APIs
+
+#![feature(rustc_private)]
+extern crate libc;
+
+fn main() {
+    let mut buf = [0u8; 5];
+    unsafe {
+               assert_eq!(libc::syscall(libc::SYS_getrandom, 0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint), 0);
+        assert_eq!(libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr() as *mut libc::c_void, 5 as libc::size_t, 0 as libc::c_uint), 5);
+    }
+}