Author: jdevlieghere Date: Wed Jun 26 09:12:08 2019 New Revision: 364443 URL: http://llvm.org/viewvc/llvm-project?rev=364443&view=rev Log: [dotest] Add the ability to set environment variables for the inferior.
This patch adds a dotest flag for setting environment variables for the inferior. This is different from the current --env flag, which sets variables in the debugger's environment. This allows us to set things like LD_LIBRARY_PATH for testing. Differential revision: https://reviews.llvm.org/D63790 Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest_config.py Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=364443&r1=364442&r2=364443&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Wed Jun 26 09:12:08 2019 @@ -270,6 +270,9 @@ def parseOptionsAndInitTestdirs(): 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) Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py?rev=364443&r1=364442&r2=364443&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py Wed Jun 26 09:12:08 2019 @@ -210,6 +210,12 @@ def create_parser(): 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', 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=364443&r1=364442&r2=364443&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Wed Jun 26 09:12:08 2019 @@ -1856,6 +1856,9 @@ class TestBase(Base): # 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"' Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest_config.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest_config.py?rev=364443&r1=364442&r2=364443&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest_config.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest_config.py Wed Jun 26 09:12:08 2019 @@ -20,3 +20,6 @@ out_of_tree_debugserver = False # path to the lldb command line executable tool lldbExec = None + +# Environment variables for the inferior +inferior_env = None _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits