summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2014-05-31 01:36:02 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2014-05-31 01:36:02 +0000
commitec1aacaf5c9b5a9ff7ca7ab7a99b4c6bbdfb6fca (patch)
tree8f73b4cd80d324cdac39ecdeaf4636924acf9daa /llvm/unittests
parent613807b4d0c19b5ebd3fd3a5bc106d4a34324cc5 (diff)
downloadbcm5719-llvm-ec1aacaf5c9b5a9ff7ca7ab7a99b4c6bbdfb6fca.tar.gz
bcm5719-llvm-ec1aacaf5c9b5a9ff7ca7ab7a99b4c6bbdfb6fca.zip
Fix the behavior of ExecuteAndWait with a non-zero timeout.
llvm-svn: 209951
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/Support/ProgramTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ProgramTest.cpp b/llvm/unittests/Support/ProgramTest.cpp
index 800df14234d..d8cb42af03e 100644
--- a/llvm/unittests/Support/ProgramTest.cpp
+++ b/llvm/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 };
OpenPOWER on IntegriCloud