Skip to content

Commit 65d1bb6

Browse files
committed
install: add test to set owner to nonexistent userid
1 parent d8dfaee commit 65d1bb6

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/by-util/test_install.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,3 +1764,23 @@ fn test_install_from_stdin() {
17641764
assert!(at.file_exists(target));
17651765
assert_eq!(at.read(target), test_string);
17661766
}
1767+
1768+
#[test]
1769+
#[cfg(unix)]
1770+
fn test_install_set_owner_nonexistent_userid() {
1771+
let ts = TestScenario::new(util_name!());
1772+
let at = &ts.fixtures;
1773+
at.touch("a");
1774+
at.touch("c");
1775+
1776+
if let Ok(result) = run_ucmd_as_root(&ts, &["-o2", "-g1", "a", "b"]) {
1777+
result.success();
1778+
assert!(at.file_exists("b"));
1779+
1780+
let metadata = fs::metadata(at.plus("b")).unwrap();
1781+
assert_eq!(metadata.uid(), 2);
1782+
assert_eq!(metadata.gid(), 1);
1783+
} else {
1784+
print!("Test skipped; requires root user");
1785+
}
1786+
}

0 commit comments

Comments
 (0)