summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2010-03-16 19:33:55 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2010-03-17 15:04:13 (GMT)
commit0ba9d041174f593509c44f84e0e70fafc6c0edc0 (patch)
treee14112a165cafec052faf1846d97a47acdb612b9 /Source/CTest
parentbd0b37ea3d5733d087b1498a20e2b87d7f537a9f (diff)
downloadCMake-0ba9d041174f593509c44f84e0e70fafc6c0edc0.zip
CMake-0ba9d041174f593509c44f84e0e70fafc6c0edc0.tar.gz
CMake-0ba9d041174f593509c44f84e0e70fafc6c0edc0.tar.bz2
Add the --stop-time argument
Unit test and script hook for STOP_TIME
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestRunTest.cxx54
-rw-r--r--Source/CTest/cmCTestRunTest.h4
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx5
-rw-r--r--Source/CTest/cmCTestTestCommand.h7
4 files changed, 65 insertions, 5 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 659cb73..94ccffe 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -14,6 +14,7 @@
#include "cmCTestMemCheckHandler.h"
#include "cmCTest.h"
#include "cmSystemTools.h"
+#include "cm_curl.h"
#include <cm_zlib.h>
#include <cmsys/Base64.h>
@@ -441,7 +442,7 @@ bool cmCTestRunTest::StartTest(size_t total)
}
this->StartTime = this->CTest->CurrentTime();
- return this->CreateProcess(this->TestProperties->Timeout,
+ return this->ForkProcess(this->ResolveTimeout(),
&this->TestProperties->Environment);
}
@@ -518,7 +519,56 @@ void cmCTestRunTest::DartProcessing()
}
//----------------------------------------------------------------------
-bool cmCTestRunTest::CreateProcess(double testTimeOut,
+double cmCTestRunTest::ResolveTimeout()
+{
+ double timeout = this->TestProperties->Timeout;
+
+ if(this->CTest->GetStopTime() == "")
+ {
+ return timeout;
+ }
+ struct tm* lctime;
+ time_t current_time = time(0);
+ lctime = gmtime(&current_time);
+ int gm_hour = lctime->tm_hour;
+ lctime = localtime(&current_time);
+ int local_hour = lctime->tm_hour;
+
+ int timezone = (local_hour - gm_hour) * 100;
+ char buf[1024];
+ // add todays year day and month to the time in str because
+ // curl_getdate no longer assumes the day is today
+ sprintf(buf, "%d%02d%02d %s %+05i",
+ lctime->tm_year + 1900,
+ lctime->tm_mon + 1,
+ lctime->tm_mday,
+ this->CTest->GetStopTime().c_str(),
+ timezone);
+
+ time_t stop_time = curl_getdate(buf, &current_time);
+ if(stop_time == -1)
+ {
+ return timeout;
+ }
+
+ //the stop time refers to the next day
+ if(this->CTest->NextDayStopTime)
+ {
+ stop_time += 24*60*60;
+ }
+ double stop_timeout = stop_time - current_time;
+
+ if(stop_timeout <= 0)
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
+ "Exiting ctest." << std::endl);
+ exit(-1);
+ }
+ return timeout == 0 ? stop_timeout : min(timeout, stop_timeout);
+}
+
+//----------------------------------------------------------------------
+bool cmCTestRunTest::ForkProcess(double testTimeOut,
std::vector<std::string>* environment)
{
this->TestProcess = new cmProcess;
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index 1e4c1cc..14fa2e5 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -59,7 +59,9 @@ public:
private:
void DartProcessing();
void ExeNotFound(std::string exe);
- bool CreateProcess(double testTimeOut,
+ // Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT)
+ double ResolveTimeout();
+ bool ForkProcess(double testTimeOut,
std::vector<std::string>* environment);
void WriteLogOutputTop(size_t completed, size_t total);
//Run post processing of the process output for MemCheck
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index b0adf22..5aee035 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -25,6 +25,7 @@ cmCTestTestCommand::cmCTestTestCommand()
this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL";
this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL";
this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM";
+ this->Arguments[ctt_STOP_TIME] = "STOP_TIME";
this->Arguments[ctt_LAST] = 0;
this->Last = ctt_LAST;
}
@@ -98,6 +99,10 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
handler->SetOption("ScheduleRandom",
this->Values[ctt_SCHEDULE_RANDOM]);
}
+ if(this->Values[ctt_STOP_TIME])
+ {
+ this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
+ }
return handler;
}
diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h
index 12314df..c6fd631 100644
--- a/Source/CTest/cmCTestTestCommand.h
+++ b/Source/CTest/cmCTestTestCommand.h
@@ -62,7 +62,8 @@ public:
" [EXCLUDE_LABEL exclude regex] \n"
" [INCLUDE_LABEL label regex] \n"
" [PARALLEL_LEVEL level] \n"
- " [SCHEDULE_RANDOM on]) \n"
+ " [SCHEDULE_RANDOM on] \n"
+ " [STOP_TIME time of day]) \n"
"Tests the given build directory and stores results in Test.xml. The "
"second argument is a variable that will hold value. Optionally, "
"you can specify the starting test number START, the ending test number "
@@ -73,7 +74,8 @@ public:
"property LABEL. PARALLEL_LEVEL should be set to a positive number "
"representing the number of tests to be run in parallel. "
"SCHEDULE_RANDOM will launch tests in a random order, and is "
- "typically used to detect implicit test dependencies."
+ "typically used to detect implicit test dependencies. STOP_TIME is the "
+ "time of day at which the tests should all stop running."
"\n"
CTEST_COMMAND_APPEND_OPTION_DOCS;
}
@@ -96,6 +98,7 @@ protected:
ctt_INCLUDE_LABEL,
ctt_PARALLEL_LEVEL,
ctt_SCHEDULE_RANDOM,
+ ctt_STOP_TIME,
ctt_LAST
};
};