Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixhead committed May 17, 2024
1 parent a83a8ad commit 6b7bfbf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions tests/by-util/test_chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,17 @@ fn test_chmod_recursive() {
at.mkdir("a/b");
at.mkdir("a/b/c");
at.mkdir("z");

make_file(&at.plus_as_string("a/a"), 0o100444);
make_file(&at.plus_as_string("a/b/b"), 0o100444);
make_file(&at.plus_as_string("a/b/c/c"), 0o100444);
make_file(&at.plus_as_string("z/y"), 0o100444);

at.metadata("a").permissions().set_mode(0o777);
at.metadata("a/b").permissions().set_mode(0o777);
at.metadata("a/b/c").permissions().set_mode(0o777);
at.metadata("z").permissions().set_mode(0o777);

// only the permissions of folder `a` and `z` are changed
// folder can't be read after read permission is removed
ucmd.arg("-R")
Expand Down
6 changes: 3 additions & 3 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,15 +2542,15 @@ fn test_no_preserve_mode() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file");
set_permissions(at.plus("file"), PermissionsExt::from_mode(PERMS_ALL)).unwrap();
let umask = 0o022;
let umask: u16 = 0o022;
ucmd.arg("file")
.arg("dest")
.umask(umask)
.umask(umask as libc::mode_t)
.succeeds()
.no_stderr()
.no_stdout();
// remove sticky bit, setuid and setgid bit; apply umask
let expected_perms = PERMS_ALL & !0o7000 & !umask;
let expected_perms = PERMS_ALL & !0o7000 & !umask as u32;
assert_eq!(
at.plus("dest").metadata().unwrap().mode() & 0o7777,
expected_perms
Expand Down
5 changes: 1 addition & 4 deletions tests/by-util/test_mkdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ fn test_mkdir_parent_mode_check_existing_parent() {

assert!(at.dir_exists("a"));
// parent dirs that already exist do not get their permissions modified
assert_eq!(
at.metadata("a").permissions().mode() as mode_t,
parent_a_perms
);
assert_eq!(at.metadata("a").permissions().mode(), parent_a_perms);
assert!(at.dir_exists("a/b"));
assert_eq!(
at.metadata("a/b").permissions().mode() as mode_t,
Expand Down
13 changes: 12 additions & 1 deletion tests/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3901,7 +3901,18 @@ mod tests {
let p_umask = get_umask();
// make sure we are not testing against the same umask
let c_umask = if p_umask == 0o002 { 0o007 } else { 0o002 };
let expected = if p_umask == 0o002 { "0007\n" } else { "0002\n" };
let expected = if cfg!(target_os = "android") {
if p_umask == 0o002 {
"007\n"
} else {
"002\n"
}
} else if p_umask == 0o002 {
"0007\n"
} else {
"0002\n"
};

let ts = TestScenario::new("util");
ts.cmd("sh")
.args(&["-c", "umask"])
Expand Down

0 comments on commit 6b7bfbf

Please sign in to comment.