Skip to content

Commit 5006c2a

Browse files
committed
Add integration test test_read_large_file_bug2
Signed-off-by: Jiahao XU <[email protected]>
1 parent a0e7bce commit 5006c2a

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

tests/openssh.rs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
use once_cell::sync::Lazy;
22
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};
513
use tokio::{
614
io::{AsyncReadExt, AsyncWriteExt},
715
net::{UnixListener, UnixStream},
@@ -966,3 +974,34 @@ async fn test_read_large_file_bug() {
966974
assert_eq!(stdout.len(), bs * count);
967975
}
968976
}
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

Comments
 (0)