Index: test/python_api/event/TestEvents.py =================================================================== --- test/python_api/event/TestEvents.py +++ test/python_api/event/TestEvents.py @@ -247,11 +247,13 @@ # The finite state machine for our custom listening thread, with an - # initail state of 0, which means a "running" event is expected. - # It changes to 1 after "running" is received. - # It cahnges to 2 after "stopped" is received. - # 2 will be our final state and the test is complete. - self.state = 0 + # initail state of None, which means no event has been received. + # It changes to 'connected' after 'connected' event is received (for remote platforms) + # It changes to 'running' after 'running' event is received (should happen only if the + # currentstate is either 'None' or 'connected') + # It changes to 'stopped' if a 'stopped' event is received (should happen only if the + # current state is 'running'.) + self.state = None # Create MyListeningThread to wait for state changed events. # By design, a "running" event is expected following by a "stopped" event. @@ -272,12 +274,20 @@ match = pattern.search(desc) if not match: break; - if self.context.state == 0 and match.group(1) == 'running': - self.context.state = 1 + if match.group(1) == 'connected': + # When debugging remote targets with lldb-server, we + # first get the 'connected' event. + self.context.assertTrue(self.context.state == None) + self.context.state = 'connected' continue - elif self.context.state == 1 and match.group(1) == 'stopped': + elif match.group(1) == 'running': + self.context.assertTrue(self.context.state == None or self.context.state == 'connected') + self.context.state = 'running' + continue + elif match.group(1) == 'stopped': + self.context.assertTrue(self.context.state == 'running') # Whoopee, both events have been received! - self.context.state = 2 + self.context.state = 'stopped' break else: break @@ -304,7 +314,7 @@ my_thread.join() # The final judgement. :-) - self.assertTrue(self.state == 2, + self.assertTrue(self.state == 'stopped', "Both expected state changed events received")