1 #[cfg(not(any(target_os = "redox", target_os = "wasi")))]
2 #[test]
test_mkdirat()3 fn test_mkdirat() {
4 use rustix::fs::{cwd, mkdirat, openat, statat, unlinkat, AtFlags, FileType, Mode, OFlags};
5
6 let tmp = tempfile::tempdir().unwrap();
7 let dir = openat(cwd(), tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
8
9 mkdirat(&dir, "foo", Mode::RWXU).unwrap();
10 let stat = statat(&dir, "foo", AtFlags::empty()).unwrap();
11 assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory);
12 unlinkat(&dir, "foo", AtFlags::REMOVEDIR).unwrap();
13 }
14
15 #[cfg(any(target_os = "android", target_os = "linux"))]
16 #[test]
test_mkdirat_with_o_path()17 fn test_mkdirat_with_o_path() {
18 use rustix::fs::{cwd, mkdirat, openat, statat, unlinkat, AtFlags, FileType, Mode, OFlags};
19
20 let tmp = tempfile::tempdir().unwrap();
21 let dir = openat(
22 cwd(),
23 tmp.path(),
24 OFlags::RDONLY | OFlags::PATH,
25 Mode::empty(),
26 )
27 .unwrap();
28
29 mkdirat(&dir, "foo", Mode::RWXU).unwrap();
30 let stat = statat(&dir, "foo", AtFlags::empty()).unwrap();
31 assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory);
32 unlinkat(&dir, "foo", AtFlags::REMOVEDIR).unwrap();
33 }
34