Skip to content

Commit f176a67

Browse files
sgmarzChrisDryden
authored andcommitted
test_install: add two checks that should give Permission denied. One for failing to remove an existing file and one for trying to stat a file in /root.
1 parent 29ba3a9 commit f176a67

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/by-util/test_install.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ fn test_install_ancestors_mode_directories() {
119119
assert_eq!(0o40_200_u32, at.metadata(target_dir).permissions().mode());
120120
}
121121

122+
#[test]
123+
fn test_install_remove_impermissible_dst_file() {
124+
let src_file = "/dev/null";
125+
let dst_file = "/dev/full";
126+
new_ucmd!().args(&[src_file, dst_file]).fails().stderr_only(format!(
127+
"install: failed to remove existing file '{dst_file}': Permission denied\n"
128+
));
129+
}
130+
131+
#[test]
132+
fn test_install_remove_inaccessible_dst_file() {
133+
let src_file = "/dev/null";
134+
let dst_file = "/root/file";
135+
new_ucmd!().args(&[src_file, dst_file]).fails().stderr_only(format!(
136+
"install: cannot stat '{dst_file}': Permission denied\n"
137+
));
138+
}
139+
122140
#[test]
123141
fn test_install_ancestors_mode_directories_with_file() {
124142
let (at, mut ucmd) = at_and_ucmd!();

0 commit comments

Comments
 (0)