Skip to content

Commit f5457e4

Browse files
authored
Merge pull request #4382 from RalfJung/dup
test_dup: ensure the FDs remain in sync even after dup'ing
2 parents 2d72737 + b620d07 commit f5457e4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/tools/miri/tests/pass-dep/libc/libc-fs.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ fn test_dup() {
8888
let name_ptr = name.as_bytes().as_ptr().cast::<libc::c_char>();
8989
unsafe {
9090
let fd = libc::open(name_ptr, libc::O_RDONLY);
91+
let new_fd = libc::dup(fd);
92+
let new_fd2 = libc::dup2(fd, 8);
93+
9194
let mut first_buf = [0u8; 4];
9295
libc::read(fd, first_buf.as_mut_ptr() as *mut libc::c_void, 4);
9396
assert_eq!(&first_buf, b"dup ");
9497

95-
let new_fd = libc::dup(fd);
9698
let mut second_buf = [0u8; 4];
9799
libc::read(new_fd, second_buf.as_mut_ptr() as *mut libc::c_void, 4);
98100
assert_eq!(&second_buf, b"and ");
99101

100-
let new_fd2 = libc::dup2(fd, 8);
101102
let mut third_buf = [0u8; 4];
102103
libc::read(new_fd2, third_buf.as_mut_ptr() as *mut libc::c_void, 4);
103104
assert_eq!(&third_buf, b"dup2");

0 commit comments

Comments
 (0)