[Lldb-commits] [lldb] r371019 - [dotest] Centralize initialization commands even more

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 5 00:35:45 PDT 2019


Author: labath
Date: Thu Sep  5 00:35:45 2019
New Revision: 371019

URL: http://llvm.org/viewvc/llvm-project?rev=371019&view=rev
Log:
[dotest] Centralize initialization commands even more

Summary:
In r367234 we introduced a central place to hold the set up commands for
the various ways we have of launching lldb. However, a number of
commands still remained outside of that.

This patch moves the remaining set up commands into this function, which
allows us to remove manual clang module path setting code in
TestBatchMode.

One unfortunate victim of this approach is TestSTTYBeforeAndAfter which,
due to how it launches lldb (pexpect->expect->lldb), fails get the
quoting right. It would be possible to fix the quoting there, it would be a bit
icky, and none of the commands in this list are really relevant for what this
test is doing, so I just remove the commands outright.

Reviewers: JDevlieghere, jankratochvil

Subscribers: lldb-commits

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

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
    lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py?rev=371019&r1=371018&r2=371019&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py Thu Sep  5 00:35:45 2019
@@ -24,11 +24,9 @@ class DriverBatchModeTest(PExpectTest):
         self.build()
 
         exe = self.getBuildArtifact("a.out")
-        module_cache = self.getBuildArtifact("module.cache")
 
         # Pass CRASH so the process will crash and stop in batch mode.
         extra_args = ['-b',
-            '-o', "settings set symbols.clang-modules-cache-path '%s'"%module_cache,
             '-o', 'break set -n main',
             '-o', 'run',
             '-o', 'continue',
@@ -57,11 +55,9 @@ class DriverBatchModeTest(PExpectTest):
         self.build()
 
         exe = self.getBuildArtifact("a.out")
-        module_cache = self.getBuildArtifact("module.cache")
 
         # Now do it again, and make sure if we don't crash, we quit:
         extra_args = ['-b',
-            '-o', "settings set symbols.clang-modules-cache-path '%s'"%module_cache,
             '-o', 'break set -n main',
             '-o', 'run',
             '-o', 'continue',
@@ -96,7 +92,6 @@ class DriverBatchModeTest(PExpectTest):
         self.setTearDownCleanup()
 
         exe = self.getBuildArtifact("a.out")
-        module_cache = self.getBuildArtifact("module.cache")
 
         # Start up the process by hand, attach to it, and wait for its completion.
         # Attach is funny, since it looks like it stops with a signal on most Unixen so
@@ -117,7 +112,6 @@ class DriverBatchModeTest(PExpectTest):
 
         extra_args = [
             '-b',
-            '-o', "settings set symbols.clang-modules-cache-path '%s'"%module_cache,
             '-o', 'process attach -p %d'%victim_pid,
             '-o', "breakpoint set --file '%s' -p 'Stop here to unset keep_waiting' -N keep_waiting"%self.source,
             '-o', 'continue',

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=371019&r1=371018&r2=371019&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Sep  5 00:35:45 2019
@@ -684,16 +684,31 @@ class Base(unittest2.TestCase):
         """Return absolute path to a file in the test's source directory."""
         return os.path.join(self.getSourceDir(), name)
 
-    @staticmethod
-    def setUpCommands():
-        return [
+    @classmethod
+    def setUpCommands(cls):
+        commands = [
             # Disable Spotlight lookup. The testsuite creates
             # different binaries with the same UUID, because they only
             # differ in the debug info, which is not being hashed.
             "settings set symbols.enable-external-lookup false",
 
             # Testsuite runs in parallel and the host can have also other load.
-            "settings set plugin.process.gdb-remote.packet-timeout 60"]
+            "settings set plugin.process.gdb-remote.packet-timeout 60",
+
+            'settings set symbols.clang-modules-cache-path "{}"'.format(
+                configuration.module_cache_dir),
+            "settings set use-color false",
+        ]
+        # Make sure that a sanitizer LLDB's environment doesn't get passed on.
+        if cls.platformContext and cls.platformContext.shlib_environment_var in os.environ:
+            commands.append('settings set target.env-vars {}='.format(
+                cls.platformContext.shlib_environment_var))
+
+        # Set environment variables for the inferior.
+        if lldbtest_config.inferior_env:
+            commands.append('settings set target.env-vars {}'.format(
+                lldbtest_config.inferior_env))
+        return commands
 
     def setUp(self):
         """Fixture for unittest test case setup.
@@ -1851,25 +1866,9 @@ class TestBase(Base):
         # decorators.
         Base.setUp(self)
 
-        # Set the clang modules cache path used by LLDB.
-        self.runCmd(
-            'settings set symbols.clang-modules-cache-path "{}"'.format(
-                configuration.module_cache_dir))
-
         for s in self.setUpCommands():
             self.runCmd(s)
 
-        # Disable color.
-        self.runCmd("settings set use-color false")
-
-        # Make sure that a sanitizer LLDB's environment doesn't get passed on.
-        if 'DYLD_LIBRARY_PATH' in os.environ:
-            self.runCmd('settings set target.env-vars DYLD_LIBRARY_PATH=')
-
-        # Set environment variables for the inferior.
-        if lldbtest_config.inferior_env:
-            self.runCmd('settings set target.env-vars {}'.format(lldbtest_config.inferior_env))
-
         if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
             self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"])
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py?rev=371019&r1=371018&r2=371019&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py Thu Sep  5 00:35:45 2019
@@ -73,7 +73,7 @@ class TestSTTYBeforeAndAfter(TestBase):
         child.logfile_read = None
 
         # Invoke the lldb command.
-        child.sendline('%s %s' % (lldbtest_config.lldbExec, self.lldbOption))
+        child.sendline(lldbtest_config.lldbExec)
         child.expect_exact(lldb_prompt)
 
         # Immediately quit.

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py?rev=371019&r1=371018&r2=371019&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py Thu Sep  5 00:35:45 2019
@@ -12,7 +12,7 @@ class VSCodeTestCaseBase(TestBase):
         self.assertTrue(os.path.exists(self.lldbVSCodeExec),
                         'lldb-vscode must exist')
         self.vscode = vscode.DebugAdaptor(
-            executable=self.lldbVSCodeExec, init_commands=Base.setUpCommands())
+            executable=self.lldbVSCodeExec, init_commands=self.setUpCommands())
 
     def build_and_create_debug_adaptor(self):
         self.build()




More information about the lldb-commits mailing list