# Find non-terminated tests with ctest -j

**URL:** https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389
**Category:** Usage
**Tags:** tool:ctest
**Created:** [November 8, 2023, 2:16pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389 "2023-11-08T14:16:22Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [November 8, 2023, 2:16pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/1 "2023-11-08T14:16:22Z")

</div>

Sometimes some test under ctest does not (or not timely) terminate. When running with `-j` and a high number of tasks it is very hard to figure out which test has not ended yet. On Linux we have a decent `ps` or `pstree`, but on e.g., Windows it seems rather hard to find the test processes and how they are called and thus it is hard to find the stalled test.

Would it be possible to print the tests it cancels when you stop `ctest` using Control-C? I.e. something like this:

```auto
> ctest -j 16
....
^C
Interrupted tests:
   mytest1 (running for 530 sec)
   mytest7 (running for 10 sec)
   ...
>

```

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [November 8, 2023, 11:28pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/2 "2023-11-08T23:28:45Z")

</div>

> [@JanWielemaker](#):
>
> but on e.g., Windows it seems rather hard to find the test processes and how they are called

I suggest to use Sysinternals Process Explorer. On command line their `pslist` may help.

---

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [November 9, 2023, 4:02pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/3 "2023-11-09T16:02:22Z")

</div>

> [@jtxa](#):
>
> I suggest to use Sysinternals Process Explorer. On command line their `pslist` may help.

Thanks. At least that helps. I’m not much of a Windows developer 🙂

Still, I think feedback from ctest is not hard to implement and will simplify this problem for everybody.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [November 13, 2023, 3:42pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/4 "2023-11-13T15:42:58Z")

</div>

I think this could be a nice use case as well. Does this involve how libuv is used (?) to manage the parallel test runs?

---

<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: [November 17, 2023, 1:54pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/5 "2023-11-17T13:54:35Z")

</div>

Cc: @kyle.edwards

---

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [May 31, 2024, 3:22pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/6 "2024-05-31T15:22:47Z")

</div>

Any news on this? Locally one can finds a way out, but today I was faced with a hanging test in Github CI. So, I copied the failed test report, ran this to get a sorted list of finished tests. That allowed me to spot test `#81` did not complete …

```
 grep Passed ci.txt | sed 's/^.*#\([0-9]*\).*/\1/' | sort -n

```

How do people deal with this? Setting fairly short test timeouts is of course an option, but if tests are executed from fairly fast hardware to slow emulators, it is hard to find a sensible limit.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [June 2, 2024, 1:53pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/7 "2024-06-02T13:53:13Z")

</div>

My opinion is that this should be a feature request (in CMake Gitlab project). I think CMake’s internals using libuv from CTest would allow this message of which processes were still running. Not trivial, but seems doable possibly.

---

<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: [June 8, 2024, 2:47am UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/8 "2024-06-08T02:47:37Z")

</div>

What would trigger the printing of such a report? `SIGUSR1` or something would work, but that doesn’t help CI. Maybe we wait for some special signal that CI systems send when tearing down due to a timeout? Is there even such a thing, nevermind consistency about it?

---

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [August 29, 2024, 7:01am UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/9 "2024-08-29T07:01:37Z")

</div>

> [@ben.boeckel](#):
>
> What would trigger the printing of such a report?

I was thinking about the termination signal, be it SIGINT (for terminal) or SIGTERM (I guess most CIs will use that if the time limit is exceeded?)

---

<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: [July 21, 2025, 12:13am UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/10 "2025-07-21T00:13:34Z")

</div>

I think a survey is needed. Note that once a timeout is reached, the CI tooling may also just ignore any further output as well.

---

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [July 24, 2025, 1:02pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/11 "2025-07-24T13:02:49Z")

</div>

CI is one case. If the environment stops reading, all bets are off. Just interactive use is the other. I run using `-j 16` and if one hangs it is quite some work to find out which one.

---

<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: [July 24, 2025, 1:55pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/12 "2025-07-24T13:55:50Z")

</div>

I wonder if we could react to `SIGUSR1` to do some kind of reporting on the current execution status (not unlike `dd`’s progress reporting on signals).

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [July 25, 2025, 2:24am UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/13 "2025-07-25T02:24:10Z")

</div>

You have a problem, you need to respond to an asynchronous IPC event. You decide to use UNIX signals. Now you have two problems.

---

<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: [July 25, 2025, 1:02pm UTC](https://discourse.cmake.org/t/find-non-terminated-tests-with-ctest-j/9389/14 "2025-07-25T13:02:12Z")

</div>

Seeing as the IPC event is itself a signal…
