|
1 | 1 | use once_cell::sync::Lazy;
|
2 | 2 | use regex::Regex;
|
3 |
| -use std::{env, io, io::Write, net::IpAddr, path::PathBuf, process, time::Duration}; |
4 |
| -use tempfile::tempdir; |
| 3 | +use std::{ |
| 4 | + env, |
| 5 | + io::{self, Read, Write}, |
| 6 | + net::IpAddr, |
| 7 | + os::unix::io::AsFd, |
| 8 | + path::PathBuf, |
| 9 | + process, |
| 10 | + time::Duration, |
| 11 | +}; |
| 12 | +use tempfile::{tempdir, tempfile}; |
5 | 13 | use tokio::{
|
6 | 14 | io::{AsyncReadExt, AsyncWriteExt},
|
7 | 15 | net::{UnixListener, UnixStream},
|
@@ -966,3 +974,34 @@ async fn test_read_large_file_bug() {
|
966 | 974 | assert_eq!(stdout.len(), bs * count);
|
967 | 975 | }
|
968 | 976 | }
|
| 977 | + |
| 978 | +#[tokio::test] |
| 979 | +#[cfg_attr(not(ci), ignore)] |
| 980 | +async fn test_read_large_file_bug2() { |
| 981 | + for (session, name) in connects_with_name().await { |
| 982 | + eprintln!("Testing {name} implementation"); |
| 983 | + |
| 984 | + let bs = 1024; |
| 985 | + let count = 20480; |
| 986 | + |
| 987 | + let file = tempfile().unwrap(); |
| 988 | + |
| 989 | + let status = session |
| 990 | + .shell(format!("dd if=/dev/zero bs={bs} count={count}")) |
| 991 | + .stdout(Stdio::from(file.as_fd().try_clone_to_owned().unwrap())) |
| 992 | + .spawn() |
| 993 | + .await |
| 994 | + .unwrap() |
| 995 | + .wait() |
| 996 | + .await |
| 997 | + .unwrap(); |
| 998 | + |
| 999 | + assert!(status.success()); |
| 1000 | + |
| 1001 | + let mut stdout = Vec::with_capacity(bs * count); |
| 1002 | + (&file).read_to_end(&mut stdout).unwrap(); |
| 1003 | + |
| 1004 | + stdout.iter().copied().for_each(|byte| assert_eq!(byte, 0)); |
| 1005 | + assert_eq!(stdout.len(), bs * count); |
| 1006 | + } |
| 1007 | +} |
0 commit comments