mirror of
https://github.com/reactos/CMake.git
synced 2025-02-26 15:05:34 +00:00
CTest: Fix timeout when grandchild keeps pipes open
When a test's process creates its own child and exits, the grandchild may keep pipes open. Fix CTest logic to correctly timeout if the grandchild does not exit and close the pipes before the timeout expires. This was broken by commit b5e21d7d2e (CTest: Re-implement test process handling using libuv, 2017-12-10, v3.11.0-rc1~117^2) which added an unnecessary condition to the timeout handling. Fixes: #20116
This commit is contained in:
parent
2f5eb1800b
commit
d1976cd1f2
@ -278,9 +278,6 @@ void cmProcess::OnTimeoutCB(uv_timer_t* timer)
|
||||
|
||||
void cmProcess::OnTimeout()
|
||||
{
|
||||
if (this->ProcessState != cmProcess::State::Executing) {
|
||||
return;
|
||||
}
|
||||
this->ProcessState = cmProcess::State::Expired;
|
||||
bool const was_still_reading = !this->ReadHandleClosed;
|
||||
if (!this->ReadHandleClosed) {
|
||||
|
6
Tests/RunCMake/CTestTimeout/Fork-stdout.txt
Normal file
6
Tests/RunCMake/CTestTimeout/Fork-stdout.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Test project [^
|
||||
]*/Tests/RunCMake/CTestTimeout/Fork-build
|
||||
Start 1: TestTimeout
|
||||
1/1 Test #1: TestTimeout ......................\*\*\*Timeout +[0-9.]+ sec
|
||||
+
|
||||
0% tests passed, 1 tests failed out of 1
|
@ -12,3 +12,11 @@ function(run_ctest_timeout CASE_NAME)
|
||||
endfunction()
|
||||
|
||||
run_ctest_timeout(Basic)
|
||||
|
||||
if(UNIX)
|
||||
string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[
|
||||
target_compile_definitions(TestTimeout PRIVATE FORK)
|
||||
]])
|
||||
run_ctest_timeout(Fork)
|
||||
unset(CASE_CMAKELISTS_SUFFIX_CODE)
|
||||
endif()
|
||||
|
@ -8,6 +8,13 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#ifdef FORK
|
||||
pid_t pid = fork();
|
||||
if (pid != 0) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
Sleep((TIMEOUT + 4) * 1000);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user