File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -89,3 +89,29 @@ fn open_flink() {
8989
9090 drop ( s2) ;
9191}
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+ }
You can’t perform that action at this time.
0 commit comments