コード例 #1
0
    def client_func(self, port, number_of_queries=1, random_close=False):
        sock = gevent.socket.socket()
        sock.connect(('127.0.0.1', port))
        for _ in range(1, number_of_queries):
            id = common.send_new_query(sock, common.SAT_QUERY_KLEE)
            if random_close and random.random() > 1/2.:
                break
            common.send_cancel_query(sock, id)
            id = common.send_new_query(sock, common.SAT_QUERY_KLEE)

            reply = None
            while True:
                reply = ReplyMessage()
                common.recv_to_message(sock, reply)
                if reply.cmdId == id: #there might be an outdated messages
                    break
            assert reply.type == ReplyMessage.SAT
            common.assert_sat_ser_assignments(reply.sat.assignment, common.SAT_QUERY_ASSIGNMENT_SERIALIZED_KLEE)
        sock.close()
コード例 #2
0
    def test_SendResult(self):
        self.uniq_query = None
        self.ev_new = gevent.event.Event()
        def on_new(u_q):
            assert u_q is not None
            self.uniq_query = u_q
            self.ev_new.set()
        with TcpCmdChannel('localhost', 12346, Test.CmdHandlerFunc(on_new)) as tcp_cmd_channel:
            assert tcp_cmd_channel is not None
            sock = gevent.socket.socket()
            sock.connect(('localhost', 12346))
            
            common.send_new_query(sock, common.SAT_QUERY_SMT)
            assert self.ev_new.wait(5)
            assert self.uniq_query is not None

            result = SolverResult(self.uniq_query, True, {'some solver': '1212'}, {'arr':[0, 1, 2, 3]})
            assert tcp_cmd_channel is not None
            tcp_cmd_channel.send_result(result)
            common.recv_to_message(sock, ReplyMessage())