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

Function test_mkdir

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

Source from the content-addressed store, hash-verified

1#[test]
2fn test_mkdir() {
3 use rustix::fs::{access, mkdir, rmdir, stat, unlink, Access, FileType, Mode};
4
5 let tmp = tempfile::tempdir().unwrap();
6
7 mkdir(tmp.path().join("file"), Mode::RWXU).unwrap();
8 let stat = stat(tmp.path().join("file")).unwrap();
9 assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory);
10 access(tmp.path().join("file"), Access::READ_OK).unwrap();
11 access(tmp.path().join("file"), Access::WRITE_OK).unwrap();
12 access(tmp.path().join("file"), Access::EXEC_OK).unwrap();
13 access(tmp.path().join("file"), Access::EXISTS).unwrap();
14 unlink(tmp.path().join("file")).unwrap_err();
15 rmdir(tmp.path().join("file")).unwrap();
16}
17
18#[cfg(not(target_os = "redox"))]
19#[test]

Callers

nothing calls this directly

Calls 6

mkdirFunction · 0.50
statFunction · 0.50
accessFunction · 0.50
unlinkFunction · 0.50
rmdirFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected