diff options
author | Brad King <brad.king@kitware.com> | 2017-12-11 15:40:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-12-11 15:41:48 (GMT) |
commit | ba6caafa42afb7fa2c7d8d0d49c73d79efee1e9c (patch) | |
tree | 22dfb46aa85283b6648199c4379289df06514cd7 /Source/CTest | |
parent | 548e8f6ffedb57fcdee56633ba454ae0ddf38983 (diff) | |
download | CMake-ba6caafa42afb7fa2c7d8d0d49c73d79efee1e9c.zip CMake-ba6caafa42afb7fa2c7d8d0d49c73d79efee1e9c.tar.gz CMake-ba6caafa42afb7fa2c7d8d0d49c73d79efee1e9c.tar.bz2 |
CTest: Use integer-representable value for "infinite" timeout
Refactoring in commit 66419bc046 (CTest: convert timeouts to
std::chrono::duration, 2017-11-20) changed out "infinite" timeout to a
value not representable by a 64-bit integer. This causes undefined
behavior when e.g. KWSys Process converts the duration to a `long` to
interact with system APIs. Use the old `1.0e7` maximum value.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 8 | ||||
-rw-r--r-- | Source/CTest/cmCTestScriptHandler.cxx | 11 |
2 files changed, 4 insertions, 15 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index c76eb4e..dcb17d0 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -1,9 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifdef _WIN32 -/* windows.h defines min() and max() macros that interfere. */ -#define NOMINMAX -#endif #include "cmCTestRunTest.h" #include "cmCTest.h" @@ -678,7 +674,7 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut, // determine how much time we have std::chrono::duration<double> timeout = this->CTest->GetRemainingTimeAllowed(); - if (timeout != std::chrono::duration<double>::max()) { + if (timeout != cmCTest::MaxDuration()) { timeout -= std::chrono::minutes(2); } if (this->CTest->GetTimeOut() > std::chrono::duration<double>::zero() && @@ -702,7 +698,7 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut, this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " << "Test timeout computed to be: " - << (timeout == std::chrono::duration<double>::max() + << (timeout == cmCTest::MaxDuration() ? std::string("infinite") : std::to_string( std::chrono::duration_cast<std::chrono::seconds>(timeout) diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 922f5c7..716ea10 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -1,12 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ - -#ifdef _WIN32 -/* windows.h defines min() and max() macros, unless told to otherwise. This - * interferes with std::min() and std::max() at the very least. */ -#define NOMINMAX -#endif - #include "cmCTestScriptHandler.h" #include "cmsys/Directory.hxx" @@ -970,13 +963,13 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( std::chrono::duration<double> cmCTestScriptHandler::GetRemainingTimeAllowed() { if (!this->Makefile) { - return std::chrono::duration<double>::max(); + return cmCTest::MaxDuration(); } const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT"); if (!timelimitS) { - return std::chrono::duration<double>::max(); + return cmCTest::MaxDuration(); } auto timelimit = std::chrono::duration<double>(atof(timelimitS)); |