Ejemplo n.º 1
0
 def run(self, resume=None, wait=True):
     if resume is None:
         resume = Message(type=_ATMT_Command.RUN)
     self.cmdin.send(resume)
     if wait:
         try:
             c = self.cmdout.recv()
         except KeyboardInterrupt:
             self.cmdin.send(Message(type=_ATMT_Command.FREEZE))
             return
         if c.type == _ATMT_Command.END:
             return c.result
         elif c.type == _ATMT_Command.INTERCEPT:
             raise self.InterceptionPoint("packet intercepted",
                                          state=c.state.state,
                                          packet=c.pkt)
         elif c.type == _ATMT_Command.SINGLESTEP:
             raise self.Singlestep("singlestep state=[%s]" % c.state.state,
                                   state=c.state.state)
         elif c.type == _ATMT_Command.BREAKPOINT:
             raise self.Breakpoint("breakpoint triggered on state [%s]" %
                                   c.state.state,
                                   state=c.state.state)
         elif c.type == _ATMT_Command.EXCEPTION:
             six.reraise(c.exc_info[0], c.exc_info[1], c.exc_info[2])
Ejemplo n.º 2
0
def retry_test(func):
    """Retries the passed function 3 times before failing"""
    success = False
    for _ in six.moves.range(3):
        try:
            result = func()
        except Exception:
            t, v, tb = sys.exc_info()
            time.sleep(1)
        else:
            success = True
            break
    if not success:
        six.reraise(t, v, tb)
    assert success
    return result
Ejemplo n.º 3
0
 def run(self, resume=None, wait=True):
     if resume is None:
         resume = Message(type=_ATMT_Command.RUN)
     self.cmdin.send(resume)
     if wait:
         try:
             c = self.cmdout.recv()
         except KeyboardInterrupt:
             self.cmdin.send(Message(type=_ATMT_Command.FREEZE))
             return
         if c.type == _ATMT_Command.END:
             return c.result
         elif c.type == _ATMT_Command.INTERCEPT:
             raise self.InterceptionPoint("packet intercepted", state=c.state.state, packet=c.pkt)  # noqa: E501
         elif c.type == _ATMT_Command.SINGLESTEP:
             raise self.Singlestep("singlestep state=[%s]" % c.state.state, state=c.state.state)  # noqa: E501
         elif c.type == _ATMT_Command.BREAKPOINT:
             raise self.Breakpoint("breakpoint triggered on state [%s]" % c.state.state, state=c.state.state)  # noqa: E501
         elif c.type == _ATMT_Command.EXCEPTION:
             six.reraise(c.exc_info[0], c.exc_info[1], c.exc_info[2])