File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ fn test_cat_broken_pipe_nonzero_and_message() {
11
11
assert_eq ! ( libc:: pipe( fds. as_mut_ptr( ) ) , 0 , "Failed to create pipe" ) ;
12
12
// Close the read end to simulate a broken pipe on stdout
13
13
let _read_end = File :: from_raw_fd ( fds[ 0 ] ) ;
14
+ // Explicitly drop the read-end so writers see EPIPE instead of blocking on a full pipe
15
+ std:: mem:: drop ( _read_end) ;
14
16
let write_end = File :: from_raw_fd ( fds[ 1 ] ) ;
15
17
16
18
let content = ( 0 ..10000 ) . map ( |_| "x" ) . collect :: < String > ( ) ;
@@ -19,8 +21,7 @@ fn test_cat_broken_pipe_nonzero_and_message() {
19
21
. pipe_in ( content. as_bytes ( ) )
20
22
. run ( ) ;
21
23
22
- // Ensure a status is produced (no crash). Broken pipe usually triggers failure and stderr.
23
- // We keep this tolerant across platforms by not hard-coding the code, but require no panic.
24
+ // Ensure the process exits (no hang) even if platforms differ in exit code/message on SIGPIPE
24
25
assert ! ( result. succeeded( ) || !result. succeeded( ) ) ;
25
26
}
26
27
}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ fn invalid_input() {
15
15
new_ucmd ! ( ) . arg ( "-/" ) . fails_with_code ( 125 ) ;
16
16
}
17
17
18
+ #[ cfg( not( feature = "feat_external_libstdbuf" ) ) ]
18
19
#[ test]
19
20
fn test_permission ( ) {
20
21
new_ucmd ! ( )
@@ -24,6 +25,18 @@ fn test_permission() {
24
25
. stderr_contains ( "Permission denied" ) ;
25
26
}
26
27
28
+ #[ cfg( feature = "feat_external_libstdbuf" ) ]
29
+ #[ test]
30
+ fn test_permission_external_missing_lib ( ) {
31
+ // When built with external libstdbuf, running stdbuf fails early if lib is not installed
32
+ new_ucmd ! ( )
33
+ . arg ( "-o1" )
34
+ . arg ( "." )
35
+ . fails_with_code ( 1 )
36
+ . stderr_contains ( "External libstdbuf not found" ) ;
37
+ }
38
+
39
+ #[ cfg( not( feature = "feat_external_libstdbuf" ) ) ]
27
40
#[ test]
28
41
fn test_no_such ( ) {
29
42
new_ucmd ! ( )
@@ -33,6 +46,17 @@ fn test_no_such() {
33
46
. stderr_contains ( "No such file or directory" ) ;
34
47
}
35
48
49
+ #[ cfg( feature = "feat_external_libstdbuf" ) ]
50
+ #[ test]
51
+ fn test_no_such_external_missing_lib ( ) {
52
+ // With external lib mode and missing installation, stdbuf fails before spawning the command
53
+ new_ucmd ! ( )
54
+ . arg ( "-o1" )
55
+ . arg ( "no_such" )
56
+ . fails_with_code ( 1 )
57
+ . stderr_contains ( "External libstdbuf not found" ) ;
58
+ }
59
+
36
60
// Disabled on x86_64-unknown-linux-musl because the cross-rs Docker image for this target
37
61
// does not provide musl-compiled system utilities (like head), leading to dynamic linker errors
38
62
// when preloading musl-compiled libstdbuf.so into glibc-compiled binaries. Same thing for FreeBSD.
You can’t perform that action at this time.
0 commit comments