[llvm] 07b7a24 - [unittests] Preserve LD_LIBRARY_PATH in crash recovery test

Mikhail Maltsev via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 09:46:31 PDT 2020


Author: Mikhail Maltsev
Date: 2020-09-28T17:46:03+01:00
New Revision: 07b7a24e3fe86fe64ba5a56629cb290f3bd3b86d

URL: https://github.com/llvm/llvm-project/commit/07b7a24e3fe86fe64ba5a56629cb290f3bd3b86d
DIFF: https://github.com/llvm/llvm-project/commit/07b7a24e3fe86fe64ba5a56629cb290f3bd3b86d.diff

LOG: [unittests] Preserve LD_LIBRARY_PATH in crash recovery test

We need to preserve the LD_LIBRARY_PATH environment variable when
spawning a child process (certain setups rely on non-standard paths
for e.g. libstdc++). In order to achieve this, set
LLVM_CRC_UNIXCRCRETURNCODE in the parent process instead of creating
the child's environment from scratch.

Reviewed By: aganea

Differential Revision: https://reviews.llvm.org/D88308

Added: 
    

Modified: 
    llvm/unittests/Support/CrashRecoveryTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Support/CrashRecoveryTest.cpp b/llvm/unittests/Support/CrashRecoveryTest.cpp
index 12f25db270b3..864b852cf2d2 100644
--- a/llvm/unittests/Support/CrashRecoveryTest.cpp
+++ b/llvm/unittests/Support/CrashRecoveryTest.cpp
@@ -170,12 +170,12 @@ TEST(CrashRecoveryTest, UnixCRCReturnCode) {
       Executable, "--gtest_filter=CrashRecoveryTest.UnixCRCReturnCode"};
 
   // Add LLVM_CRC_UNIXCRCRETURNCODE to the environment of the child process.
-  std::vector<StringRef> EnvTable;
-  EnvTable.push_back("LLVM_CRC_UNIXCRCRETURNCODE=1");
+  int Res = setenv("LLVM_CRC_UNIXCRCRETURNCODE", "1", 0);
+  ASSERT_EQ(Res, 0);
 
   std::string Error;
   bool ExecutionFailed;
-  int RetCode = ExecuteAndWait(Executable, argv, makeArrayRef(EnvTable), {}, 0, 0, &Error,
+  int RetCode = ExecuteAndWait(Executable, argv, {}, {}, 0, 0, &Error,
                                &ExecutionFailed);
   ASSERT_EQ(-2, RetCode);
 }


        


More information about the llvm-commits mailing list