# ctest 3.16 - tests don't timeout if there are remaining subprocesses

**URL:** https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493
**Category:** Usage
**Created:** [January 7, 2021, 5:48pm UTC](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493 "2021-01-07T17:48:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Marc\_Legendre](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marc_legendre/32/1078_2.png) [@Marc\_Legendre](https://discourse.cmake.org/u/Marc_Legendre)
#### Post date: [January 7, 2021, 5:48pm UTC](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493/1 "2021-01-07T17:48:45Z")

</div>

Hi there,

I noticed that ctest 3.16 fails to timeout tests if their main process has terminated, but there are still subprocesses running. (NB : Ubuntu 20.04 ships cmake 3.16.3)

For example, here is a test script that starts a subprocess (in the background), and terminates immediately :

```
#!/bin/bash
sleep 10&

```

And here is a `CMakeLists.txt` that adds a test named `repro` :

```
cmake_minimum_required(VERSION 3.12)
project(repro)

include(CTest)
enable_testing()

add_test(NAME repro COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)
set_tests_properties(repro PROPERTIES TIMEOUT 5)

```

Then if we run the test with ctest 3.16, we can see it does not timeout :

```
$ mkdir build && cd build && cmake ..
$ ctest --verbose
[...]
test 1
    Start 1: repro

1: Test timeout computed to be: 5
1/1 Test #1: repro ............................ Passed 0.00 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) = 10.01 sec

```

Whereas with more recent versions of cmake, it does timeout properly:

```
$ ctest --verbose
[...]
1: Test timeout computed to be: 5
1/1 Test #1: repro ............................***Timeout 5.01 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 5.01 sec

The following tests FAILED:
          1 - repro (Timeout)
Errors while running CTest

```

More precisely,

- I could reproduce the issue with cmake 3.16.3 (the version shipped with Ubuntu 20.04), and 3.16.9 (the latest patch version)
- I could not reproduce the issue with cmake 3.17.5, 3.18.3, or 3.19.2
- I couldn’t find anything seemingly related in the release notes of 3.17

Should I open an issue on gitlab ? (3.16 is kinda old, I don’t know if it is maintained.)

Anyway, I thought I’d share the information.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 7, 2021, 6:09pm UTC](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493/2 "2021-01-07T18:09:45Z")

</div>

This probably coincides with the kwsys -\> libuv process management transition. Not sure what to do about it as it seems that 3.17+'s behavior makes more sense to me.

Cc: @brad.king

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [January 7, 2021, 6:22pm UTC](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493/3 "2021-01-07T18:22:32Z")

</div>

This was indeed fixed in [!4217](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4217), which was first present in 3.17.0.

We are not providing any further updates to the 3.16 branch. Since you’re using Ubuntu, I would suggest using the newer builds from our [APT repository](https://apt.kitware.com/).

---

<div class="post-metadata">

### Author: ![Marc\_Legendre](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marc_legendre/32/1078_2.png) [@Marc\_Legendre](https://discourse.cmake.org/u/Marc_Legendre)
#### Post date: [January 8, 2021, 10:38am UTC](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493/4 "2021-01-08T10:38:54Z")

</div>

(Ha! I check open issues, but not closed ones…)

Thank you very much for your replies. We’ll use a more recent version of cmake.
