Debian Codegraph @

debian/rust-vendor/rlimit/tests/it/utils.rs

raw
1 use std::io;
2
3 #[track_caller]
4 pub fn expect_ok(result: io::Result<()>) {
5 assert!(
6 result.is_ok(),
7 "result = {}, should be OK()",
8 result.as_ref().unwrap_err(),
9 );
10 }
11
12 #[track_caller]
13 pub fn expect_err(result: io::Result<()>, kind: io::ErrorKind) {
14 assert_eq!(result.unwrap_err().kind(), kind);
15 }
16
17 pub fn atomically<R>(f: impl FnOnce() -> R) -> R {
18 use once_cell::sync::Lazy;
19 use std::sync::Mutex;
20
21 static LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
22 let _guard = LOCK.lock().unwrap();
23 f()
24 }
25
26 #[test]
27 #[ignore]
28 fn tools_nofile() {
29 let lim = rlimit::increase_nofile_limit(u64::MAX).unwrap();
30 dbg!(lim);
31 }