MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_mkdirat

Function test_mkdirat

tests/fs/mkdirat.rs:20–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18#[cfg(not(target_os = "redox"))]
19#[test]
20fn test_mkdirat() {
21 use rustix::fs::{
22 accessat, mkdirat, openat, statat, unlinkat, Access, AtFlags, FileType, Mode, OFlags, CWD,
23 };
24
25 let tmp = tempfile::tempdir().unwrap();
26 let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
27
28 mkdirat(&dir, "file", Mode::RWXU).unwrap();
29 let stat = statat(&dir, "file", AtFlags::empty()).unwrap();
30 assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory);
31 accessat(&dir, "file", Access::READ_OK, AtFlags::empty()).unwrap();
32 accessat(&dir, "file", Access::WRITE_OK, AtFlags::empty()).unwrap();
33 accessat(&dir, "file", Access::EXEC_OK, AtFlags::empty()).unwrap();
34 accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap();
35 unlinkat(&dir, "file", AtFlags::empty()).unwrap_err();
36 unlinkat(&dir, "file", AtFlags::REMOVEDIR).unwrap();
37}
38
39#[cfg(linux_kernel)]
40#[test]

Callers

nothing calls this directly

Calls 6

openatFunction · 0.50
mkdiratFunction · 0.50
statatFunction · 0.50
accessatFunction · 0.50
unlinkatFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected