rust/tests/pass/linux-getrandom-without-isolation.rs
2022-06-20 16:09:45 -07:00

42 lines
996 B
Rust

// only-linux
// compile-flags: -Zmiri-disable-isolation
#![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
);
assert_eq!(
libc::getrandom(0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint),
0
);
assert_eq!(
libc::getrandom(
buf.as_mut_ptr() as *mut libc::c_void,
5 as libc::size_t,
0 as libc::c_uint
),
5
);
}
}