lldb-server tests: Propagate environment variables (pr34192)
authorPavel Labath <labath@google.com>
Fri, 20 Oct 2017 22:39:18 +0000 (22:39 +0000)
committerPavel Labath <labath@google.com>
Fri, 20 Oct 2017 22:39:18 +0000 (22:39 +0000)
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

lldb/unittests/tools/lldb-server/tests/TestClient.cpp

index 67fff20..12b9420 100644 (file)
@@ -101,6 +101,14 @@ bool TestClient::StopDebugger() {
 }
 
 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++) {