We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ba5d63e commit 8dfa117Copy full SHA for 8dfa117
1 file changed
tests/general.rs
@@ -89,3 +89,29 @@ fn open_flink() {
89
90
drop(s2);
91
}
92
+
93
+#[test]
94
+fn share_data() {
95
+ let s1 = ShmemConf::new()
96
+ .size(core::mem::size_of::<u32>())
97
+ .create()
98
+ .unwrap();
99
100
+ // Open with the unique os id
101
+ let os_id = s1.get_os_id().to_string();
102
+ let s2 = ShmemConf::new().os_id(&os_id).open().unwrap();
103
104
+ let ptr1 = s1.as_ptr() as *mut u32;
105
+ let ptr2 = s2.as_ptr() as *mut u32;
106
107
+ // Confirm that the two pointers are different
108
+ assert_ne!(ptr1, ptr2);
109
110
+ // Write a value from s1 and read it from s2
111
+ unsafe {
112
+ let shared_val = 0xBADC0FEE;
113
+ ptr1.write_volatile(shared_val);
114
+ let read_val = ptr2.read_volatile();
115
+ assert_eq!(read_val, shared_val);
116
+ }
117
+}
0 commit comments