|
4 | 4 | // file that was distributed with this source code. |
5 | 5 | // spell-checker:ignore NOFILE nonewline cmdline |
6 | 6 |
|
7 | | -use crate::common::util::TestScenario; |
8 | | -#[cfg(not(windows))] |
9 | | -use crate::common::util::vec_of_size; |
10 | 7 | #[cfg(any(target_os = "linux", target_os = "android"))] |
11 | 8 | use rlimit::Resource; |
12 | | -#[cfg(target_os = "linux")] |
| 9 | +#[cfg(unix)] |
13 | 10 | use std::fs::File; |
14 | 11 | use std::fs::OpenOptions; |
15 | | -#[cfg(not(windows))] |
16 | 12 | use std::process::Stdio; |
| 13 | +use uutests::at_and_ucmd; |
| 14 | +use uutests::new_ucmd; |
| 15 | +use uutests::util::TestScenario; |
| 16 | +#[cfg(not(windows))] |
| 17 | +use uutests::util::vec_of_size; |
| 18 | +use uutests::util_name; |
17 | 19 |
|
18 | 20 | #[test] |
19 | 21 | fn test_output_simple() { |
@@ -668,3 +670,40 @@ fn test_appending_same_input_output() { |
668 | 670 | .no_stdout() |
669 | 671 | .stderr_contains("input file is output file"); |
670 | 672 | } |
| 673 | + |
| 674 | +#[cfg(unix)] |
| 675 | +#[test] |
| 676 | +fn test_uchild_when_no_capture_reading_from_infinite_source() { |
| 677 | + use regex::Regex; |
| 678 | + |
| 679 | + let ts = TestScenario::new("cat"); |
| 680 | + |
| 681 | + let expected_stdout = b"\0".repeat(12345); |
| 682 | + let mut child = ts |
| 683 | + .ucmd() |
| 684 | + .set_stdin(Stdio::from(File::open("/dev/zero").unwrap())) |
| 685 | + .set_stdout(Stdio::piped()) |
| 686 | + .run_no_wait(); |
| 687 | + |
| 688 | + child |
| 689 | + .make_assertion() |
| 690 | + .with_exact_output(12345, 0) |
| 691 | + .stdout_only_bytes(expected_stdout); |
| 692 | + |
| 693 | + child |
| 694 | + .kill() |
| 695 | + .make_assertion() |
| 696 | + .with_current_output() |
| 697 | + .stdout_matches(&Regex::new("[\0].*").unwrap()) |
| 698 | + .no_stderr(); |
| 699 | +} |
| 700 | + |
| 701 | +#[test] |
| 702 | +fn test_child_when_pipe_in() { |
| 703 | + let ts = TestScenario::new("cat"); |
| 704 | + let mut child = ts.ucmd().set_stdin(Stdio::piped()).run_no_wait(); |
| 705 | + child.pipe_in("content"); |
| 706 | + child.wait().unwrap().stdout_only("content").success(); |
| 707 | + |
| 708 | + ts.ucmd().pipe_in("content").run().stdout_is("content"); |
| 709 | +} |
0 commit comments