def test_getchar(self): m = ManticoreWASM(if_check_file, env={"getchar": getchar2}) m.main() results = [] for idx, val_list in enumerate(m.collect_returns()): results.append(val_list[0][0]) self.assertEqual(sorted(results), [-1, 0])
def test_br_if(self): m = ManticoreWASM(test_br_if_file) def arg_gen(state): arg = state.new_symbolic_value(32, "arg") state.context["arg"] = arg return [arg] m.main(arg_gen) m.run() assert any((self.can_terminate_with(0, state) for state in m.terminated_states))
:param state: The current state :param _addr: Memory index of the string that gets printed by getchar :return: A symbolic value of the interval [1, 7] """ res = state.new_symbolic_value(32, "getchar_res") state.constrain(res > 0) state.constrain(res < 8) return [res] # Pass our symbolic implementation of the `getchar` function into the WASM environment # as an import. m = ManticoreWASM("collatz.wasm", env={"getchar": getchar}) # Invoke the main function, which will call getchar m.main() # Manually collect return values for idx, val_list in enumerate(m.collect_returns()): print("State", idx, "::", val_list[0]) # Finalize the run (dump testcases) m.finalize() print( """ ============ Example 3 ============ """ )