[llvm-branch-commits] [lldb] a0b68a2 - [lldb] Deduplicate some tests in TestLldbGdbServer

Pavel Labath via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 29 00:41:03 PST 2020


Author: Pavel Labath
Date: 2020-12-29T09:37:01+01:00
New Revision: a0b68a2925fbe31f4b0af27677d55feaff6b1362

URL: https://github.com/llvm/llvm-project/commit/a0b68a2925fbe31f4b0af27677d55feaff6b1362
DIFF: https://github.com/llvm/llvm-project/commit/a0b68a2925fbe31f4b0af27677d55feaff6b1362.diff

LOG: [lldb] Deduplicate some tests in TestLldbGdbServer

Use the new gdb-remote test case factory to generate debugserver and
llgs variants, handling the simple cases first.

Added: 
    

Modified: 
    lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 0a93f2ceba08..58df3212f653 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -24,15 +24,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @debugserver_test
-    def test_exe_starts_debugserver(self):
-        server = self.connect_to_debug_monitor()
-
-    @llgs_test
-    def test_exe_starts_llgs(self):
-        server = self.connect_to_debug_monitor()
-
-    def thread_suffix_supported(self):
+    def test_thread_suffix_supported(self):
         server = self.connect_to_debug_monitor()
         self.assertIsNotNone(server)
 
@@ -44,15 +36,8 @@ def thread_suffix_supported(self):
 
         self.expect_gdbremote_sequence()
 
-    @debugserver_test
-    def test_thread_suffix_supported_debugserver(self):
-        self.thread_suffix_supported()
-
-    @llgs_test
-    def test_thread_suffix_supported_llgs(self):
-        self.thread_suffix_supported()
 
-    def list_threads_in_stop_reply_supported(self):
+    def test_list_threads_in_stop_reply_supported(self):
         server = self.connect_to_debug_monitor()
         self.assertIsNotNone(server)
 
@@ -63,15 +48,8 @@ def list_threads_in_stop_reply_supported(self):
             True)
         self.expect_gdbremote_sequence()
 
