From b620d0791d9176232d72b2743e93e054a7849a32 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 7 Jun 2025 08:27:34 +0200 Subject: [PATCH] test_dup: ensure the FDs remain in sync even after dup'ing --- src/tools/miri/tests/pass-dep/libc/libc-fs.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/tests/pass-dep/libc/libc-fs.rs b/src/tools/miri/tests/pass-dep/libc/libc-fs.rs index 129b18d8e598..0ff48c389e85 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-fs.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-fs.rs @@ -88,16 +88,17 @@ fn test_dup() { let name_ptr = name.as_bytes().as_ptr().cast::(); unsafe { let fd = libc::open(name_ptr, libc::O_RDONLY); + let new_fd = libc::dup(fd); + let new_fd2 = libc::dup2(fd, 8); + let mut first_buf = [0u8; 4]; libc::read(fd, first_buf.as_mut_ptr() as *mut libc::c_void, 4); assert_eq!(&first_buf, b"dup "); - let new_fd = libc::dup(fd); let mut second_buf = [0u8; 4]; libc::read(new_fd, second_buf.as_mut_ptr() as *mut libc::c_void, 4); assert_eq!(&second_buf, b"and "); - let new_fd2 = libc::dup2(fd, 8); let mut third_buf = [0u8; 4]; libc::read(new_fd2, third_buf.as_mut_ptr() as *mut libc::c_void, 4); assert_eq!(&third_buf, b"dup2");