diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2014-05-31 01:36:02 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2014-05-31 01:36:02 +0000 |
commit | bfe17408a9bcad9cbb29ff0dafb8a7674a7c09a6 (patch) | |
tree | c4805b107aea8b61ab69711651c592bcb30de54a /unittests | |
parent | c3648ce2dca6d9a0a86ce4d736c24b896a9ad7a6 (diff) | |
download | llvm-bfe17408a9bcad9cbb29ff0dafb8a7674a7c09a6.tar.gz llvm-bfe17408a9bcad9cbb29ff0dafb8a7674a7c09a6.tar.bz2 llvm-bfe17408a9bcad9cbb29ff0dafb8a7674a7c09a6.tar.xz |
Fix the behavior of ExecuteAndWait with a non-zero timeout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209951 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Support/ProgramTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/unittests/Support/ProgramTest.cpp b/unittests/Support/ProgramTest.cpp index 800df14234..d8cb42af03 100644 --- a/unittests/Support/ProgramTest.cpp +++ b/unittests/Support/ProgramTest.cpp @@ -162,6 +162,36 @@ TEST(ProgramTest, TestExecuteNoWait) { ASSERT_GT(LoopCount, 1u) << "LoopCount should be >1"; } +TEST(ProgramTest, TestExecuteAndWaitTimeout) { + using namespace llvm::sys; + + if (getenv("LLVM_PROGRAM_TEST_TIMEOUT")) { + sleep_for(/*seconds*/ 10); + exit(0); + } + + std::string Executable = + sys::fs::getMainExecutable(TestMainArgv0, &ProgramTestStringArg1); + const char *argv[] = { + Executable.c_str(), + "--gtest_filter=ProgramTest.TestExecuteAndWaitTimeout", + 0 + }; + + // Add LLVM_PROGRAM_TEST_TIMEOUT to the environment of the child. + std::vector<const char *> envp; + CopyEnvironment(envp); + envp.push_back("LLVM_PROGRAM_TEST_TIMEOUT=1"); + envp.push_back(0); + + std::string Error; + bool ExecutionFailed; + int RetCode = + ExecuteAndWait(Executable, argv, &envp[0], 0, /*secondsToWait=*/1, 0, + &Error, &ExecutionFailed); + ASSERT_EQ(-2, RetCode); +} + TEST(ProgramTest, TestExecuteNegative) { std::string Executable = "i_dont_exist"; const char *argv[] = { Executable.c_str(), 0 }; |