1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

test_tail: add test_follow_truncate_fast

This commit is contained in:
Jan Scheer 2022-06-02 16:56:09 +02:00
parent f3aacac9d8
commit 42fa386d89
No known key found for this signature in database
GPG key ID: C62AD4C29E2B9828

View file

@ -1740,6 +1740,54 @@ fn test_follow_name_truncate4() {
}
}
#[test]
fn test_follow_truncate_fast() {
// inspired by: "gnu/tests/tail-2/truncate.sh"
// Ensure all logs are output upon file truncation
// This is similar to `test_follow_name_truncate1-3` but uses very short delays
// to better mimic the tight timings used in the "truncate.sh" test.
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let mut args = vec![
"-s.1",
"--max-unchanged-stats=1",
"f",
"---disable-inotify",
];
let follow = vec!["-f", "-F"];
let delay = 100;
for _ in 0..2 {
for mode in &follow {
args.push(mode);
at.truncate("f", "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
let mut p = ts.ucmd().set_stdin(Stdio::null()).args(&args).run_no_wait();
sleep(Duration::from_millis(delay));
at.truncate("f", "11\n12\n13\n14\n15\n");
sleep(Duration::from_millis(delay));
p.kill().unwrap();
sleep(Duration::from_millis(delay));
let (buf_stdout, buf_stderr) = take_stdout_stderr(&mut p);
assert_eq!(
buf_stdout,
"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n"
);
assert_eq!(buf_stderr, "tail: f: file truncated\n");
args.pop();
}
args.pop();
}
}
#[test]
#[cfg(all(unix, not(any(target_os = "android", target_vendor = "apple"))))] // FIXME: make this work not just on Linux
fn test_follow_name_move_create() {