[Lldb-commits] [PATCH] D98749: [lldb] [test] Fix TestGdbRemote_vContThreads.py logic

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 17 01:29:59 PDT 2021


mgorny updated this revision to Diff 331176.
mgorny edited the summary of this revision.
mgorny added a comment.

Added a helper `send_and_check_signal` method to reduce code duplication.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98749/new/

https://reviews.llvm.org/D98749

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


Index: lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -31,6 +31,34 @@
         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 @@
 
         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 @@
 
         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):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98749.331176.patch
Type: text/x-patch
Size: 3017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210317/0caa2be1/attachment.bin>


More information about the lldb-commits mailing list