Skip to content

Commit aad9ce6

Browse files
committed
Move test to individual function
1 parent a7ed890 commit aad9ce6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/pass-dep/libc/libc-fs-with-isolation.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use std::{fs, thread};
77

88
fn main() {
99
test_fcntl_f_dupfd();
10+
test_readlink();
11+
test_stat();
1012
test_socketpair_setfl_getfl();
1113
test_pipe_setfl_getfl();
1214
test_setfl_getfl_threaded();
@@ -17,19 +19,20 @@ fn test_fcntl_f_dupfd() {
1719
unsafe {
1820
assert!(libc::fcntl(1, libc::F_DUPFD, 0) >= 0);
1921
}
22+
}
2023

21-
// Although `readlink` and `stat` require disable-isolation mode
22-
// to properly run, they are tested with isolation mode on to check the error emitted
23-
// with `-Zmiri-isolation-error=warn-nobacktrace`.
24-
25-
// test `readlink`
24+
/// Although `readlink` and `stat` require disable-isolation mode
25+
/// to properly run, they are tested with isolation mode on to check the error emitted
26+
/// with `-Zmiri-isolation-error=warn-nobacktrace`.
27+
fn test_readlink() {
2628
let mut buf = vec![0; "foo_link.txt".len() + 1];
2729
unsafe {
2830
assert_eq!(libc::readlink(c"foo.txt".as_ptr(), buf.as_mut_ptr(), buf.len()), -1);
2931
assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EACCES));
3032
}
33+
}
3134

32-
// test `stat`
35+
fn test_stat() {
3336
let err = fs::metadata("foo.txt").unwrap_err();
3437
assert_eq!(err.kind(), ErrorKind::PermissionDenied);
3538
// check that it is the right kind of `PermissionDenied`

0 commit comments

Comments
 (0)