-    @debugserver_test
-    def test_list_threads_in_stop_reply_supported_debugserver(self):
-        self.list_threads_in_stop_reply_supported()
-
-    @llgs_test
-    def test_list_threads_in_stop_reply_supported_llgs(self):
-        self.list_threads_in_stop_reply_supported()
-
-    def c_packet_works(self):
+    def test_c_packet_works(self):
+        self.build()
         procs = self.prep_debug_monitor_and_inferior()
         self.test_sequence.add_log_lines(
             ["read packet: $c#63",
@@ -80,17 +58,9 @@ def c_packet_works(self):
 
         self.expect_gdbremote_sequence()
 
-    @debugserver_test
-    def test_c_packet_works_debugserver(self):
-        self.build()
-        self.c_packet_works()
-
-    @llgs_test
-    def test_c_packet_works_llgs(self):
+    @skipIfWindows # No pty support to test any inferior output
+    def test_inferior_print_exit(self):
         self.build()
-        self.c_packet_works()
-
-    def inferior_print_exit(self):
         procs = self.prep_debug_monitor_and_inferior(
                 inferior_args=["hello, world"])
         self.test_sequence.add_log_lines(
@@ -102,19 +72,8 @@ def inferior_print_exit(self):
         context = self.expect_gdbremote_sequence()
         self.assertIsNotNone(context)
 
-    @debugserver_test
-    def test_inferior_print_exit_debugserver(self):
-        self.build()
-        self.inferior_print_exit()
-
-    @skipIfWindows # No pty support to test any inferior output
-    @llgs_test
-    @expectedFlakeyLinux("llvm.org/pr25652")
-    def test_inferior_print_exit_llgs(self):
+    def test_first_launch_stop_reply_thread_matches_first_qC(self):
         self.build()
-        self.inferior_print_exit()
-
-    def first_launch_stop_reply_thread_matches_first_qC(self):
         procs = self.prep_debug_monitor_and_inferior()
         self.test_sequence.add_log_lines(["read packet: $qC#00",
                                           {"direction": "send",
@@ -127,17 +86,9 @@ def first_launch_stop_reply_thread_matches_first_qC(self):
                                          True)
         self.expect_gdbremote_sequence()
 
-    @debugserver_test
-    def test_first_launch_stop_reply_thread_matches_first_qC_debugserver(self):
-        self.build()
-        self.first_launch_stop_reply_thread_matches_first_qC()
-
-    @llgs_test
-    def test_first_launch_stop_reply_thread_matches_first_qC_llgs(self):
+    def test_attach_commandline_continue_app_exits(self):
         self.build()
-        self.first_launch_stop_reply_thread_matches_first_qC()
-
-    def attach_commandline_continue_app_exits(self):
+        self.set_inferior_startup_attach()
         procs = self.prep_debug_monitor_and_inferior()
         self.test_sequence.add_log_lines(
             ["read packet: $vCont;c#a8",
@@ -160,19 +111,8 @@ def attach_commandline_continue_app_exits(self):
             lldbgdbserverutils.process_is_running(
                 procs["inferior"].pid, False))
 
-    @debugserver_test
-    def test_attach_commandline_continue_app_exits_debugserver(self):
+    def test_qRegisterInfo_returns_one_valid_result(self):
         self.build()
-        self.set_inferior_startup_attach()
-        self.attach_commandline_continue_app_exits()
-
-    @llgs_test
-    def test_attach_commandline_continue_app_exits_llgs(self):
-        self.build()
-        self.set_inferior_startup_attach()
-        self.attach_commandline_continue_app_exits()
-
-    def qRegisterInfo_returns_one_valid_result(self):
         self.prep_debug_monitor_and_inferior()
         self.test_sequence.add_log_lines(
             ["read packet: $qRegisterInfo0#00",
@@ -188,17 +128,8 @@ def qRegisterInfo_returns_one_valid_result(self):
         self.assert_valid_reg_info(
             lldbgdbserverutils.parse_reg_info_response(reg_info_packet))
 
-    @debugserver_test
-    def test_qRegisterInfo_returns_one_valid_result_debugserver(self):
+    def test_qRegisterInfo_returns_all_valid_results(self):
         self.build()
-        self.qRegisterInfo_returns_one_valid_result()
-
-    @llgs_test
-    def test_qRegisterInfo_returns_one_valid_result_llgs(self):
-        self.build()
-        self.qRegisterInfo_returns_one_valid_result()
-
-    def qRegisterInfo_returns_all_valid_results(self):
         self.prep_debug_monitor_and_inferior()
         self.add_register_info_collection_packets()
 
@@ -210,17 +141,8 @@ def qRegisterInfo_returns_all_valid_results(self):
         for reg_info in self.parse_register_info_packets(context):
             self.assert_valid_reg_info(reg_info)
 
-    @debugserver_test
-    def test_qRegisterInfo_returns_all_valid_results_debugserver(self):
-        self.build()
-        self.qRegisterInfo_returns_all_valid_results()
-
-    @llgs_test
-    def test_qRegisterInfo_returns_all_valid_results_llgs(self):
+    def test_qRegisterInfo_contains_required_generics_debugserver(self):
         self.build()
-        self.qRegisterInfo_returns_all_valid_results()
-
-    def qRegisterInfo_contains_required_generics(self):
         self.prep_debug_monitor_and_inferior()
         self.add_register_info_collection_packets()
 
@@ -248,17 +170,8 @@ def qRegisterInfo_contains_required_generics(self):
         # Ensure we have a flags register.
         self.assertTrue('flags' in generic_regs)
 
-    @debugserver_test
-    def test_qRegisterInfo_contains_required_generics_debugserver(self):
-        self.build()
-        self.qRegisterInfo_contains_required_generics()
-
-    @llgs_test
-    def test_qRegisterInfo_contains_required_generics_llgs(self):
+    def test_qRegisterInfo_contains_at_least_one_register_set(self):
         self.build()
-        self.qRegisterInfo_contains_required_generics()
-
-    def qRegisterInfo_contains_at_least_one_register_set(self):
         self.prep_debug_monitor_and_inferior()
         self.add_register_info_collection_packets()
 
@@ -274,17 +187,6 @@ def qRegisterInfo_contains_at_least_one_register_set(self):
             reg_info['set']: 1 for reg_info in reg_infos if 'set' in reg_info}
         self.assertTrue(len(register_sets) >= 1)
 
-    @debugserver_test
-    def test_qRegisterInfo_contains_at_least_one_register_set_debugserver(
-            self):
-        self.build()
-        self.qRegisterInfo_contains_at_least_one_register_set()
-
-    @llgs_test
-    def test_qRegisterInfo_contains_at_least_one_register_set_llgs(self):
-        self.build()
-        self.qRegisterInfo_contains_at_least_one_register_set()
-
     def targetHasAVX(self):
         triple = self.dbg.GetSelectedPlatform().GetTriple()
 
@@ -305,7 +207,11 @@ def targetHasAVX(self):
         f.close()
         return " avx " in cpuinfo
 
-    def qRegisterInfo_contains_avx_registers(self):
+    @expectedFailureAll(oslist=["windows"]) # no avx for now.
+    @expectedFailureAll(oslist=["netbsd"])
+    @add_test_categories(["llgs"])
+    def test_qRegisterInfo_contains_avx_registers(self):
+        self.build()
         self.prep_debug_monitor_and_inferior()
         self.add_register_info_collection_packets()
 
@@ -323,13 +229,6 @@ def qRegisterInfo_contains_avx_registers(self):
             self.targetHasAVX(),
             "Advanced Vector Extensions" in register_sets)
 
-    @expectedFailureAll(oslist=["windows"]) # no avx for now.
-    @expectedFailureAll(oslist=["netbsd"])
-    @llgs_test
-    def test_qRegisterInfo_contains_avx_registers_llgs(self):
-        self.build()
-        self.qRegisterInfo_contains_avx_registers()
-
     def qThreadInfo_contains_thread(self):
         procs = self.prep_debug_monitor_and_inferior()
         self.add_threadinfo_collection_packets()
@@ -345,27 +244,13 @@ def qThreadInfo_contains_thread(self):
         # We should have exactly one thread.
         self.assertEqual(len(threads), 1)
 
-    @debugserver_test
-    def test_qThreadInfo_contains_thread_launch_debugserver(self):
+    def test_qThreadInfo_contains_thread_launch(self):
         self.build()
         self.set_inferior_startup_launch()
         self.qThreadInfo_contains_thread()
 
-    @llgs_test
-    def test_qThreadInfo_contains_thread_launch_llgs(self):
-        self.build()
-        self.set_inferior_startup_launch()
-        self.qThreadInfo_contains_thread()
-
-    @debugserver_test
-    def test_qThreadInfo_contains_thread_attach_debugserver(self):
-        self.build()
-        self.set_inferior_startup_attach()
-        self.qThreadInfo_contains_thread()
-
     @expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
-    @llgs_test
-    def test_qThreadInfo_contains_thread_attach_llgs(self):
+    def test_qThreadInfo_contains_thread_attach(self):
         self.build()
         self.set_inferior_startup_attach()
         self.qThreadInfo_contains_thread()
@@ -398,32 +283,21 @@ def qThreadInfo_matches_qC(self):
         # Those two should be the same.
         self.assertEqual(threads[0], QC_thread_id)
 
-    @debugserver_test
-    def test_qThreadInfo_matches_qC_launch_debugserver(self):
-        self.build()
-        self.set_inferior_startup_launch()
-        self.qThreadInfo_matches_qC()
-
-    @llgs_test
-    def test_qThreadInfo_matches_qC_launch_llgs(self):
+    def test_qThreadInfo_matches_qC_launch(self):
         self.build()
         self.set_inferior_startup_launch()
         self.qThreadInfo_matches_qC()
 
-    @debugserver_test
-    def test_qThreadInfo_matches_qC_attach_debugserver(self):
-        self.build()
-        self.set_inferior_startup_attach()
-        self.qThreadInfo_matches_qC()
-
     @expectedFailureAll(oslist=["windows"]) # expect one more thread stopped
-    @llgs_test
-    def test_qThreadInfo_matches_qC_attach_llgs(self):
+    def test_qThreadInfo_matches_qC_attach(self):
         self.build()
         self.set_inferior_startup_attach()
         self.qThreadInfo_matches_qC()
 
-    def p_returns_correct_data_size_for_each_qRegisterInfo(self):
+    @expectedFailureAll(oslist=["netbsd"])
+    def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch(self):
+        self.build()
+        self.set_inferior_startup_launch()
         procs = self.prep_debug_monitor_and_inferior()
         self.add_register_info_collection_packets()
 
@@ -476,36 +350,6 @@ def p_returns_correct_data_size_for_each_qRegisterInfo(self):
             # Increment loop
             reg_index += 1
 
-    @debugserver_test
-    def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_debugserver(
-            self):
-        self.build()
-        self.set_inferior_startup_launch()
-        self.p_returns_correct_data_size_for_each_qRegisterInfo()
-
-    @expectedFailureAll(oslist=["netbsd"])
-    @llgs_test
-    def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_llgs(
-            self):
-        self.build()
-        self.set_inferior_startup_launch()
-        self.p_returns_correct_data_size_for_each_qRegisterInfo()
-
-    @debugserver_test
-    def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_debugserver(
-            self):
-        self.build()
-        self.set_inferior_startup_attach()
-        self.p_returns_correct_data_size_for_each_qRegisterInfo()
-
-    @expectedFailureAll(oslist=["netbsd"])
-    @llgs_test
-    def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_llgs(
-            self):
-        self.build()
-        self.set_inferior_startup_attach()
-        self.p_returns_correct_data_size_for_each_qRegisterInfo()
-
     def Hg_switches_to_3_threads(self):
         # Startup the inferior with three threads (main + 2 new ones).
         procs = self.prep_debug_monitor_and_inferior(
@@ -538,28 +382,14 @@ def Hg_switches_to_3_threads(self):
             self.assertIsNotNone(context.get("thread_id"))
             self.assertEqual(int(context.get("thread_id"), 16), thread)
 
-    @debugserver_test
-    def test_Hg_switches_to_3_threads_launch_debugserver(self):
-        self.build()
-        self.set_inferior_startup_launch()
-        self.Hg_switches_to_3_threads()
-
     @expectedFailureAll(oslist=["windows"]) # expect 4 threads
-    @llgs_test
-    def test_Hg_switches_to_3_threads_launch_llgs(self):
+    def test_Hg_switches_to_3_threads_launch(self):
         self.build()
         self.set_inferior_startup_launch()
         self.Hg_switches_to_3_threads()
 
-    @debugserver_test
-    def test_Hg_switches_to_3_threads_attach_debugserver(self):
-        self.build()
-        self.set_inferior_startup_attach()
-        self.Hg_switches_to_3_threads()
-
     @expectedFailureAll(oslist=["windows"]) # expecting one more thread
-    @llgs_test
-    def test_Hg_switches_to_3_threads_attach_llgs(self):
+    def test_Hg_switches_to_3_threads_attach(self):
         self.build()
         self.set_inferior_startup_attach()
         self.Hg_switches_to_3_threads()


        


More information about the llvm-branch-commits mailing list