File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,14 +232,21 @@ fn test_chmod_ugoa() {
232232}
233233
234234#[ test]
235- #[ cfg( any( target_os = "linux" , target_os = "macos" ) ) ]
236- // TODO fix android, it has 0777
237- // We should force for the umask on startup
235+ #[ cfg( any( target_os = "linux" , target_os = "macos" , target_os = "android" ) ) ]
236+ #[ allow( clippy:: cast_lossless) ]
238237fn test_chmod_umask_expected ( ) {
238+ // Get the actual system umask using libc
239+ let system_umask = unsafe {
240+ let mask = libc:: umask ( 0 ) ;
241+ libc:: umask ( mask) ;
242+ mask
243+ } ;
244+
245+ // Now verify that get_umask() returns the same value
239246 let current_umask = uucore:: mode:: get_umask ( ) ;
240247 assert_eq ! (
241- current_umask, 0o022 ,
242- "Unexpected umask value: expected 022 (octal), but got {current_umask:03o}. Please adjust the test environment. " ,
248+ current_umask, system_umask as u32 ,
249+ "get_umask() returned {current_umask:03o}, but system umask is {system_umask:03o} " ,
243250 ) ;
244251}
245252
You can’t perform that action at this time.
0 commit comments