MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / test

Method test

crates/wiggle/tests/flags.rs:64–96  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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}
98proptest! {
99 #[test]

Callers

nothing calls this directly

Calls 7

guest_memoryMethod · 0.80
newFunction · 0.50
expectMethod · 0.45
writeMethod · 0.45
unwrapMethod · 0.45
bitsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected