示例#1
0
 def test_raise_assert_for_unexpected_inputs(self):
     with patch('z3.parse_smt2_file', return_value=[]):
         with self.assertRaisesRegex(AssertionError,
                                     '0 or more than 1 asserts'):
             z3_utils.parse_smt2_file('bar')
     with patch('z3.parse_smt2_file', return_value=['1', '2']):
         with self.assertRaises(AssertionError):
             z3_utils.parse_smt2_file('baz')
示例#2
0
    def test_hello(self):
        base_path = Path(__file__).parent
        sketch_ir = Path(base_path / './data/hello.dag').resolve().read_text()
        formula_from_ir = z3_utils.get_z3_formula(sketch_ir, input_bits=2)
        ir_pkt_fields, ir_state_vars = z3_utils.generate_counterexamples(
            formula_from_ir)

        formula_from_smt = z3_utils.parse_smt2_file(
            str(Path(base_path / './data/hello.smt').resolve()))
        smt_pkt_fields, smt_state_vars = z3_utils.generate_counterexamples(
            formula_from_smt)

        self.assertDictEqual(ir_pkt_fields, smt_pkt_fields)
        self.assertDictEqual(ir_state_vars, smt_state_vars)
示例#3
0
 def test_success(self, mock_z3_parse_smt2_file):
     self.assertEqual('1', z3_utils.parse_smt2_file('foo'))