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

Function test_readlinkat

tests/fs/readlinkat.rs:31–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29#[cfg(not(target_os = "redox"))]
30#[test]
31fn test_readlinkat() {
32 use rustix::fs::{openat, readlinkat, symlinkat, Mode, OFlags, CWD};
33
34 let tmp = tempfile::tempdir().unwrap();
35 let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
36
37 let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap();
38 symlinkat("file", &dir, "link").unwrap();
39
40 readlinkat(&dir, "absent", Vec::new()).unwrap_err();
41 readlinkat(&dir, "file", Vec::new()).unwrap_err();
42
43 let target = readlinkat(&dir, "link", Vec::new()).unwrap();
44 assert_eq!(target.to_string_lossy(), "file");
45
46 symlinkat("link", &dir, "another").unwrap();
47
48 let target = readlinkat(&dir, "link", Vec::new()).unwrap();
49 assert_eq!(target.to_string_lossy(), "file");
50 let target = readlinkat(&dir, "another", Vec::new()).unwrap();
51 assert_eq!(target.to_string_lossy(), "link");
52}
53
54#[cfg(not(target_os = "redox"))]
55#[test]

Callers

nothing calls this directly

Calls 4

openatFunction · 0.50
symlinkatFunction · 0.50
readlinkatFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected