Test TIMEOUT property explicitly set to zero should be honored

This commit is contained in:
Zach Mullen 2011-01-03 14:41:25 -05:00
parent edff9207ed
commit 51bb493574
9 changed files with 101 additions and 28 deletions

View File

@ -455,7 +455,8 @@ bool cmCTestRunTest::StartTest(size_t total)
{ {
return false; return false;
} }
return this->ForkProcess(timeout, &this->TestProperties->Environment); return this->ForkProcess(timeout, this->TestProperties->ExplicitTimeout,
&this->TestProperties->Environment);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -598,7 +599,7 @@ double cmCTestRunTest::ResolveTimeout()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool cmCTestRunTest::ForkProcess(double testTimeOut, bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
std::vector<std::string>* environment) std::vector<std::string>* environment)
{ {
this->TestProcess = new cmProcess; this->TestProcess = new cmProcess;
@ -619,12 +620,16 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut,
{ {
timeout = testTimeOut; timeout = testTimeOut;
} }
// always have at least 1 second if we got to here // always have at least 1 second if we got to here
if (timeout <= 0) if (timeout <= 0)
{ {
timeout = 1; timeout = 1;
} }
// handle timeout explicitly set to 0
if (testTimeOut == 0 && explicitTimeout)
{
timeout = 0;
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
<< "Test timeout computed to be: " << timeout << "\n"); << "Test timeout computed to be: " << timeout << "\n");

View File

@ -63,8 +63,8 @@ private:
void ExeNotFound(std::string exe); void ExeNotFound(std::string exe);
// Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT) // Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT)
double ResolveTimeout(); double ResolveTimeout();
bool ForkProcess(double testTimeOut, bool ForkProcess(double testTimeOut, bool explicitTimeout,
std::vector<std::string>* environment); std::vector<std::string>* environment);
void WriteLogOutputTop(size_t completed, size_t total); void WriteLogOutputTop(size_t completed, size_t total);
//Run post processing of the process output for MemCheck //Run post processing of the process output for MemCheck
void MemCheckPostProcess(); void MemCheckPostProcess();

View File

@ -2122,6 +2122,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "TIMEOUT" ) if ( key == "TIMEOUT" )
{ {
rtit->Timeout = atof(val.c_str()); rtit->Timeout = atof(val.c_str());
rtit->ExplicitTimeout = true;
} }
if ( key == "COST" ) if ( key == "COST" )
{ {
@ -2295,6 +2296,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.WillFail = false; test.WillFail = false;
test.RunSerial = false; test.RunSerial = false;
test.Timeout = 0; test.Timeout = 0;
test.ExplicitTimeout = false;
test.Cost = 0; test.Cost = 0;
test.Processors = 1; test.Processors = 1;
test.PreviousRuns = 0; test.PreviousRuns = 0;

View File

@ -99,6 +99,7 @@ public:
int PreviousRuns; int PreviousRuns;
bool RunSerial; bool RunSerial;
double Timeout; double Timeout;
bool ExplicitTimeout;
int Index; int Index;
//Requested number of process slots //Requested number of process slots
int Processors; int Processors;

View File

@ -1432,6 +1432,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES
PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed")
CONFIGURE_FILE(
"${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake"
@ONLY ESCAPE_QUOTES)
ADD_TEST(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V
--output-log
"${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log")
SET_TESTS_PROPERTIES(CTestTestZeroTimeout PROPERTIES
FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout")
CONFIGURE_FILE( CONFIGURE_FILE(
"${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in" "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"

View File

@ -0,0 +1,8 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT (CTestTestZeroTimeout)
INCLUDE (CTest)
ADD_EXECUTABLE (Sleep sleep.c)
ADD_TEST (TestExplicitZeroTimeout Sleep)
SET_TESTS_PROPERTIES(TestExplicitZeroTimeout PROPERTIES TIMEOUT 0)

View File

@ -0,0 +1,7 @@
set(CTEST_PROJECT_NAME "CTestTestZeroTimeout")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "www.cdash.org")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard")
set(CTEST_DROP_SITE_CDASH TRUE)

View File

@ -0,0 +1,16 @@
#if defined(_WIN32)
# include <windows.h>
#else
# include <unistd.h>
#endif
/* sleeps for 5 seconds */
int main(int argc, char** argv)
{
#if defined(_WIN32)
Sleep(5000);
#else
sleep(5);
#endif
return 0;
}

View File

@ -0,0 +1,23 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.1)
# Settings:
SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest")
SET(CTEST_SITE "@SITE@")
SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ZeroTimeout")
SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestZeroTimeout")
SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestZeroTimeout")
SET(CTEST_CVS_COMMAND "@CVSCOMMAND@")
SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@")
SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@")
SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@")
SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
SET(CTEST_TEST_TIMEOUT 2)
CTEST_START(Experimental)
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)