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

Function test_linkat

tests/fs/linkat.rs:34–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

openatFunction · 0.50
linkatFunction · 0.50
readlinkatFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected