File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1551,3 +1551,35 @@ fn test_csplit_non_utf8_paths() {
15511551
15521552 ucmd. arg ( & filename) . arg ( "3" ) . succeeds ( ) ;
15531553}
1554+
1555+ /// Test write error detection using /dev/full
1556+ #[ test]
1557+ #[ cfg( target_os = "linux" ) ]
1558+ fn test_write_error_dev_full ( ) {
1559+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
1560+ at. symlink_file ( "/dev/full" , "xx01" ) ;
1561+
1562+ ucmd. args ( & [ "-" , "2" ] )
1563+ . pipe_in ( "1\n 2\n " )
1564+ . fails_with_code ( 1 )
1565+ . stderr_contains ( "xx01: No space left on device" ) ;
1566+
1567+ // Files cleaned up by default
1568+ assert ! ( !at. file_exists( "xx00" ) ) ;
1569+ }
1570+
1571+ /// Test write error with -k keeps files
1572+ #[ test]
1573+ #[ cfg( target_os = "linux" ) ]
1574+ fn test_write_error_dev_full_keep_files ( ) {
1575+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
1576+ at. symlink_file ( "/dev/full" , "xx01" ) ;
1577+
1578+ ucmd. args ( & [ "-k" , "-" , "2" ] )
1579+ . pipe_in ( "1\n 2\n " )
1580+ . fails_with_code ( 1 )
1581+ . stderr_contains ( "xx01: No space left on device" ) ;
1582+
1583+ assert ! ( at. file_exists( "xx00" ) ) ;
1584+ assert_eq ! ( at. read( "xx00" ) , "1\n " ) ;
1585+ }
You can’t perform that action at this time.
0 commit comments