Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -36,10 +36,11 @@ @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly @expectedFailureDarwin('llvm.org/pr23669') @expectedFailureWindows("llvm.org/pr24660") + @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained def test_state_after_expression(self): """Test thread state after expression.""" self.build(dictionary=self.getBuildFlags(use_cpp11=False)) - self.thread_state_after_continue_test() + self.thread_state_after_expression_test() @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly @@ -70,10 +71,6 @@ # This should create a breakpoint in the main thread. lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - # The breakpoint list should show 1 breakpoint with 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1]) - # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -102,6 +99,12 @@ # Kill the process self.runCmd("process kill") + def wait_for_running_event(self): + listener = self.dbg.GetListener() + if lldb.remote_platform: + lldbutil.expect_state_changes(self, listener, [lldb.eStateConnected]) + lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) + def thread_state_after_continue_test(self): """Test thread state after continue.""" exe = os.path.join(os.getcwd(), "a.out") @@ -111,10 +114,6 @@ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) - # The breakpoint list should show 1 breakpoints with 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.break_1]) - # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -139,7 +138,7 @@ # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") - time.sleep(1) + self.wait_for_running_event() # Check the thread state. It should be running. self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") @@ -160,10 +159,6 @@ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) - # The breakpoint list should show 1 breakpoints with 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1]) - # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -204,10 +199,6 @@ # This should create a breakpoint in the main thread. lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) - # The breakpoint list should show 1 breakpoints with 1 location. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1]) - # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -229,7 +220,7 @@ # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") - time.sleep(1) + self.wait_for_running_event() # Go back to synchronous interactions self.dbg.SetAsync(False) @@ -258,11 +249,6 @@ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) - # The breakpoint list should show 2 breakpoints with 1 location each. - self.expect("breakpoint list -f", "Breakpoint location shown correctly", - substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1, - "2: file = 'main.cpp', line = %d, locations = 1" % self.break_2]) - # Run the program. self.runCmd("run", RUN_SUCCEEDED) @@ -291,7 +277,7 @@ # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") - time.sleep(1) + self.wait_for_running_event() # Check the thread state. It should be running. self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.")