| 126 | .boxed() |
| 127 | } |
| 128 | pub fn test(&self) { |
| 129 | let mut ctx = WasiCtx::new(); |
| 130 | let mut host_memory = HostMemory::new(); |
| 131 | let mut memory = host_memory.guest_memory(); |
| 132 | |
| 133 | memory |
| 134 | .write(GuestPtr::new(self.input2_loc.ptr), self.input2) |
| 135 | .expect("input2 ref_mut"); |
| 136 | |
| 137 | memory |
| 138 | .write(GuestPtr::new(self.input3_loc.ptr), self.input3) |
| 139 | .expect("input3 ref_mut"); |
| 140 | |
| 141 | memory |
| 142 | .write(GuestPtr::new(self.input4_loc.ptr), self.input4) |
| 143 | .expect("input4 ref_mut"); |
| 144 | |
| 145 | memory |
| 146 | .write(GuestPtr::new(self.input4_ptr_loc.ptr), self.input4_loc.ptr) |
| 147 | .expect("input4 ptr ref_mut"); |
| 148 | |
| 149 | let e = pointers::pointers_and_enums( |
| 150 | &mut ctx, |
| 151 | &mut memory, |
| 152 | self.input1 as i32, |
| 153 | self.input2_loc.ptr as i32, |
| 154 | self.input3_loc.ptr as i32, |
| 155 | self.input4_ptr_loc.ptr as i32, |
| 156 | ) |
| 157 | .unwrap(); |
| 158 | assert_eq!(e, types::Errno::Ok as i32, "errno"); |
| 159 | |
| 160 | // Implementation of pointers_and_enums writes input3 to the input2_loc: |
| 161 | let written_to_input2_loc: i32 = memory |
| 162 | .read(GuestPtr::new(self.input2_loc.ptr)) |
| 163 | .expect("input2 ref"); |
| 164 | |
| 165 | assert_eq!( |
| 166 | written_to_input2_loc, self.input3 as i32, |
| 167 | "pointers_and_enums written to input2" |
| 168 | ); |
| 169 | |
| 170 | // Implementation of pointers_and_enums writes input2_loc to input4_ptr_loc: |
| 171 | let written_to_input4_ptr: u32 = memory |
| 172 | .read(GuestPtr::new(self.input4_ptr_loc.ptr)) |
| 173 | .expect("input4_ptr_loc ref"); |
| 174 | |
| 175 | assert_eq!( |
| 176 | written_to_input4_ptr, self.input2_loc.ptr, |
| 177 | "pointers_and_enums written to input4_ptr" |
| 178 | ); |
| 179 | } |
| 180 | } |
| 181 | proptest! { |
| 182 | #[test] |