]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass-dep/shims/libc-getrandom.rs
Rollup merge of #106625 - Swatinem:ref/cov6, r=nagisa
[rust.git] / src / tools / miri / tests / pass-dep / shims / libc-getrandom.rs
1 //@only-target-linux
2
3 use std::ptr;
4
5 fn main() {
6     let mut buf = [0u8; 5];
7     unsafe {
8         assert_eq!(
9             libc::syscall(
10                 libc::SYS_getrandom,
11                 ptr::null_mut::<libc::c_void>(),
12                 0 as libc::size_t,
13                 0 as libc::c_uint,
14             ),
15             0,
16         );
17         assert_eq!(
18             libc::syscall(
19                 libc::SYS_getrandom,
20                 buf.as_mut_ptr() as *mut libc::c_void,
21                 5 as libc::size_t,
22                 0 as libc::c_uint,
23             ),
24             5,
25         );
26
27         assert_eq!(
28             libc::getrandom(ptr::null_mut::<libc::c_void>(), 0 as libc::size_t, 0 as libc::c_uint),
29             0,
30         );
31         assert_eq!(
32             libc::getrandom(
33                 buf.as_mut_ptr() as *mut libc::c_void,
34                 5 as libc::size_t,
35                 0 as libc::c_uint,
36             ),
37             5,
38         );
39     }
40 }