diff options
| author | Pavel Labath <pavel@labath.sk> | 2020-03-31 10:47:20 +0200 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2020-04-01 11:20:13 +0200 |
| commit | 0ec88d031ad5abcd78068a8377494ec84ea6a1e1 (patch) | |
| tree | dae83afcbca2a1600a8796780d546d412b9b78ae /lldb/test/API/python_api | |
| parent | 9be4be3e53270fc12b184773203b9aa6eb4ad92b (diff) | |
| download | llvm-0ec88d031ad5abcd78068a8377494ec84ea6a1e1.zip llvm-0ec88d031ad5abcd78068a8377494ec84ea6a1e1.tar.gz llvm-0ec88d031ad5abcd78068a8377494ec84ea6a1e1.tar.bz2 | |
[lldb] Inherit host environment when running shell commands
Summary:
On most hosts we were running shell commands with an empty environment.
The only exception was windows, which was inheriting the host enviroment
mostly by accident.
Running the commands in an empty environment does not sound like a
sensible default, so this patch changes Host::RunShellCommand to inherit
the host environment. This impacts both commands run via
SBPlatform::Run (in case of host platforms), as well as the "platform
shell" CLI command.
Reviewers: jingham, friss
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D77123
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/sbplatform/Makefile | 3 | ||||
| -rw-r--r-- | lldb/test/API/python_api/sbplatform/TestSBPlatform.py | 22 | ||||
| -rw-r--r-- | lldb/test/API/python_api/sbplatform/main.cpp | 8 |
3 files changed, 33 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/sbplatform/Makefile b/lldb/test/API/python_api/sbplatform/Makefile new file mode 100644 index 0000000..99998b2 --- /dev/null +++ b/lldb/test/API/python_api/sbplatform/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/python_api/sbplatform/TestSBPlatform.py b/lldb/test/API/python_api/sbplatform/TestSBPlatform.py new file mode 100644 index 0000000..4735f6e --- /dev/null +++ b/lldb/test/API/python_api/sbplatform/TestSBPlatform.py @@ -0,0 +1,22 @@ +"""Test the SBPlatform APIs.""" + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + +class SBPlatformAPICase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + @add_test_categories(['pyapi']) + def test_run(self): + self.build() + plat = lldb.SBPlatform.GetHostPlatform() + + os.environ["MY_TEST_ENV_VAR"]="SBPlatformAPICase.test_run" + def cleanup(): + del os.environ["MY_TEST_ENV_VAR"] + self.addTearDownHook(cleanup) + cmd = lldb.SBPlatformShellCommand(self.getBuildArtifact("a.out")) + self.assertTrue(plat.Run(cmd).Success()) + self.assertIn("MY_TEST_ENV_VAR=SBPlatformAPICase.test_run", cmd.GetOutput()) diff --git a/lldb/test/API/python_api/sbplatform/main.cpp b/lldb/test/API/python_api/sbplatform/main.cpp new file mode 100644 index 0000000..9f2aca2 --- /dev/null +++ b/lldb/test/API/python_api/sbplatform/main.cpp @@ -0,0 +1,8 @@ +#include <cstdlib> +#include <cstdio> + +int main() { + printf("MY_TEST_ENV_VAR=%s\n", getenv("MY_TEST_ENV_VAR")); + + return 0; +} |
