Skip to content

Commit ec2deaa

Browse files
committed
test: add test for piping to /dev/full from /dev/stdin
- Adds a new test case to verify that `cat /dev/stdin` properly handles writing to a full device (/dev/full) and outputs the correct error message "No space left on device" without the raw errno code. This improves test coverage for error handling on Unix-like systems.
1 parent 08946a2 commit ec2deaa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/by-util/test_cat.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,21 @@ fn test_piped_to_dev_full() {
228228
}
229229
}
230230

231+
#[test]
232+
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))]
233+
fn test_piped_to_dev_full_from_dev_stdin() {
234+
let dev_full = OpenOptions::new().write(true).open("/dev/full").unwrap();
235+
236+
new_ucmd!()
237+
.arg("/dev/stdin")
238+
.set_stdout(dev_full)
239+
.pipe_in("1")
240+
.ignore_stdin_write_error()
241+
.fails()
242+
.stderr_contains("write error: No space left on device")
243+
.stderr_does_not_contain("ENOSPC");
244+
}
245+
231246
#[test]
232247
fn test_directory() {
233248
let s = TestScenario::new(util_name!());

0 commit comments

Comments
 (0)