| 62 | } |
| 63 | |
| 64 | pub fn test(&self) { |
| 65 | let mut ctx = WasiCtx::new(); |
| 66 | let mut host_memory = HostMemory::new(); |
| 67 | let mut memory = host_memory.guest_memory(); |
| 68 | |
| 69 | // Populate input ptr |
| 70 | memory |
| 71 | .write( |
| 72 | GuestPtr::new(self.other_config_by_ptr.ptr), |
| 73 | self.other_config, |
| 74 | ) |
| 75 | .expect("deref ptr mut to CarConfig"); |
| 76 | |
| 77 | let res = flags::configure_car( |
| 78 | &mut ctx, |
| 79 | &mut memory, |
| 80 | self.old_config.bits() as i32, |
| 81 | self.other_config_by_ptr.ptr as i32, |
| 82 | self.return_ptr_loc.ptr as i32, |
| 83 | ) |
| 84 | .unwrap(); |
| 85 | assert_eq!(res, types::Errno::Ok as i32, "configure car errno"); |
| 86 | |
| 87 | let res_config = memory |
| 88 | .read(GuestPtr::<types::CarConfig>::new(self.return_ptr_loc.ptr)) |
| 89 | .expect("deref to CarConfig value"); |
| 90 | |
| 91 | assert_eq!( |
| 92 | self.old_config ^ self.other_config, |
| 93 | res_config, |
| 94 | "returned CarConfig should be an XOR of inputs" |
| 95 | ); |
| 96 | } |
| 97 | } |
| 98 | proptest! { |
| 99 | #[test] |