()
| 12 | #[cfg(not(target_os = "redox"))] |
| 13 | #[test] |
| 14 | fn test_file() { |
| 15 | rustix::fs::accessat( |
| 16 | rustix::fs::CWD, |
| 17 | "Cargo.toml", |
| 18 | rustix::fs::Access::READ_OK, |
| 19 | rustix::fs::AtFlags::empty(), |
| 20 | ) |
| 21 | .unwrap(); |
| 22 | |
| 23 | rustix::fs::chown("Cargo.toml", None, None).unwrap(); |
| 24 | |
| 25 | #[cfg(not(any(target_os = "android", target_os = "emscripten")))] |
| 26 | #[allow(unreachable_patterns)] |
| 27 | match rustix::fs::accessat( |
| 28 | rustix::fs::CWD, |
| 29 | "Cargo.toml", |
| 30 | rustix::fs::Access::READ_OK, |
| 31 | rustix::fs::AtFlags::EACCESS, |
| 32 | ) { |
| 33 | Ok(()) => (), |
| 34 | Err( |
| 35 | rustix::io::Errno::NOSYS | rustix::io::Errno::NOTSUP | rustix::io::Errno::OPNOTSUPP, |
| 36 | ) => { |
| 37 | #[cfg(feature = "process")] |
| 38 | if rustix::process::getuid() == rustix::process::geteuid() |
| 39 | && rustix::process::getgid() == rustix::process::getegid() |
| 40 | { |
| 41 | panic!( |
| 42 | "accessat with EACCESS should always work when the effective uid/gid match \ |
| 43 | the real uid/gid" |
| 44 | ) |
| 45 | } |
| 46 | } |
| 47 | Err(err) => panic!("{:?}", err), |
| 48 | } |
| 49 | |
| 50 | // Check that `SYMLINK_FOLLOW` is rejected. Except on NetBSD which seems to |
| 51 | // permit it. |
| 52 | #[cfg(not(target_os = "netbsd"))] |
| 53 | assert_eq!( |
| 54 | rustix::fs::accessat( |
| 55 | rustix::fs::CWD, |
| 56 | "Cargo.toml", |
| 57 | rustix::fs::Access::READ_OK, |
| 58 | rustix::fs::AtFlags::SYMLINK_FOLLOW, |
| 59 | ), |
| 60 | Err(rustix::io::Errno::INVAL) |
| 61 | ); |
| 62 | |
| 63 | assert_eq!( |
| 64 | rustix::fs::openat( |
| 65 | rustix::fs::CWD, |
| 66 | "Cagro.motl", |
| 67 | rustix::fs::OFlags::RDONLY, |
| 68 | rustix::fs::Mode::empty(), |
| 69 | ) |
| 70 | .unwrap_err(), |
| 71 | rustix::io::Errno::NOENT |
nothing calls this directly
no test coverage detected