@@ -1717,3 +1717,53 @@ fn test_install_root_combined() {
17171717 run_and_check ( & [ "-Cv" , "c" , "d" ] , "d" , 0 , 0 ) ;
17181718 run_and_check ( & [ "-Cv" , "c" , "d" ] , "d" , 0 , 0 ) ;
17191719}
1720+
1721+ #[ test]
1722+ #[ cfg( unix) ]
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) ;
1753+ }
1754+
1755+ #[ test]
1756+ #[ cfg( unix) ]
1757+ fn test_install_from_stdin ( ) {
1758+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
1759+ let target = "target" ;
1760+ let test_string = "Hello, World!\n " ;
1761+
1762+ ucmd. arg ( "/dev/fd/0" )
1763+ . arg ( target)
1764+ . pipe_in ( test_string)
1765+ . succeeds ( ) ;
1766+
1767+ assert ! ( at. file_exists( target) ) ;
1768+ assert_eq ! ( at. read( target) , test_string) ;
1769+ }
0 commit comments