Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tests/by-util/test_chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,22 @@ fn test_chmod_ugoa() {
}

#[test]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "android"))]
#[cfg(unix)]
#[allow(clippy::cast_lossless)]
fn test_chmod_umask_expected() {
// Get the actual system umask using libc
let system_umask = unsafe {
let mask = libc::umask(0);
libc::umask(mask);
// Get the actual system umask
let system_umask = {
use rustix::process::umask;
let mask = umask(rustix::fs::Mode::empty());
umask(mask);
mask
};

// Now verify that get_umask() returns the same value
let current_umask = uucore::mode::get_umask();
assert_eq!(
current_umask, system_umask as u32,
current_umask,
system_umask.bits() as u32,
"get_umask() returned {current_umask:03o}, but system umask is {system_umask:03o}",
);
}
Expand Down
Loading