diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp index 68b5e0deb4c29f3c8f5ed70bc527ceac927a3d3c..728845ac4420275bfac8d90c4fe2eb0fc0ae049b 100644 --- a/tests/mpi_test_main.cpp +++ b/tests/mpi_test_main.cpp @@ -28,7 +28,16 @@ main(int argc, char* argv[]) parallel::Messenger::create(argc, argv); const int nb_max_threads = std::max(std::thread::hardware_concurrency(), 1u); - const int nb_threads = std::max(nb_max_threads / parallel::Messenger::getInstance().size(), 1ul); + int nb_threads = std::max(nb_max_threads / parallel::Messenger::getInstance().size(), 1ul); + + Catch::Session session; + + auto cli = session.cli() | Catch::Clara::Opt(nb_threads, "number of threads")["--threads"]( + "number of threads (default: max logical threads)"); + + session.cli(cli); + + int result = session.applyCommandLine(argc, argv); { Kokkos::InitializationSettings args; @@ -54,9 +63,6 @@ main(int argc, char* argv[]) } }(); - Catch::Session session; - int result = session.applyCommandLine(argc, argv); - // disable file locking to avoid mess in tests setenv("HDF5_USE_FILE_LOCKING", "FALSE", 1); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index fe5e8eea36d3973e17691a180bad2fd2f5820dcb..84b15f7585ab6abe69e6f0a9fb02688b18802e85 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -23,7 +23,16 @@ int main(int argc, char* argv[]) { parallel::Messenger::create(argc, argv); - const int nb_threads = std::max(std::thread::hardware_concurrency() / 2, 1u); + int nb_threads = std::max(std::thread::hardware_concurrency() / 2, 1u); + + Catch::Session session; + + auto cli = session.cli() | Catch::Clara::Opt(nb_threads, "number of threads")["--threads"]( + "number of threads (default: max logical threads)"); + + session.cli(cli); + + int result = session.applyCommandLine(argc, argv); { Kokkos::InitializationSettings args; @@ -40,9 +49,6 @@ main(int argc, char* argv[]) PETScWrapper::initialize(argc, argv); SLEPcWrapper::initialize(argc, argv); - Catch::Session session; - int result = session.applyCommandLine(argc, argv); - if (result == 0) { const auto& config = session.config(); if (config.listReporters() or config.listTags() or config.listTests()) {