mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
chmod: make a test environment-agnostic
run ssh, it might break with: ---- test_chmod::test_chmod_umask_expected stdout ---- thread 'test_chmod::test_chmod_umask_expected' panicked at tests/by-util/test_chmod.rs:240:5: assertion `left == right` failed: Unexpected umask value: expected 022 (octal), but got 002. Please adjust the test environment. left: 2 right: 18 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This commit is contained in:
parent
1a7e6c05ce
commit
218baa3f88
1 changed files with 12 additions and 5 deletions
|
|
@ -232,14 +232,21 @@ fn test_chmod_ugoa() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
// TODO fix android, it has 0777
|
||||
// We should force for the umask on startup
|
||||
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "android"))]
|
||||
#[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);
|
||||
mask
|
||||
};
|
||||
|
||||
// Now verify that get_umask() returns the same value
|
||||
let current_umask = uucore::mode::get_umask();
|
||||
assert_eq!(
|
||||
current_umask, 0o022,
|
||||
"Unexpected umask value: expected 022 (octal), but got {current_umask:03o}. Please adjust the test environment.",
|
||||
current_umask, system_umask as u32,
|
||||
"get_umask() returned {current_umask:03o}, but system umask is {system_umask:03o}",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue