Author: labath Date: Mon Dec 7 05:09:14 2015 New Revision: 254901 URL: http://llvm.org/viewvc/llvm-project?rev=254901&view=rev Log: Make TestThreadStates more stable
Summary: Because of the large number of XFAILs TestThreadStates has decayed quite a bit. This commit does the following: - removes the "breakpoint list" expectations. Most tests have been failing on this, because the command output changed quite a while back. I remove it, because run_break_set_by_file_and_line already does a decent amount of checking - fixup test_state_after_expression: this was calling the wrong function by mistake. As now the function actually tests something (which we know is broken), I needed to XFAIL it as well. - replaces the sleep() with a proper wait-for-event functionality in parts which use async mode, to stabilize the one function that actually tests something. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D15233 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py?rev=254901&r1=254900&r2=254901&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py Mon Dec 7 05:09:14 2015 @@ -36,10 +36,11 @@ class ThreadStateTestCase(TestBase): @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 @@ class ThreadStateTestCase(TestBase): # 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 @@ class ThreadStateTestCase(TestBase): # 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 @@ class ThreadStateTestCase(TestBase): 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 @@ class ThreadStateTestCase(TestBase): # 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 @@ class ThreadStateTestCase(TestBase): 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 @@ class ThreadStateTestCase(TestBase): # 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 @@ class ThreadStateTestCase(TestBase): # 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 @@ class ThreadStateTestCase(TestBase): 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 @@ class ThreadStateTestCase(TestBase): # 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.") _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits