about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-06-10 09:11:22 +0000
committerGitHub <noreply@github.com>2025-06-10 09:11:22 +0000
commitf5457e402f378cd8c04f5da4b4a86b5d0314d677 (patch)
treefde43274a324c4633abf3cfeed779dd87fd7a194
parent2d72737a7936323c89743d14629dbc00b68ca980 (diff)
parentb620d0791d9176232d72b2743e93e054a7849a32 (diff)
downloadrust-f5457e402f378cd8c04f5da4b4a86b5d0314d677.tar.gz
rust-f5457e402f378cd8c04f5da4b4a86b5d0314d677.zip
Merge pull request #4382 from RalfJung/dup
test_dup: ensure the FDs remain in sync even after dup'ing
-rw-r--r--src/tools/miri/tests/pass-dep/libc/libc-fs.rs5
1 files 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 129b18d8e59..0ff48c389e8 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::<libc::c_char>();
     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");