[Lldb-commits] [lldb] r266326 - [test] Relax stderr expectations on targets with chatty output

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 14 08:52:54 PDT 2016


Author: labath
Date: Thu Apr 14 10:52:53 2016
New Revision: 266326

URL: http://llvm.org/viewvc/llvm-project?rev=266326&view=rev
Log:
[test] Relax stderr expectations on targets with chatty output

Summary:
On some android targets, a binary can produce additional garbage (e.g. warning messages from the
dynamic linker) on the standard error, which confuses some tests. This relaxes the stderr
expectations for targets known for their chattyness.

Reviewers: tfiala, ovyalov

Subscribers: tberghammer, danalbert, srhines, lldb-commits

Differential Revision: http://reviews.llvm.org/D19114

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py
    lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbplatformutil.py Thu Apr 14 10:52:53 2016
@@ -139,3 +139,10 @@ def createPlatformContext():
         return _PlatformContext('LD_LIBRARY_PATH', 'lib', 'so')
     else:
         return None
+
+def hasChattyStderr(test_case):
+    """Some targets produce garbage on the standard error output. This utility function
+    determines whether the tests can be strict about the expected stderr contents."""
+    if match_android_device(test_case.getArchitecture(), ['aarch64'], [22]):
+        return True # The dynamic linker on the device will complain about unknown DT entries
+    return False

Modified: lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py Thu Apr 14 10:52:53 2016
@@ -312,8 +312,11 @@ class SettingsCommandTestCase(TestBase):
         with open('stderr.txt', 'r') as f:
             output = f.read()
 
