3

We have over 10 Google Test executables which, in sum, provide over 5000 test cases.

So far, our CTest configuration used add_test command which resulted in each test executable being a single test from CTest point of view.

Recently, we used the GoogleTest module to replace the add_test command with the gtest_discover_tests command. This way all individual test cases are now visible to CTest. Now each of those over 5000 test cases is a separate test in CTest.

This worked quite nice enhancing parallel runs (a strong machine runs far more test cases than we have test executables) and allowing us to use CTest command-line interface to filter test cases etc. abstracting away the testing framework used.

However, we hit a major blocker for Valgrind runs! Now each individual test case is run separately, causing the Valgrind machinery to be set up and tear down over 5000 times. The time whooped from around 10 minutes for the full suite to almost 2 hours which is unacceptable.

Now, I'm wondering whether there is any way to make the CTest run tests in batches from the same executable by invoking the executable only once. We would do this for Valgrind runs but not the ordinary runs. I'm afraid there is no way, especially that it would probably require the GoogleTest module to somehow explain how to do it. But maybe someone already had a similar issue and solved it somehow?


I know a workaround would be to skip CTest for Valgrind runs. Just take the test executables and run them "manually" under Valgrind. Doable, probably also in an automated way (so the list of test executables is somehow "queried", perhaps with the --show-only argument to ctest, rather than hardcoded). But it makes the interface (command line, output, etc.) less consistent.

Adam Badura
  • 5,069
  • 1
  • 35
  • 70
  • Did you ever find an answer to this? – Kevin Jul 06 '21 at 23:21
  • @Kevin, no, we didn't. I was considering adding Valgrind-based tests as separate `add_test` calls. Probably also label them (from CTest point of view). But I never got into this since we uncovered some issues in the GoogleTest CMake module in this area that prevented us from using it anyway. I hope to fix them at some point but never got time to do it so far. – Adam Badura Jul 07 '21 at 12:03

0 Answers0