[Lldb-commits] [lldb] 9cf21da - [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 17 09:30:57 PDT 2021


Author: Michał Górny
Date: 2021-03-17T17:30:28+01:00
New Revision: 9cf21da776b5e71da46826ba941147495285f106

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

LOG: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

The TestGdbRemote_vContThreads.py were introduced to test NetBSD process
plugin's capability of sending per-thread and per-process signals.
However, at some point the tests started failing.  From retrospective,
it is possible that they were relying on some bug in the plugin's
original signal handling.

Fix the tests not to expect the process to terminate after receiving
the signals.  Instead, scan for output indicating that the signals were
received and match thread IDs in it.  Enable 'signal to all threads'
test everywhere as it works fine on Linux.  Add a new test for vCont
packet without specific thread IDs.  Introduce a helper function
to cover the common part of tests.

While this does not fix all the problems on NetBSD, it enables a subset
of the tests on other systems.  I am planning to add more tests
to the group while implementing multiprocess extension for vCont.

Differential Revision: https://reviews.llvm.org/D98749

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
index 5278d59fb06a..9243f71e8650 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@ def start_threads(self, num):
         self.reset_test_sequence()
         return threads
 
+    def send_and_check_signal(self, vCont_data, threads):
+        self.test_sequence.add_log_lines([
+            "read packet: $vCont;{0}#00".format(vCont_data),
+            {"type": "output_match",
+             "regex": self.maybe_strict_output_regex(
+                 len(threads) *
+                 r"received SIGUSR1 on thread id: ([0-9a-f]+)\r\n"),
+             "capture": dict((i, "tid{0}".format(i)) for i
+                             in range(1, len(threads)+1)),
+             },
+        ], True)
+
+        context = self.expect_gdbremote_sequence()
+        self.assertIsNotNone(context)
+        tids = sorted(int(context["tid{0}".format(x)], 16)
+                      for x in range(1, len(threads)+1))
+        self.assertEqual(tids, sorted(threads))
+
+    @expectedFailureNetBSD
+    def test_signal_process_without_tid(self):
+        self.build()
+        self.set_inferior_startup_launch()
+
+        threads = self.start_threads(1)
+        self.send_and_check_signal(
+            "C{0:x}".format(lldbutil.get_signal_number('SIGUSR1')),
+            threads)
+
     @skipUnlessPlatform(["netbsd"])
     @expectedFailureNetBSD
     def test_signal_one_thread(self):
@@ -39,16 +67,10 @@ def test_signal_one_thread(self):
 
         threads = self.start_threads(1)
         # try sending a signal to one of the two threads
-        self.test_sequence.add_log_lines([
-            "read packet: $vCont;C{0:x}:{1:x};c#00".format(
-                lldbutil.get_signal_number('SIGUSR1'), threads[0]),
-            {"direction": "send", "regex": r"^\$W00#b7$"},
-        ], True)
-
-        context = self.expect_gdbremote_sequence()
-        self.assertIsNotNone(context)
+        self.send_and_check_signal(
+            "C{0:x}:{1:x};c".format(lldbutil.get_signal_number('SIGUSR1')),
+            threads[:1])
 
-    @skipUnlessPlatform(["netbsd"])
     @expectedFailureNetBSD
     def test_signal_all_threads(self):
         self.build()
@@ -56,15 +78,11 @@ def test_signal_all_threads(self):
 
         threads = self.start_threads(1)
         # try sending a signal to two threads (= the process)
-        self.test_sequence.add_log_lines([
-            "read packet: $vCont;C{0:x}:{1:x};C{0:x}:{2:x}#00".format(
+        self.send_and_check_signal(
+            "C{0:x}:{1:x};C{0:x}:{2:x}".format(
                 lldbutil.get_signal_number('SIGUSR1'),
-                threads[0], threads[1]),
-            {"direction": "send", "regex": r"^\$W00#b7$"},
-        ], True)
-
-        context = self.expect_gdbremote_sequence()
-        self.assertIsNotNone(context)
+                *threads),
+            threads)
 
     @skipUnlessPlatform(["netbsd"])
     def test_signal_two_of_three_threads(self):


        


More information about the lldb-commits mailing list