File tree Expand file tree Collapse file tree 1 file changed +30
-12
lines changed
Expand file tree Collapse file tree 1 file changed +30
-12
lines changed Original file line number Diff line number Diff line change @@ -1720,16 +1720,34 @@ fn test_install_root_combined() {
17201720
17211721#[ test]
17221722#[ cfg( unix) ]
1723- fn test_install_from_pipe ( ) {
1724- let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
1725- let target = "target" ;
1726- let test_string = "Hello, World!\n " ;
1727-
1728- ucmd. arg ( "/dev/stdin" )
1729- . arg ( target)
1730- . pipe_in ( test_string)
1731- . succeeds ( ) ;
1732-
1733- assert ! ( at. file_exists( target) ) ;
1734- assert_eq ! ( at. read( target) , test_string) ;
1723+ fn test_install_from_fifo ( ) {
1724+ use std:: fs:: OpenOptions ;
1725+ use std:: io:: Write ;
1726+ use std:: thread;
1727+
1728+ let pipe_name = "pipe" ;
1729+ let target_name = "target" ;
1730+ let test_string = "Hello, world!\n " ;
1731+
1732+ let s = TestScenario :: new ( util_name ! ( ) ) ;
1733+ s. fixtures . mkfifo ( pipe_name) ;
1734+ assert ! ( s. fixtures. is_fifo( pipe_name) ) ;
1735+
1736+ let proc = s. ucmd ( ) . arg ( pipe_name) . arg ( target_name) . run_no_wait ( ) ;
1737+
1738+ let pipe_path = s. fixtures . plus ( pipe_name) ;
1739+ let thread = thread:: spawn ( move || {
1740+ let mut pipe = OpenOptions :: new ( )
1741+ . write ( true )
1742+ . create ( false )
1743+ . open ( pipe_path)
1744+ . unwrap ( ) ;
1745+ pipe. write_all ( test_string. as_bytes ( ) ) . unwrap ( ) ;
1746+ } ) ;
1747+
1748+ proc. wait ( ) . unwrap ( ) ;
1749+ thread. join ( ) . unwrap ( ) ;
1750+
1751+ assert ! ( s. fixtures. file_exists( target_name) ) ;
1752+ assert_eq ! ( s. fixtures. read( target_name) , test_string) ;
17351753}
You can’t perform that action at this time.
0 commit comments