[Lldb-commits] [PATCH] D63790: [dotest] Add the ability to set environment variables for the inferior.

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 25 15:38:42 PDT 2019


JDevlieghere updated this revision to Diff 206541.

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

https://reviews.llvm.org/D63790

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/lldbtest_config.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest_config.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest_config.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest_config.py
@@ -20,3 +20,6 @@
 
 # path to the lldb command line executable tool
 lldbExec = None
+
+# Environment variables for the inferior
+inferior_env = None
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -835,6 +835,7 @@
                 self.darwinWithFramework = False
         self.makeBuildDir()
 
+
     def setAsync(self, value):
         """ Sets async mode to True/False and ensures it is reset after the testcase completes."""
         old_async = self.dbg.GetAsync()
@@ -1856,6 +1857,9 @@
         # decorators.
         Base.setUp(self)
 
+        if lldbtest_config.inferior_env:
+            self.runCmd('settings set target.env-vars {}'.format(lldbtest_config.inferior_env))
+
         # Set the clang modules cache path used by LLDB.
         mod_cache = os.path.join(os.environ["LLDB_BUILD"], "module-cache-lldb")
         self.runCmd('settings set symbols.clang-modules-cache-path "%s"'
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -210,6 +210,12 @@
         metavar='variable',
         action='append',
         help='Specify an environment variable to set to the given value before running the test cases e.g.: --env CXXFLAGS=-O3 --env DYLD_INSERT_LIBRARIES')
+    group.add_argument(
+        '--inferior-env',
+        dest='set_inferior_env_vars',
+        metavar='variable',
+        action='append',
+        help='Specify an environment variable to set to the given value for the inferior.')
     X('-v', 'Do verbose mode of unittest framework (print out each test case invocation)')
     group.add_argument(
         '--enable-crash-dialog',
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -270,6 +270,9 @@
             else:
                 os.environ[parts[0]] = parts[1]
 
+    if args.set_inferior_env_vars:
+        lldbtest_config.inferior_env = ' '.join(args.set_inferior_env_vars)
+
     # only print the args if being verbose (and parsable is off)
     if args.v and not args.q:
         print(sys.argv)
@@ -636,7 +639,7 @@
 def get_llvm_bin_dirs():
     """
     Returns an array of paths that may have the llvm/clang/etc binaries
-    in them, relative to this current file.  
+    in them, relative to this current file.
     Returns an empty array if none are found.
     """
     result = []


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63790.206541.patch
Type: text/x-patch
Size: 3030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190625/11ca03a9/attachment-0001.bin>


More information about the lldb-commits mailing list