lldb-server tests: Propagate environment variables (pr34192)
Summary:
Without this, the launching of the test inferior may fail if it depends
on some component of the environment (most likely LD_LIBRARY_PATH). This
makes sure we propagate the environment variable to the inferior
process.
Reviewers: eugene
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D39010
llvm-svn: 316244
diff --git a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
index 67fff20..12b9420 100644
--- a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
+++ b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -101,6 +101,14 @@
}
bool TestClient::SetInferior(llvm::ArrayRef<std::string> inferior_args) {
+ StringList env;
+ Host::GetEnvironment(env);
+ for (size_t i = 0; i < env.GetSize(); ++i) {
+ if (SendEnvironmentPacket(env[i].c_str()) != 0) {
+ GTEST_LOG_(ERROR) << "failed to set environment variable `" << env[i] << "`";
+ return false;
+ }
+ }
std::stringstream command;
command << "A";
for (size_t i = 0; i < inferior_args.size(); i++) {