mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
test_tail: add test_follow_descriptor_vs_rename1-2
This commit is contained in:
parent
07eb50248b
commit
3f4b0146a1
1 changed files with 35 additions and 10 deletions
|
@ -894,11 +894,21 @@ fn test_retry9() {
|
||||||
assert_eq!(buf_stderr, expected_stderr);
|
assert_eq!(buf_stderr, expected_stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn test_follow_descriptor_vs_rename1() {
|
||||||
// gnu/tests/tail-2/descriptor-vs-rename.sh
|
// gnu/tests/tail-2/descriptor-vs-rename.sh
|
||||||
|
// $ ((rm -f A && touch A && sleep 1 && echo -n "A\n" >> A && sleep 1 && \
|
||||||
|
// mv A B && sleep 1 && echo -n "B\n" >> B &)>/dev/null 2>&1 &) ; \
|
||||||
|
// sleep 1 && target/debug/tail --follow=descriptor A ---disable-inotify
|
||||||
|
// $ A
|
||||||
|
// $ B
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
let file_a = "FILE_A";
|
let file_a = "FILE_A";
|
||||||
let file_b = "FILE_B";
|
let file_b = "FILE_B";
|
||||||
|
let file_c = "FILE_C";
|
||||||
|
|
||||||
let mut args = vec![
|
let mut args = vec![
|
||||||
"--follow=descriptor",
|
"--follow=descriptor",
|
||||||
|
@ -910,34 +920,48 @@ fn test_retry9() {
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let i = 2;
|
let i = 2;
|
||||||
// TODO: fix the case without `--disable-inotify` for bsd/macos
|
// FIXME: fix the case without `--disable-inotify` for BSD/macOS
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
let i = 1;
|
let i = 1;
|
||||||
|
|
||||||
let delay = 100;
|
let delay = 500;
|
||||||
for _ in 0..i {
|
for _ in 0..i {
|
||||||
at.touch(file_a);
|
at.touch(file_a);
|
||||||
|
|
||||||
let mut p = ts.ucmd().args(&args).run_no_wait();
|
let mut p = ts.ucmd().args(&args).run_no_wait();
|
||||||
sleep(Duration::from_millis(delay));
|
sleep(Duration::from_millis(delay));
|
||||||
at.append(file_a, "x\n");
|
|
||||||
|
at.append(file_a, "A\n");
|
||||||
sleep(Duration::from_millis(delay));
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
at.rename(file_a, file_b);
|
at.rename(file_a, file_b);
|
||||||
sleep(Duration::from_millis(1000));
|
|
||||||
at.append(file_b, "y\n");
|
|
||||||
sleep(Duration::from_millis(delay));
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
|
at.append(file_b, "B\n");
|
||||||
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
|
at.rename(file_b, file_c);
|
||||||
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
|
at.append(file_c, "C\n");
|
||||||
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
p.kill().unwrap();
|
p.kill().unwrap();
|
||||||
sleep(Duration::from_millis(delay));
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
let (buf_stdout, _) = take_stdout_stderr(&mut p);
|
let (buf_stdout, buf_stderr) = take_stdout_stderr(&mut p);
|
||||||
assert_eq!(buf_stdout, "x\ny\n");
|
assert_eq!(buf_stdout, "A\nB\nC\n");
|
||||||
|
assert!(buf_stderr.is_empty());
|
||||||
|
|
||||||
args.pop();
|
args.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(windows))]
|
#[cfg(target_os = "linux")] // FIXME: fix this test for BSD/macOS
|
||||||
fn test_tail_follow_descriptor_vs_rename_verbose() {
|
fn test_follow_descriptor_vs_rename2() {
|
||||||
|
// Ensure the headers are correct for --verbose.
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
let file_a = "FILE_A";
|
let file_a = "FILE_A";
|
||||||
|
@ -973,11 +997,12 @@ fn test_tail_follow_descriptor_vs_rename_verbose() {
|
||||||
p.kill().unwrap();
|
p.kill().unwrap();
|
||||||
sleep(Duration::from_millis(delay));
|
sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
let (buf_stdout, _) = take_stdout_stderr(&mut p);
|
let (buf_stdout, buf_stderr) = take_stdout_stderr(&mut p);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
buf_stdout,
|
buf_stdout,
|
||||||
"==> FILE_A <==\n\n==> FILE_B <==\n\n==> FILE_A <==\nx\n"
|
"==> FILE_A <==\n\n==> FILE_B <==\n\n==> FILE_A <==\nx\n"
|
||||||
);
|
);
|
||||||
|
assert!(buf_stderr.is_empty());
|
||||||
|
|
||||||
args.pop();
|
args.pop();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue