MCPcopy Create free account
hub / github.com/elast0ny/shared_memory / open_flink

Function open_flink

tests/general.rs:67–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66#[test]
67fn open_flink() {
68 let flink = Path::new("create_new2");
69 let s1 = ShmemConf::new().flink(flink).size(4090).create().unwrap();
70
71 // Open with file base link
72 let mut s2 = ShmemConf::new().flink(&flink).open().unwrap();
73
74 assert!(!s2.is_owner());
75 assert!(!s2.get_os_id().is_empty());
76 assert!(flink.is_file());
77 assert!(s2.len() >= 4090);
78 assert!(!s2.as_ptr().is_null());
79 unsafe {
80 assert_eq!(s2.as_slice().len(), s2.len());
81 assert_eq!(s2.as_slice_mut().len(), s2.len());
82 }
83
84 // Drop the owner of the mapping
85 drop(s1);
86
87 // Make sure it can be openned again
88 assert!(ShmemConf::new().flink(&flink).open().is_err());
89
90 drop(s2);
91}
92
93#[test]
94fn share_data() {

Callers

nothing calls this directly

Calls 4

createMethod · 0.80
sizeMethod · 0.80
flinkMethod · 0.80
openMethod · 0.80

Tested by

no test coverage detected