From 3e43ca7c2a29c8ffbddd394e56d10c4b304a3890 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Sun, 7 Jul 2024 22:50:41 +0100 Subject: [PATCH] make running of CUDA tests optional CUDA run-time is not available on GitHub actions, so we need to able to disable them. --- src/recon_test/test_priors.cxx | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/recon_test/test_priors.cxx b/src/recon_test/test_priors.cxx index 4b8788cb2..0f7cbd2b3 100644 --- a/src/recon_test/test_priors.cxx +++ b/src/recon_test/test_priors.cxx @@ -602,6 +602,27 @@ USING_NAMESPACE_STIR int main(int argc, char** argv) { + // option processing + bool do_cuda_tests = true; + while (argc > 1 && strncmp(argv[1], "--", 2) == 0) + { + if (strcmp(argv[1], "--help") == 0) + { + std::cerr << "Usage:\n" + << " test_priors [--skip-cuda] [image_filename]\n"; + exit(EXIT_SUCCESS); + } + else if (strcmp(argv[1], "--skip-cuda") == 0) + do_cuda_tests = false; + else + { + std::cerr << "Unknown option: " << argv[1] << "\nUse --help for more information\n"; + exit(EXIT_FAILURE); + } + --argc; + ++argv; + } + set_default_num_threads(); bool everything_ok = true; @@ -617,11 +638,12 @@ main(int argc, char** argv) everything_ok = everything_ok && tests.is_everything_ok(); } #ifdef STIR_WITH_CUDA - { - RelativeDifferencePriorTests> tests(argc > 1 ? argv[1] : nullptr); - tests.run_tests(); - everything_ok = everything_ok && tests.is_everything_ok(); - } + if (do_cuda_tests) + { + RelativeDifferencePriorTests> tests(argc > 1 ? argv[1] : nullptr); + tests.run_tests(); + everything_ok = everything_ok && tests.is_everything_ok(); + } #endif { PLSPriorTests tests(argc > 1 ? argv[1] : nullptr);