Exporting a CTest Project


I have the following use case:

  • Multiarch product (x64, arm64)
  • Testcases that need to run on real arch cpus (QEMU fails)
  • arm cpus are sparse

Therefore we build both on x64 with cross compiler. We execute the x64 unit tests directly and the arm64 ones later in a separate step.
We duplicate all add_test()/ set_tests_properties() settings into a skript that runs on arm64.

We would like to remove that duplication. We could build on arm64, but as I said, we are limited in machines there.

Therefore I want to know if there is a way to export the CMake or CTest configuration to run VTest on the other machine? CMake generated files generally contain absolute paths, so this is not possible (can it be set to use relative paths?) But looking at the CTestTestfile.cmake files, it looks like they are relative (subdirs(…)).
What would I need for the to CTest-Export to work:

  • **/CTestTestfile.cmake
  • other CMake generated files for CTest?
  • all so/executable files (gladly they are all in one dir as we use CMAKE_RUNTIME_OUTPUT_DIRECTORY etc.)
  • Other test resources (like xml files that are parsed during test)

I have had a deeper look into the CTestTestfile.cmake files.

The test executable is full path and not relative :frowning:
The properties e.g. ENVIRONMENT, WORKING_DIRECTORY is also full path. However, that is probably the users fault.
There also is _BACKTRACE_TRIPLES with full path to some CMakeLists.txt. This looks like some kind of internal property What is that?

Any Ideas how to solve my use case?

The solution:
ctest [OPTIONS] --show-only=json-v1

It exports all properties (but not _BACKTRACE_TRIPLES) in a way I can read it back. Many paths are still absolute, but I can work around this.

Another solution is to have a project that runs the test suite given an installed package. For example, see this project which runs VTK’s test suite given a find_package(VTK).