-        self.expect(output, exe=False,
-            startstr = "This message should go to standard error.")
+        message = "This message should go to standard error."
+        if lldbplatformutil.hasChattyStderr(self):
+            self.expect(output, exe=False, substrs = [message])
+        else:
+            self.expect(output, exe=False, startstr = message)
 
         # The 'stdout.txt' file should now exist.
         self.assertTrue(os.path.isfile("stdout.txt"),

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py Thu Apr 14 10:52:53 2016
@@ -25,7 +25,7 @@ class TestGdbRemoteAuxvSupport(gdbremote
             # Start the inferior...
             "read packet: $c#63",
             # ... match output....
-            { "type":"output_match", "regex":r"^message:main entered\r\n$" },
+            { "type":"output_match", "regex":self.maybe_strict_output_regex(r"message:main entered\r\n") },
             ], True)
         # ... then interrupt.
         self.add_interrupt_packets()

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteRegisterState.py Thu Apr 14 10:52:53 2016
@@ -26,7 +26,7 @@ class TestGdbRemoteRegisterState(gdbremo
             # Start the inferior...
             "read packet: $c#63",
             # ... match output....
-            { "type":"output_match", "regex":r"^message:main entered\r\n$" },
+            { "type":"output_match", "regex":self.maybe_strict_output_regex(r"message:main entered\r\n") },
             ], True)
         # ... then interrupt.
         self.add_interrupt_packets()

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py Thu Apr 14 10:52:53 2016
@@ -232,7 +232,7 @@ class LldbGdbServerTestCase(gdbremote_te
         self.add_verified_launch_packets(launch_args)
         self.test_sequence.add_log_lines(
             ["read packet: $vCont;c#a8",
-             {"type":"output_match", "regex":r"^hello, world\r\n$" },
+             {"type":"output_match", "regex": self.maybe_strict_output_regex(r"hello, world\r\n")},
              "send packet: $W00#00"],
             True)
 
@@ -868,7 +868,8 @@ class LldbGdbServerTestCase(gdbremote_te
              "read packet: $c#63",
              # Match output line that prints the memory address of the message buffer within the inferior. 
              # Note we require launch-only testing so we can get inferior otuput.
-             { "type":"output_match", "regex":r"^data address: 0x([0-9a-fA-F]+)\r\n$", "capture":{ 1:"message_address"} },
+             { "type":"output_match", "regex":self.maybe_strict_output_regex(r"data address: 0x([0-9a-fA-F]+)\r\n"),
+               "capture":{ 1:"message_address"} },
              # Now stop the inferior.
              "read packet: {}".format(chr(3)),
              # And wait for the stop notification.
@@ -950,7 +951,8 @@ class LldbGdbServerTestCase(gdbremote_te
              "read packet: $c#63",
              # Match output line that prints the memory address of the message buffer within the inferior. 
              # Note we require launch-only testing so we can get inferior otuput.
-             { "type":"output_match", "regex":r"^code address: 0x([0-9a-fA-F]+)\r\n$", "capture":{ 1:"code_address"} },
+             { "type":"output_match", "regex":self.maybe_strict_output_regex(r"code address: 0x([0-9a-fA-F]+)\r\n"),
+               "capture":{ 1:"code_address"} },
              # Now stop the inferior.
              "read packet: {}".format(chr(3)),
              # And wait for the stop notification.
@@ -1011,7 +1013,8 @@ class LldbGdbServerTestCase(gdbremote_te
              "read packet: $c#63",
              # Match output line that prints the memory address of the message buffer within the inferior. 
              # Note we require launch-only testing so we can get inferior otuput.
-             { "type":"output_match", "regex":r"^stack address: 0x([0-9a-fA-F]+)\r\n$", "capture":{ 1:"stack_address"} },
+             { "type":"output_match", "regex":self.maybe_strict_output_regex(r"stack address: 0x([0-9a-fA-F]+)\r\n"),
+               "capture":{ 1:"stack_address"} },
              # Now stop the inferior.
              "read packet: {}".format(chr(3)),
              # And wait for the stop notification.
@@ -1072,7 +1075,8 @@ class LldbGdbServerTestCase(gdbremote_te
              "read packet: $c#63",
              # Match output line that prints the memory address of the message buffer within the inferior. 
              # Note we require launch-only testing so we can get inferior otuput.
-             { "type":"output_match", "regex":r"^heap address: 0x([0-9a-fA-F]+)\r\n$", "capture":{ 1:"heap_address"} },
+             { "type":"output_match", "regex":self.maybe_strict_output_regex(r"heap address: 0x([0-9a-fA-F]+)\r\n"),
+               "capture":{ 1:"heap_address"} },
              # Now stop the inferior.
              "read packet: {}".format(chr(3)),
              # And wait for the stop notification.
@@ -1135,7 +1139,8 @@ class LldbGdbServerTestCase(gdbremote_te
              "read packet: $c#63",
              # Match output line that prints the memory address of the function call entry point.
              # Note we require launch-only testing so we can get inferior otuput.
-             { "type":"output_match", "regex":r"^code address: 0x([0-9a-fA-F]+)\r\n$", "capture":{ 1:"function_address"} },
+             { "type":"output_match", "regex":self.maybe_strict_output_regex(r"code address: 0x([0-9a-fA-F]+)\r\n"),
+               "capture":{ 1:"function_address"} },
              # Now stop the inferior.
              "read packet: {}".format(chr(3)),
              # And wait for the stop notification.
@@ -1279,7 +1284,8 @@ class LldbGdbServerTestCase(gdbremote_te
              "read packet: $c#63",
              # Match output line that prints the memory address of the message buffer within the inferior. 
              # Note we require launch-only testing so we can get inferior otuput.
-             { "type":"output_match", "regex":r"^data address: 0x([0-9a-fA-F]+)\r\n$", "capture":{ 1:"message_address"} },
+             { "type":"output_match", "regex":self.maybe_strict_output_regex(r"data address: 0x([0-9a-fA-F]+)\r\n"),
+               "capture":{ 1:"message_address"} },
              # Now stop the inferior.
              "read packet: {}".format(chr(3)),
              # And wait for the stop notification.

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py Thu Apr 14 10:52:53 2016
@@ -1374,3 +1374,6 @@ class GdbRemoteTestCaseBase(TestBase):
         self.assertTrue(state_reached)
         self.assertEqual(step_count, expected_step_count)
 
+    def maybe_strict_output_regex(self, regex):
+        return '.*'+regex+'.*' if lldbplatformutil.hasChattyStderr(self) else '^'+regex+'$'
+

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py?rev=266326&r1=266325&r2=266326&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py Thu Apr 14 10:52:53 2016
@@ -787,7 +787,7 @@ class GdbRemoteTestSequence(object):
                     regex = line.get("regex", None)
                     # Compile the regex.
                     if regex and (type(regex) == str):
-                        regex = re.compile(regex)
+                        regex = re.compile(regex, re.DOTALL)
 
                     regex_mode = line.get("regex_mode", "match")
                     capture = line.get("capture", None)




More information about the lldb-commits mailing list