mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
cat: add error handling in write_fast function (#8091)
This commit is contained in:
parent
e5bde07591
commit
e1f40ff601
2 changed files with 29 additions and 4 deletions
|
@ -713,6 +713,26 @@ fn test_u_ignored() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_write_fast_read_error() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
// Create a file with content
|
||||
at.write("foo", "content");
|
||||
|
||||
// Remove read permissions to cause a read error
|
||||
let file_path = at.plus_as_string("foo");
|
||||
let mut perms = std::fs::metadata(&file_path).unwrap().permissions();
|
||||
perms.set_mode(0o000); // No permissions
|
||||
std::fs::set_permissions(&file_path, perms).unwrap();
|
||||
|
||||
// Test that cat fails with permission denied
|
||||
ucmd.arg("foo").fails().stderr_contains("Permission denied");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_appending_same_input_output() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue