From ce30db70882196a5dec5bb7dd4dbdc658250b027 Mon Sep 17 00:00:00 2001 From: Piotr Konopka Date: Fri, 13 Nov 2026 11:43:01 +0100 Subject: [PATCH] Complete boost test to catch2 migration in Framework and common Modules This commit transitions the remaining boost tests into catch2, so we finally use only one testing framework instead of two. We also gain some speedups in test execution, mainly thanks to combining test source files into two main executables, speaking of... I split the framework tests into two executables to preserve the current behaviour, which is being able to exclude CCDB-labelled tests on the level of ctest (from alidist): - `o2-qc-test-core` - `o2-qc-test-ccdb` This being said, I saw that not all tests which require CCDD were labelled as such - should we fix that? For now, I added catch2 tags to such test cases, but they will not be excluded when running: ``` ctest --output-on-failure -LE (CCDB)|(manual) ``` ...which, again, preserves the current behaviour. Assisted by Claude Sonnet/Opus 5.5 --- Framework/CMakeLists.txt | 76 +++---- Framework/test/testCcdbDatabase.cxx | 208 ++++++++++-------- Framework/test/testCcdbDatabaseExtra.cxx | 43 ++-- .../test/testCcdbDatabaseListingErrors.cxx | 19 +- Framework/test/testDbFactory.cxx | 41 ++-- Framework/test/testObjectsManager.cxx | 117 +++++----- Framework/test/testPostProcessingConfig.cxx | 36 ++- .../test/testPostProcessingInterface.cxx | 25 +-- Framework/test/testPublisher.cxx | 14 +- Framework/test/testQcInfoLogger.cxx | 21 +- Framework/test/testReductor.cxx | 60 +++-- Framework/test/testRepoPathUtils.cxx | 37 ++-- Framework/test/testRunnerUtils.cxx | 22 +- Framework/test/testTaskInterface.cxx | 2 +- Framework/test/testTaskRunner.cxx | 56 ++--- Framework/test/testTrendingTask.cxx | 2 +- Framework/test/testTriggerHelpers.cxx | 2 +- Framework/test/testTriggers.cxx | 134 ++++++----- Framework/test/testUserCodeInterface.cxx | 46 ++-- Modules/Benchmark/CMakeLists.txt | 21 +- Modules/Benchmark/test/testQcBenchmark.cxx | 9 +- Modules/Common/CMakeLists.txt | 30 +-- Modules/Common/test/testCommonHistRatios.cxx | 137 ++++++------ Modules/Common/test/testCommonReductors.cxx | 71 +++--- Modules/Common/test/testMeanIsAbove.cxx | 22 +- Modules/Common/test/testNonEmpty.cxx | 26 +-- .../Common/test/testWorstOfAllAggregator.cxx | 48 ++-- Modules/Daq/CMakeLists.txt | 20 +- Modules/Daq/test/testQcDaq.cxx | 12 +- Modules/Example/CMakeLists.txt | 26 +-- Modules/Example/test/testFactory.cxx | 20 +- Modules/Example/test/testQcExample.cxx | 17 +- Modules/Skeleton/.CMakeListsEmpty.txt | 20 +- Modules/Skeleton/CMakeLists.txt | 20 +- Modules/Skeleton/test/.testEmpty.cxx | 9 +- Modules/Skeleton/test/testQcSkeleton.cxx | 11 +- Modules/o2-qc-module-configurator.sh | 1 + 37 files changed, 691 insertions(+), 790 deletions(-) diff --git a/Framework/CMakeLists.txt b/Framework/CMakeLists.txt index b52a705cac..7b44d9ac37 100644 --- a/Framework/CMakeLists.txt +++ b/Framework/CMakeLists.txt @@ -307,6 +307,17 @@ add_executable(o2-qc-test-core test/testQCInputs.cxx test/testUserInputOutput.cxx test/testStringUtils.cxx + test/testPublisher.cxx + test/testQcInfoLogger.cxx + test/testTaskRunner.cxx + test/testObjectsManager.cxx + test/testCcdbDatabaseListingErrors.cxx + test/testTriggers.cxx + test/testPostProcessingInterface.cxx + test/testPostProcessingConfig.cxx + test/testReductor.cxx + test/testRepoPathUtils.cxx + test/testRunnerUtils.cxx ) set_property(TARGET o2-qc-test-core PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) @@ -315,56 +326,41 @@ target_link_libraries(o2-qc-test-core PRIVATE O2::EMCALBase O2::EMCALCalib) target_include_directories(o2-qc-test-core PRIVATE ${CMAKE_SOURCE_DIR}) add_test(NAME o2-qc-test-core COMMAND o2-qc-test-core) -set_tests_properties(o2-qc-test-core PROPERTIES TIMEOUT 30) +set_tests_properties(o2-qc-test-core PROPERTIES TIMEOUT 60) target_sources(o2-qc-test-core PRIVATE ${CMAKE_BINARY_DIR}/getTestDataDirectory.cxx) target_include_directories(o2-qc-test-core PRIVATE ${CMAKE_SOURCE_DIR}) target_include_directories(o2-qc-test-core PRIVATE $) +# Tests which require access to CCDB, they are in a separate executable to allow excluding them with `ctest -LE CCDB`. +# Test cases tagged with [.manual] are hidden, thus they are not run by default and have to be requested explicitly. +add_executable(o2-qc-test-ccdb + test/testCcdbDatabase.cxx + test/testCcdbDatabaseExtra.cxx + test/testDbFactory.cxx + test/testUserCodeInterface.cxx +) +set_property(TARGET o2-qc-test-ccdb + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +target_link_libraries(o2-qc-test-ccdb PRIVATE O2QualityControl O2::Catch2) +target_include_directories(o2-qc-test-ccdb PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(o2-qc-test-ccdb PRIVATE $) + +add_test(NAME o2-qc-test-ccdb COMMAND o2-qc-test-ccdb) +set_tests_properties(o2-qc-test-ccdb PROPERTIES TIMEOUT 60 LABELS "slow;CCDB") + set(TEST_SRCS test/testActorCallbacks.cxx - test/testDbFactory.cxx - test/testPublisher.cxx - test/testQcInfoLogger.cxx - test/testTaskRunner.cxx - test/testObjectsManager.cxx - test/testCcdbDatabase.cxx - test/testCcdbDatabaseListingErrors.cxx - test/testCcdbDatabaseExtra.cxx - test/testTriggers.cxx - test/testPostProcessingInterface.cxx - test/testPostProcessingConfig.cxx - test/testReductor.cxx test/testCheckWorkflow.cxx test/testWorkflow.cxx - test/testRepoPathUtils.cxx - test/testUserCodeInterface.cxx - test/testRunnerUtils.cxx test/testBookkeepingQualitySink.cxx ) set(TEST_ARGS "-b --run" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" "-b --run" "-b --run" "" - "" - "" - "" - "" - "" ) list(LENGTH TEST_SRCS count) @@ -381,33 +377,23 @@ foreach(i RANGE ${count}) set_property(TARGET ${test_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) target_link_libraries(${test_name} - PRIVATE O2QualityControl Boost::unit_test_framework) + PRIVATE O2QualityControl) add_test(NAME ${test_name} COMMAND ${test_name} ${arg}) set_tests_properties(${test_name} PROPERTIES TIMEOUT 30) endforeach() -foreach(t testWorkflow testTaskRunner testCheckWorkflow - testPostProcessingConfig testPostProcessingInterface) +foreach(t testWorkflow testCheckWorkflow) target_sources(${t} PRIVATE ${CMAKE_BINARY_DIR}/getTestDataDirectory.cxx) target_include_directories(${t} PRIVATE ${CMAKE_SOURCE_DIR}) endforeach() -target_include_directories(testCcdbDatabase PRIVATE $) - set_property(TEST testActorCallbacks PROPERTY TIMEOUT 30) set_property(TEST testActorCallbacks PROPERTY LABELS slow) set_property(TEST testWorkflow PROPERTY TIMEOUT 40) set_property(TEST testWorkflow PROPERTY LABELS slow) set_property(TEST testCheckWorkflow PROPERTY TIMEOUT 50) set_property(TEST testCheckWorkflow PROPERTY LABELS slow) -set_property(TEST testObjectsManager PROPERTY TIMEOUT 30) -set_property(TEST testObjectsManager PROPERTY LABELS slow) -set_property(TEST testCcdbDatabase PROPERTY TIMEOUT 60) -set_property(TEST testCcdbDatabase PROPERTY LABELS slow CCDB) -set_property(TEST testCcdbDatabaseExtra PROPERTY LABELS manual CCDB) -set_property(TEST testDbFactory PROPERTY LABELS CCDB) -set_property(TEST testUserCodeInterface PROPERTY LABELS CCDB) # Add a functional test (QC-336) string(RANDOM UNIQUE_ID) diff --git a/Framework/test/testCcdbDatabase.cxx b/Framework/test/testCcdbDatabase.cxx index aa6d5abd40..9e44501bae 100644 --- a/Framework/test/testCcdbDatabase.cxx +++ b/Framework/test/testCcdbDatabase.cxx @@ -20,11 +20,6 @@ #include "QualityControl/QcInfoLogger.h" #include "QualityControl/Version.h" -#define BOOST_TEST_MODULE CcdbDatabase test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include #include #include #include "QualityControl/RepoPathUtils.h" @@ -34,14 +29,16 @@ #include #include #include +#include #include #include - -namespace utf = boost::unit_test; +#include +#include namespace o2::quality_control::core { +// anonymous namespace to keep these symbols visible only to this file (instead of all files combined into o2-qc-test-ccdb) namespace { @@ -78,7 +75,7 @@ struct test_fixture { backend->connect(CCDB_ENDPOINT, "", "", ""); pid = std::to_string(getpid()); taskName = "Test/pid" + pid; - ILOG(Info, Support) << "*** " << boost::unit_test::framework::current_test_case().p_name << " (" << pid + ILOG(Info, Support) << "*** " << Catch::getResultCapture().getCurrentTestName() << " (" << pid << ") ***" << ENDM; } @@ -112,24 +109,32 @@ struct test_fixture { std::string taskName; }; -struct MyGlobalFixture { - void teardown() +// Cleans up the objects stored by the tests in this file once the whole test run is over +class CcdbDatabaseCleanupListener : public Catch::EventListenerBase +{ + public: + using Catch::EventListenerBase::EventListenerBase; + + void testRunEnded(Catch::TestRunStats const&) override { - std::unique_ptr backend = std::make_unique(); - backend->connect(CCDB_ENDPOINT, "", "", ""); - // cannot use the test_fixture because we are tearing down - backend->truncate("qc/TST/MO/Test/pid" + std::to_string(getpid()), "*"); - backend->truncate("qc/TST/QO/Test/pid" + std::to_string(getpid()), "*"); - backend->truncate("qc/TST/QCFC/Test_pid" + std::to_string(getpid()), "*"); - backend->truncate("qc_hello/TST/MO/Test/pid" + std::to_string(getpid()), "*"); - backend->truncate("qc_hello/TST/QO/Test/pid" + std::to_string(getpid()), "*"); + try { + std::unique_ptr backend = std::make_unique(); + backend->connect(CCDB_ENDPOINT, "", "", ""); + backend->truncate("qc/TST/MO/Test/pid" + std::to_string(getpid()), "*"); + backend->truncate("qc/TST/QO/Test/pid" + std::to_string(getpid()), "*"); + backend->truncate("qc/TST/QCFC/Test_pid" + std::to_string(getpid()), "*"); + backend->truncate("qc_hello/TST/MO/Test/pid" + std::to_string(getpid()), "*"); + backend->truncate("qc_hello/TST/QO/Test/pid" + std::to_string(getpid()), "*"); + } catch (...) { + } } }; -BOOST_TEST_GLOBAL_FIXTURE(MyGlobalFixture); +// NOTE: the tests below depend on the objects stored by "ccdb_store" and rely on Catch2 running the test cases +// of a file in the order of their declaration, which is true by default (argument --order=decl). long oldTimestamp; -BOOST_AUTO_TEST_CASE(ccdb_store) +TEST_CASE("ccdb_store", "[ccdb]") { test_fixture f; @@ -191,7 +196,7 @@ BOOST_AUTO_TEST_CASE(ccdb_store) f.backend->storeMO(mo3); // should fail } -BOOST_AUTO_TEST_CASE(ccdb_store_for_future_tests) +TEST_CASE("ccdb_store_for_future_tests", "[ccdb]") { // this test is storing a version of the objects in a different directory. // The goal is to keep old versions of the objects, in old formats, for future backward compatibility testing. @@ -208,94 +213,96 @@ BOOST_AUTO_TEST_CASE(ccdb_store_for_future_tests) f.backend->storeQO(qo1); } -BOOST_AUTO_TEST_CASE(ccdb_retrieve_mo, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_retrieve_mo", "[ccdb]") { test_fixture f; std::shared_ptr mo = f.backend->retrieveMO(f.getMoFolder("quarantine"), "quarantine"); - BOOST_REQUIRE_NE(mo, nullptr); - BOOST_CHECK_EQUAL(mo->getName(), "quarantine"); - BOOST_CHECK_EQUAL(mo->getActivity().mId, 1234); - BOOST_CHECK_EQUAL(mo->getActivity().mPeriodName, "LHC66"); - BOOST_CHECK_EQUAL(mo->getActivity().mPassName, "passName1"); - BOOST_CHECK_EQUAL(mo->getActivity().mProvenance, "qc"); + REQUIRE(mo != nullptr); + CHECK(mo->getName() == "quarantine"); + CHECK(mo->getActivity().mId == 1234); + CHECK(mo->getActivity().mPeriodName == "LHC66"); + CHECK(mo->getActivity().mPassName == "passName1"); + CHECK(mo->getActivity().mProvenance == "qc"); } -BOOST_AUTO_TEST_CASE(ccdb_retrieve_timestamps, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_retrieve_timestamps", "[ccdb]") { test_fixture f; std::shared_ptr mo = f.backend->retrieveMO(f.getMoFolder("short"), "short", 15000); - BOOST_REQUIRE_NE(mo, nullptr); - BOOST_CHECK_EQUAL(mo->getName(), "short"); + REQUIRE(mo != nullptr); + CHECK(mo->getName() == "short"); std::shared_ptr qo = f.backend->retrieveQO(f.getQoPath("short", "", false), 15000); - BOOST_REQUIRE_NE(qo, nullptr); - BOOST_CHECK_EQUAL(qo->getName(), f.taskName + "/short"); + REQUIRE(qo != nullptr); + CHECK(qo->getName() == f.taskName + "/short"); auto qoValidity = f.backend->getLatestObjectValidity(f.getQoPath("short", "qc", true), {}); ValidityInterval expectedValidity{ 10000, 20000 }; - BOOST_CHECK(qoValidity == expectedValidity); + CHECK(qoValidity == expectedValidity); } -BOOST_AUTO_TEST_CASE(ccdb_retrieve_inexisting_mo) +TEST_CASE("ccdb_retrieve_inexisting_mo", "[ccdb]") { test_fixture f; std::shared_ptr mo = f.backend->retrieveMO("non/existing", "object"); - BOOST_CHECK(mo == nullptr); + CHECK(mo == nullptr); } -BOOST_AUTO_TEST_CASE(ccdb_retrieve_mo_with_cycle, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_retrieve_mo_with_cycle", "[ccdb]") { test_fixture f; std::shared_ptr mo{}; mo = f.backend->retrieveMO(f.getMoFolder("cycle"), "cycle", 15000, Activity{}, { { metadata_keys::cycleNumber, "1" } }); - BOOST_REQUIRE(mo.get() != nullptr); - BOOST_REQUIRE_NO_THROW(mo->getMetadata(metadata_keys::cycleNumber)); - BOOST_REQUIRE(mo->getMetadata(metadata_keys::cycleNumber) == "1"); + REQUIRE(mo.get() != nullptr); + REQUIRE_NOTHROW(mo->getMetadata(metadata_keys::cycleNumber)); + REQUIRE(mo->getMetadata(metadata_keys::cycleNumber) == "1"); mo = f.backend->retrieveMO(f.getMoFolder("cycle"), "cycle", 15000, Activity{}, { { metadata_keys::cycleNumber, "2" } }); - BOOST_REQUIRE(mo.get() != nullptr); - BOOST_REQUIRE_NO_THROW(mo->getMetadata(metadata_keys::cycleNumber)); - BOOST_REQUIRE(mo->getMetadata(metadata_keys::cycleNumber) == "2"); + REQUIRE(mo.get() != nullptr); + REQUIRE_NOTHROW(mo->getMetadata(metadata_keys::cycleNumber)); + REQUIRE(mo->getMetadata(metadata_keys::cycleNumber) == "2"); } -BOOST_AUTO_TEST_CASE(ccdb_retrieve_qo, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_retrieve_qo", "[ccdb]") { test_fixture f; std::shared_ptr qo = f.backend->retrieveQO(RepoPathUtils::getQoPath("TST", f.taskName + "/test-ccdb-check", "", {}, "", false)); - BOOST_REQUIRE_NE(qo, nullptr); + REQUIRE(qo != nullptr); Quality q = qo->getQuality(); - BOOST_CHECK_EQUAL(q.getLevel(), 3); - BOOST_CHECK_EQUAL(qo->getActivity().mId, 1234); - BOOST_CHECK_EQUAL(qo->getActivity().mPeriodName, "LHC66"); - BOOST_CHECK_EQUAL(qo->getActivity().mPassName, "passName1"); - BOOST_CHECK_EQUAL(qo->getActivity().mProvenance, "qc"); + CHECK(q.getLevel() == 3); + CHECK(qo->getActivity().mId == 1234); + CHECK(qo->getActivity().mPeriodName == "LHC66"); + CHECK(qo->getActivity().mPassName == "passName1"); + CHECK(qo->getActivity().mProvenance == "qc"); qo = f.backend->retrieveQO(RepoPathUtils::getQoPath("TST", f.taskName + "/metadata", "", {}, "", false), repository::CcdbDatabase::Timestamp::Current, {}, { { "my_meta", "is_good" } }); - BOOST_REQUIRE_NE(qo, nullptr); - BOOST_REQUIRE_NO_THROW(qo->getMetadata("my_meta")); - BOOST_CHECK_EQUAL(qo->getMetadata("my_meta"), "is_good"); + REQUIRE(qo != nullptr); + REQUIRE_NOTHROW(qo->getMetadata("my_meta")); + CHECK(qo->getMetadata("my_meta") == "is_good"); qo = f.backend->retrieveQO(RepoPathUtils::getQoPath("TST", f.taskName + "/metadata", "", {}, "", false), repository::CcdbDatabase::Timestamp::Current, {}, { { "my_meta", "nonexistent" } }); - BOOST_REQUIRE_EQUAL(qo, nullptr); + REQUIRE(qo == nullptr); } -BOOST_AUTO_TEST_CASE(ccdb_provenance, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_provenance", "[ccdb]") { test_fixture f; std::shared_ptr qo = f.backend->retrieveQO(RepoPathUtils::getQoPath("TST", f.taskName + "/provenance", "", {}, "", false), -1, { 0, "NONE", "", "", "qc_hello" }); - BOOST_REQUIRE_NE(qo, nullptr); - BOOST_CHECK_EQUAL(qo->getActivity().mProvenance, "qc_hello"); + REQUIRE(qo != nullptr); + CHECK(qo->getActivity().mProvenance == "qc_hello"); std::shared_ptr mo = f.backend->retrieveMO(f.getMoFolder("provenance"), "provenance", -1, { 0, "NONE", "", "", "qc_hello" }); - BOOST_REQUIRE_NE(mo, nullptr); - BOOST_CHECK_EQUAL(mo->getActivity().mProvenance, "qc_hello"); + REQUIRE(mo != nullptr); + CHECK(mo->getActivity().mProvenance == "qc_hello"); } unique_ptr backendGlobal = std::make_unique(); +// Catch2 assertions are not thread-safe, so the worker threads only count the failures and the test case checks them. +std::atomic emptyResultsGlobal{ 0 }; void askObject(std::string objectPath) { @@ -306,11 +313,13 @@ void askObject(std::string objectPath) cout << "std::string::max_size(): " << std::string().max_size() << endl; cout << "json string size: " << json.size() << endl; cout << "object " << json.substr(0, 10) << endl; - BOOST_CHECK(!json.empty()); + if (json.empty()) { + emptyResultsGlobal++; + } cout << "finished " << endl; } -BOOST_AUTO_TEST_CASE(ccdb_test_thread, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_test_thread", "[ccdb]") { ROOT::EnableThreadSafety(); string pid = std::to_string(getpid()); @@ -329,9 +338,12 @@ BOOST_AUTO_TEST_CASE(ccdb_test_thread, *utf::depends_on("ccdb_store")) t.join(); } threads.clear(); + CHECK(emptyResultsGlobal.load() == 0); } unique_ptr apiGlobal = std::make_unique(); +// Catch2 assertions are not thread-safe, so the worker threads only count the failures and the test case checks them. +std::atomic missingObjectsGlobal{ 0 }; void askObjectApi(std::string objectPath) { @@ -340,11 +352,13 @@ void askObjectApi(std::string objectPath) map headers; auto* object = apiGlobal->retrieveFromTFileAny(objectPath, metadata, -1, &headers); - BOOST_CHECK(object != nullptr); + if (object == nullptr) { + missingObjectsGlobal++; + } cout << "finished " << endl; } -BOOST_AUTO_TEST_CASE(ccdb_test_thread_api, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_test_thread_api", "[ccdb]") { ROOT::EnableThreadSafety(); string pid = std::to_string(getpid()); @@ -365,9 +379,10 @@ BOOST_AUTO_TEST_CASE(ccdb_test_thread_api, *utf::depends_on("ccdb_store")) t.join(); } threads.clear(); + CHECK(missingObjectsGlobal.load() == 0); } -BOOST_AUTO_TEST_CASE(ccdb_test_no_thread_api) +TEST_CASE("ccdb_test_no_thread_api", "[ccdb]") { unique_ptr api = std::make_unique(); string ccdbUrl = "http://" + QCDB_ENDPOINT; @@ -387,7 +402,7 @@ BOOST_AUTO_TEST_CASE(ccdb_test_no_thread_api) } } -BOOST_AUTO_TEST_CASE(ccdb_metadata, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_metadata", "[ccdb]") { test_fixture f; @@ -400,37 +415,37 @@ BOOST_AUTO_TEST_CASE(ccdb_metadata, *utf::depends_on("ccdb_store")) std::map headers2; TObject* obj1 = f.backend->retrieveTObject(pathQuarantine, f.metadata, -1, &headers1); TObject* obj2 = f.backend->retrieveTObject(pathMetadata, f.metadata, -1, &headers2); - BOOST_CHECK_NE(obj1, nullptr); - BOOST_CHECK_NE(obj2, nullptr); - BOOST_CHECK(headers1.size() > 0); - BOOST_CHECK(headers2.size() > 1); - BOOST_CHECK_EQUAL(headers1.count("my_meta"), 0); - BOOST_CHECK_EQUAL(headers2.count("my_meta"), 1); - BOOST_CHECK_EQUAL(headers2.at("my_meta"), "is_good"); + CHECK(obj1 != nullptr); + CHECK(obj2 != nullptr); + CHECK(headers1.size() > 0); + CHECK(headers2.size() > 1); + CHECK(headers1.count("my_meta") == 0); + CHECK(headers2.count("my_meta") == 1); + CHECK(headers2.at("my_meta") == "is_good"); // get the path without the objectName because of the interface retrieveMO auto obj1a = f.backend->retrieveMO(f.getMoFolder("quarantine"), "quarantine"); auto obj2a = f.backend->retrieveMO(f.getQoFolder(""), "metadata"); - BOOST_REQUIRE_NE(obj1a, nullptr); - BOOST_REQUIRE_NE(obj2a, nullptr); - BOOST_CHECK(obj1a->getMetadataMap().size() > 0); - BOOST_CHECK(obj2a->getMetadataMap().size() > 1); - BOOST_CHECK_EQUAL(obj1a->getMetadataMap().count("my_meta"), 0); - BOOST_CHECK_EQUAL(obj2a->getMetadataMap().count("my_meta"), 1); - BOOST_CHECK_EQUAL(obj2a->getMetadataMap().at("my_meta"), "is_good"); + REQUIRE(obj1a != nullptr); + REQUIRE(obj2a != nullptr); + CHECK(obj1a->getMetadataMap().size() > 0); + CHECK(obj2a->getMetadataMap().size() > 1); + CHECK(obj1a->getMetadataMap().count("my_meta") == 0); + CHECK(obj2a->getMetadataMap().count("my_meta") == 1); + CHECK(obj2a->getMetadataMap().at("my_meta") == "is_good"); auto obj3 = f.backend->retrieveQO(pathQuality.substr(3)); auto obj4 = f.backend->retrieveQO(pathQualityMetadata.substr(3)); - BOOST_REQUIRE_NE(obj3, nullptr); - BOOST_REQUIRE_NE(obj4, nullptr); - BOOST_CHECK(obj3->getMetadataMap().size() > 0); - BOOST_CHECK(obj4->getMetadataMap().size() > 1); - BOOST_CHECK_EQUAL(obj3->getMetadataMap().count("my_meta"), 0); - BOOST_CHECK_EQUAL(obj4->getMetadataMap().count("my_meta"), 1); - BOOST_CHECK_EQUAL(obj4->getMetadataMap().at("my_meta"), "is_good"); + REQUIRE(obj3 != nullptr); + REQUIRE(obj4 != nullptr); + CHECK(obj3->getMetadataMap().size() > 0); + CHECK(obj4->getMetadataMap().size() > 1); + CHECK(obj3->getMetadataMap().count("my_meta") == 0); + CHECK(obj4->getMetadataMap().count("my_meta") == 1); + CHECK(obj4->getMetadataMap().at("my_meta") == "is_good"); } -BOOST_AUTO_TEST_CASE(ccdb_store_retrieve_any) +TEST_CASE("ccdb_store_retrieve_any", "[ccdb]") { test_fixture f; @@ -443,13 +458,13 @@ BOOST_AUTO_TEST_CASE(ccdb_store_retrieve_any) meta.clear(); void* rawResult = f.backend->retrieveAny(typeid(TH1F), f.getMoPath("storeAny"), meta); auto h1_back = static_cast(rawResult); - BOOST_CHECK(rawResult != nullptr); - BOOST_CHECK(h1_back != nullptr); - BOOST_CHECK(h1_back->GetNbinsX() == 100); - BOOST_CHECK(h1_back->GetEntries() > 0); + CHECK(rawResult != nullptr); + CHECK(h1_back != nullptr); + CHECK(h1_back->GetNbinsX() == 100); + CHECK(h1_back->GetEntries() > 0); } -BOOST_AUTO_TEST_CASE(ccdb_store_retrieve_latest) +TEST_CASE("ccdb_store_retrieve_latest", "[ccdb]") { test_fixture f; @@ -471,11 +486,14 @@ BOOST_AUTO_TEST_CASE(ccdb_store_retrieve_latest) f.backend->storeMO(mo1); std::shared_ptr moBack = f.backend->retrieveMO(f.getMoFolder("latest_test"), "latest_test", DatabaseInterface::Timestamp::Latest, { 1234, "NONE", "LHC66", "passName1", "qc" }); - BOOST_REQUIRE(moBack != nullptr); + REQUIRE(moBack != nullptr); auto h1Back = dynamic_cast(moBack->getObject()); - BOOST_REQUIRE(h1Back != nullptr); - BOOST_CHECK_EQUAL(h1Back->GetEntries(), 20000); + REQUIRE(h1Back != nullptr); + CHECK(h1Back->GetEntries() == 20000); } } // namespace + +CATCH_REGISTER_LISTENER(CcdbDatabaseCleanupListener) + } // namespace o2::quality_control::core diff --git a/Framework/test/testCcdbDatabaseExtra.cxx b/Framework/test/testCcdbDatabaseExtra.cxx index 4426ffe4a6..14d4fbcc6c 100644 --- a/Framework/test/testCcdbDatabaseExtra.cxx +++ b/Framework/test/testCcdbDatabaseExtra.cxx @@ -20,19 +20,14 @@ #include "QualityControl/CcdbDatabase.h" #include "QualityControl/QcInfoLogger.h" -#define BOOST_TEST_MODULE CcdbDatabaseExtra test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include #include #include - -namespace utf = boost::unit_test; +#include namespace o2::quality_control::core { +// anonymous namespace to keep these symbols visible only to this file (instead of all files combined into o2-qc-test-ccdb) namespace { @@ -57,7 +52,7 @@ struct test_fixture { { backend = DatabaseFactory::create("CCDB"); backend->connect(CCDB_ENDPOINT, "", "", ""); - ILOG(Info, Support) << "*** " << boost::unit_test::framework::current_test_case().p_name << " ***" << ENDM; + ILOG(Info, Support) << "*** " << Catch::getResultCapture().getCurrentTestName() << " ***" << ENDM; } ~test_fixture() = default; @@ -68,8 +63,10 @@ struct test_fixture { // These tests should not be executed automatically, too much error prone. // It depends on what is in the database. +// They are hidden (tag "[ccdb][.manual]") and have to be requested explicitly: +// o2-qc-test-ccdb [ccdb][.manual] -BOOST_AUTO_TEST_CASE(ccdb_retrieve_all) +TEST_CASE("ccdb_retrieve_all", "[ccdb][.manual]") { test_fixture f; for (auto const& [task, object] : Objects) { @@ -85,7 +82,7 @@ BOOST_AUTO_TEST_CASE(ccdb_retrieve_all) long oldTimestamp; -BOOST_AUTO_TEST_CASE(ccdb_store) +TEST_CASE("ccdb_extra_store", "[ccdb][.manual]") { test_fixture f; @@ -99,7 +96,7 @@ BOOST_AUTO_TEST_CASE(ccdb_store) f.backend->storeQO(qo); } -BOOST_AUTO_TEST_CASE(ccdb_retrieve_former_versions, *utf::depends_on("ccdb_store")) +TEST_CASE("ccdb_retrieve_former_versions", "[ccdb][.manual]") { // store a new object test_fixture f; @@ -110,37 +107,37 @@ BOOST_AUTO_TEST_CASE(ccdb_retrieve_former_versions, *utf::depends_on("ccdb_store // Retrieve old object stored at timestampStorage std::shared_ptr mo = f.backend->retrieveMO("TST/MO/my/task", "asdf/asdf", oldTimestamp); - BOOST_CHECK(mo); + CHECK(mo); TH1F* old = dynamic_cast(mo->getObject()); - BOOST_CHECK_NE(old, nullptr); - BOOST_CHECK_EQUAL(old->GetEntries(), 10000); + CHECK(old != nullptr); + CHECK(old->GetEntries() == 10000); // Retrieve latest object with timestamp std::shared_ptr mo2 = f.backend->retrieveMO("TST/MO/my/task", "asdf/asdf", CcdbDatabase::getCurrentTimestamp()); - BOOST_CHECK(mo2); + CHECK(mo2); TH1F* latest = dynamic_cast(mo2->getObject()); - BOOST_CHECK_NE(latest, nullptr); - BOOST_CHECK_EQUAL(latest->GetEntries(), 10001); + CHECK(latest != nullptr); + CHECK(latest->GetEntries() == 10001); // Retrieve latest object without timetsamp std::shared_ptr mo3 = f.backend->retrieveMO("TST/MO/my/task", "asdf/asdf"); - BOOST_CHECK(mo3); + CHECK(mo3); TH1F* latest2 = dynamic_cast(mo3->getObject()); - BOOST_CHECK_NE(latest2, nullptr); - BOOST_CHECK_EQUAL(latest2->GetEntries(), 10001); + CHECK(latest2 != nullptr); + CHECK(latest2->GetEntries() == 10001); } -BOOST_AUTO_TEST_CASE(ccdb_getobjects_name) +TEST_CASE("ccdb_getobjects_name", "[ccdb][.manual]") { test_fixture f; CcdbDatabase* ccdb = static_cast(f.backend.get()); ILOG(Info, Support) << "getListing()" << ENDM; auto tasks = ccdb->getListing("/qc"); - BOOST_CHECK_GT(tasks.size(), 0); // we know that there are a few + CHECK(tasks.size() > 0); // we know that there are a few // print but only for TST auto objects = f.backend->getPublishedObjectNames("/qc/TST"); - BOOST_CHECK_GT(objects.size(), 0); + CHECK(objects.size() > 0); } } // namespace } // namespace o2::quality_control::core diff --git a/Framework/test/testCcdbDatabaseListingErrors.cxx b/Framework/test/testCcdbDatabaseListingErrors.cxx index e3b23f752e..256a817259 100644 --- a/Framework/test/testCcdbDatabaseListingErrors.cxx +++ b/Framework/test/testCcdbDatabaseListingErrors.cxx @@ -17,11 +17,6 @@ #include "QualityControl/CcdbDatabase.h" -#define BOOST_TEST_MODULE CcdbDatabase listing errors test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include #include #include @@ -33,9 +28,11 @@ #include #include #include +#include using namespace o2::quality_control::repository; +// anonymous namespace to these symbols visible only to this file (instead of all files combined into o2-qc-test-core) namespace { @@ -119,24 +116,24 @@ class Html503Server } // namespace -BOOST_AUTO_TEST_CASE(getPublishedObjectNames_handles_html_503) +TEST_CASE("getPublishedObjectNames_handles_html_503") { Html503Server server; CcdbDatabase db; db.connect(server.url(), "", "", ""); std::vector names; - BOOST_CHECK_NO_THROW(names = db.getPublishedObjectNames("qc/TST/MO/SomeTask")); - BOOST_TEST(names.empty()); + CHECK_NOTHROW(names = db.getPublishedObjectNames("qc/TST/MO/SomeTask")); + CHECK(names.empty()); } -BOOST_AUTO_TEST_CASE(getListingAsPtree_handles_html_503) +TEST_CASE("getListingAsPtree_handles_html_503") { Html503Server server; CcdbDatabase db; db.connect(server.url(), "", "", ""); boost::property_tree::ptree listing; - BOOST_CHECK_NO_THROW(listing = db.getListingAsPtree("qc/TST/MO/SomeTask")); - BOOST_TEST(listing.count("objects") == 0); + CHECK_NOTHROW(listing = db.getListingAsPtree("qc/TST/MO/SomeTask")); + CHECK(listing.count("objects") == 0); } diff --git a/Framework/test/testDbFactory.cxx b/Framework/test/testDbFactory.cxx index bfa60b012d..9cefaa5990 100644 --- a/Framework/test/testDbFactory.cxx +++ b/Framework/test/testDbFactory.cxx @@ -21,19 +21,14 @@ #include "QualityControl/MySqlDatabase.h" #endif -#define BOOST_TEST_MODULE DbFactory test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include - #include #include #include #include -#include +#include #include #include +#include using namespace std; using namespace o2::quality_control::core; @@ -51,33 +46,33 @@ const std::string QCDB_ENDPOINT = [] { namespace o2::quality_control::repository { -BOOST_AUTO_TEST_CASE(db_factory_test) +TEST_CASE("db_factory_test") { #ifdef _WITH_MYSQL std::unique_ptr database = DatabaseFactory::create("MySql"); - BOOST_CHECK(database); - BOOST_CHECK(dynamic_cast(database.get())); + CHECK(database); + CHECK(dynamic_cast(database.get())); #endif std::unique_ptr database2 = nullptr; - BOOST_CHECK_EXCEPTION(database2 = DatabaseFactory::create("asf"), AliceO2::Common::FatalException, o2::quality_control::test::do_nothing); - BOOST_CHECK(!database2); + CHECK_THROWS_AS(database2 = DatabaseFactory::create("asf"), AliceO2::Common::FatalException); + CHECK(!database2); std::unique_ptr database3 = DatabaseFactory::create("CCDB"); - BOOST_CHECK(database3); - BOOST_CHECK(dynamic_cast(database3.get())); + CHECK(database3); + CHECK(dynamic_cast(database3.get())); std::unique_ptr database4 = DatabaseFactory::create("Dummy"); - BOOST_CHECK(database4); - BOOST_CHECK(dynamic_cast(database4.get())); + CHECK(database4); + CHECK(dynamic_cast(database4.get())); } -BOOST_AUTO_TEST_CASE(db_ccdb_listing) +TEST_CASE("db_ccdb_listing", "[ccdb]") { std::unique_ptr database3 = DatabaseFactory::create("CCDB"); - BOOST_CHECK(database3); + CHECK(database3); auto* ccdb = dynamic_cast(database3.get()); - BOOST_CHECK(ccdb); + CHECK(ccdb); ccdb->connect(QCDB_ENDPOINT, "", "", ""); @@ -102,7 +97,7 @@ BOOST_AUTO_TEST_CASE(db_ccdb_listing) for (const auto& item : list) { ILOG(Info, Support) << "task : " << item << ENDM; } - BOOST_CHECK(std::find(list.begin(), list.end(), RepoPathUtils::getMoPath(mo1.get())) != list.end()); + CHECK(std::find(list.begin(), list.end(), RepoPathUtils::getMoPath(mo1.get())) != list.end()); // test getting objects list from task auto objectNames = ccdb->getPublishedObjectNames(prefixPath + "functional_test"); @@ -110,9 +105,9 @@ BOOST_AUTO_TEST_CASE(db_ccdb_listing) // for (auto name : objectNames) { // ILOG(Info, Support) << " - object : " << name << ENDM; // } - BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/object1") != objectNames.end()); - BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/object2") != objectNames.end()); - BOOST_CHECK(std::find(objectNames.begin(), objectNames.end(), "/path/to/object3") != objectNames.end()); + CHECK(std::find(objectNames.begin(), objectNames.end(), "/object1") != objectNames.end()); + CHECK(std::find(objectNames.begin(), objectNames.end(), "/object2") != objectNames.end()); + CHECK(std::find(objectNames.begin(), objectNames.end(), "/path/to/object3") != objectNames.end()); } } // namespace o2::quality_control::repository diff --git a/Framework/test/testObjectsManager.cxx b/Framework/test/testObjectsManager.cxx index 17dfec2080..380d7e74a8 100644 --- a/Framework/test/testObjectsManager.cxx +++ b/Framework/test/testObjectsManager.cxx @@ -16,13 +16,10 @@ #include "QualityControl/ObjectsManager.h" -#define BOOST_TEST_MODULE ObjectManager test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK #include #include #include -#include +#include using namespace std; using namespace o2::quality_control::core; @@ -31,14 +28,18 @@ using namespace AliceO2::Common; namespace o2::quality_control::core { +// anonymous namespace to keep these symbols visible only to this file (instead of all files combined into o2-qc-test-core) +namespace +{ struct Config { std::string taskName = "test"; std::string detectorName = "TST"; std::string consulUrl = "invalid"; std::string taskClass = "TestClass"; }; +} // namespace -BOOST_AUTO_TEST_CASE(invalid_url_test) +TEST_CASE("invalid_url_test") { Config config; config.taskName = "test"; @@ -46,7 +47,7 @@ BOOST_AUTO_TEST_CASE(invalid_url_test) ObjectsManager objectsManager(config.taskName, config.taskClass, config.detectorName, 0); } -BOOST_AUTO_TEST_CASE(duplicate_object_test) +TEST_CASE("duplicate_object_test") { Config config; config.taskName = "test"; @@ -54,61 +55,61 @@ BOOST_AUTO_TEST_CASE(duplicate_object_test) ObjectsManager objectsManager(config.taskName, config.taskClass, config.detectorName, 0); TObjString s("content"); objectsManager.startPublishing(&s, PublicationPolicy::Forever); - BOOST_CHECK_NO_THROW(objectsManager.startPublishing(&s, PublicationPolicy::Forever)); - BOOST_REQUIRE(objectsManager.getMonitorObject("content") != nullptr); + CHECK_NOTHROW(objectsManager.startPublishing(&s, PublicationPolicy::Forever)); + REQUIRE(objectsManager.getMonitorObject("content") != nullptr); TObjString s2("content"); - BOOST_CHECK_NO_THROW(objectsManager.startPublishing(&s2, PublicationPolicy::Forever)); + CHECK_NOTHROW(objectsManager.startPublishing(&s2, PublicationPolicy::Forever)); auto mo2 = objectsManager.getMonitorObject("content"); - BOOST_REQUIRE(mo2 != nullptr); - BOOST_REQUIRE(mo2->getObject() != &s); - BOOST_REQUIRE(mo2->getObject() == &s2); + REQUIRE(mo2 != nullptr); + REQUIRE(mo2->getObject() != &s); + REQUIRE(mo2->getObject() == &s2); } -BOOST_AUTO_TEST_CASE(is_being_published_test) +TEST_CASE("is_being_published_test") { Config config; config.taskName = "test"; config.consulUrl = ""; ObjectsManager objectsManager(config.taskName, config.taskClass, config.detectorName, 0); TObjString s("content"); - BOOST_CHECK(!objectsManager.isBeingPublished("content")); + CHECK(!objectsManager.isBeingPublished("content")); objectsManager.startPublishing(&s, PublicationPolicy::Forever); - BOOST_CHECK_NO_THROW(objectsManager.startPublishing(&s, PublicationPolicy::Forever)); - BOOST_CHECK(objectsManager.isBeingPublished("content")); + CHECK_NOTHROW(objectsManager.startPublishing(&s, PublicationPolicy::Forever)); + CHECK(objectsManager.isBeingPublished("content")); } -BOOST_AUTO_TEST_CASE(unpublish_test) +TEST_CASE("unpublish_test") { Config config; config.taskName = "test"; ObjectsManager objectsManager(config.taskName, config.taskClass, config.detectorName, 0); TObjString s("content"); objectsManager.startPublishing(&s, PublicationPolicy::Forever); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 1); + CHECK(objectsManager.getNumberPublishedObjects() == 1); objectsManager.stopPublishing(&s); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); + CHECK(objectsManager.getNumberPublishedObjects() == 0); objectsManager.startPublishing(&s, PublicationPolicy::Forever); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 1); + CHECK(objectsManager.getNumberPublishedObjects() == 1); objectsManager.stopPublishing("content"); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); - BOOST_CHECK_THROW(objectsManager.stopPublishing("content"), ObjectNotFoundError); - BOOST_CHECK_THROW(objectsManager.stopPublishing("asdf"), ObjectNotFoundError); + CHECK(objectsManager.getNumberPublishedObjects() == 0); + CHECK_THROWS_AS(objectsManager.stopPublishing("content"), ObjectNotFoundError); + CHECK_THROWS_AS(objectsManager.stopPublishing("asdf"), ObjectNotFoundError); // unpublish all objectsManager.startPublishing(&s, PublicationPolicy::Forever); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 1); + CHECK(objectsManager.getNumberPublishedObjects() == 1); objectsManager.stopPublishingAll(); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); - BOOST_CHECK_NO_THROW(objectsManager.stopPublishingAll()); + CHECK(objectsManager.getNumberPublishedObjects() == 0); + CHECK_NOTHROW(objectsManager.stopPublishingAll()); // unpublish after deletion auto s2 = new TObjString("content"); objectsManager.startPublishing(s2, PublicationPolicy::Forever); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 1); + CHECK(objectsManager.getNumberPublishedObjects() == 1); delete s2; objectsManager.stopPublishing(s2); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); + CHECK(objectsManager.getNumberPublishedObjects() == 0); // unpublish for publication policy auto s3 = new TObjString("content3"); @@ -117,25 +118,25 @@ BOOST_AUTO_TEST_CASE(unpublish_test) objectsManager.startPublishing(s4, PublicationPolicy::Once); auto s5 = new TObjString("content5"); objectsManager.startPublishing(s5, PublicationPolicy::ThroughStop); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 3); + CHECK(objectsManager.getNumberPublishedObjects() == 3); objectsManager.stopPublishing(PublicationPolicy::Once); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 1); + CHECK(objectsManager.getNumberPublishedObjects() == 1); objectsManager.stopPublishing(PublicationPolicy::ThroughStop); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); + CHECK(objectsManager.getNumberPublishedObjects() == 0); objectsManager.startPublishing(s3, PublicationPolicy::Once); objectsManager.stopPublishing(s3); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); - BOOST_CHECK_NO_THROW(objectsManager.stopPublishing(PublicationPolicy::Once)); - BOOST_CHECK_EQUAL(objectsManager.getNumberPublishedObjects(), 0); - BOOST_CHECK_NO_THROW(objectsManager.stopPublishing(s3)); + CHECK(objectsManager.getNumberPublishedObjects() == 0); + CHECK_NOTHROW(objectsManager.stopPublishing(PublicationPolicy::Once)); + CHECK(objectsManager.getNumberPublishedObjects() == 0); + CHECK_NOTHROW(objectsManager.stopPublishing(s3)); delete s3; delete s4; delete s5; } -BOOST_AUTO_TEST_CASE(getters_test) +TEST_CASE("getters_test") { Config config; config.taskName = "test"; @@ -149,23 +150,23 @@ BOOST_AUTO_TEST_CASE(getters_test) objectsManager.startPublishing(&h, PublicationPolicy::Forever); // basic gets - BOOST_CHECK_NO_THROW(objectsManager.getMonitorObject("content")); - BOOST_CHECK_NO_THROW(objectsManager.getMonitorObject("histo")); - BOOST_CHECK_THROW(objectsManager.getMonitorObject("unexisting object"), ObjectNotFoundError); + CHECK_NOTHROW(objectsManager.getMonitorObject("content")); + CHECK_NOTHROW(objectsManager.getMonitorObject("histo")); + CHECK_THROWS_AS(objectsManager.getMonitorObject("unexisting object"), ObjectNotFoundError); // non owning array TObjArray* array = objectsManager.getNonOwningArray(); - BOOST_CHECK_EQUAL(array->GetEntries(), 2); - BOOST_CHECK(array->FindObject("content") != nullptr); - BOOST_CHECK(array->FindObject("histo") != nullptr); + CHECK(array->GetEntries() == 2); + CHECK(array->FindObject("content") != nullptr); + CHECK(array->FindObject("histo") != nullptr); // we confirm that deleting the array does not delete objects delete array; - BOOST_CHECK_NO_THROW(objectsManager.getMonitorObject("content")); - BOOST_CHECK_NO_THROW(objectsManager.getMonitorObject("histo")); + CHECK_NOTHROW(objectsManager.getMonitorObject("content")); + CHECK_NOTHROW(objectsManager.getMonitorObject("histo")); } -BOOST_AUTO_TEST_CASE(metadata_test) +TEST_CASE("metadata_test") { Config config; config.taskName = "test"; @@ -178,10 +179,10 @@ BOOST_AUTO_TEST_CASE(metadata_test) objectsManager.startPublishing(&h, PublicationPolicy::Forever); objectsManager.addMetadata("content", "aaa", "bbb"); - BOOST_CHECK_EQUAL(objectsManager.getMonitorObject("content")->getMetadataMap().at("aaa"), "bbb"); + CHECK(objectsManager.getMonitorObject("content")->getMetadataMap().at("aaa") == "bbb"); } -BOOST_AUTO_TEST_CASE(drawOptions_test) +TEST_CASE("drawOptions_test") { Config config; config.taskName = "test"; @@ -191,30 +192,30 @@ BOOST_AUTO_TEST_CASE(drawOptions_test) TH1F h("histo", "h", 100, 0, 99); objectsManager.startPublishing(&h, PublicationPolicy::Forever); - BOOST_CHECK_THROW(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDrawOptionsKey), out_of_range); + CHECK_THROWS_AS(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDrawOptionsKey), out_of_range); objectsManager.setDefaultDrawOptions(&h, "colz"); - BOOST_CHECK_EQUAL(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDrawOptionsKey), "colz"); + CHECK(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDrawOptionsKey) == "colz"); objectsManager.setDefaultDrawOptions("histo", "alp lego1"); - BOOST_CHECK_EQUAL(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDrawOptionsKey), "alp lego1"); + CHECK(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDrawOptionsKey) == "alp lego1"); - BOOST_CHECK_THROW(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDisplayHintsKey), out_of_range); + CHECK_THROWS_AS(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDisplayHintsKey), out_of_range); objectsManager.setDisplayHint(&h, "logx"); - BOOST_CHECK_EQUAL(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDisplayHintsKey), "logx"); + CHECK(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDisplayHintsKey) == "logx"); objectsManager.setDisplayHint("histo", "gridy logy"); - BOOST_CHECK_EQUAL(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDisplayHintsKey), "gridy logy"); + CHECK(objectsManager.getMonitorObject("histo")->getMetadataMap().at(ObjectsManager::gDisplayHintsKey) == "gridy logy"); } -BOOST_AUTO_TEST_CASE(feed_with_nullptr) +TEST_CASE("feed_with_nullptr") { Config config; config.taskName = "test"; config.consulUrl = ""; ObjectsManager objectsManager(config.taskName, config.taskClass, config.detectorName, 0); - BOOST_CHECK_NO_THROW(objectsManager.startPublishing(nullptr, PublicationPolicy::Forever)); - BOOST_CHECK_NO_THROW(objectsManager.setDefaultDrawOptions(nullptr, "")); - BOOST_CHECK_NO_THROW(objectsManager.setDisplayHint(nullptr, "")); - BOOST_CHECK_NO_THROW(objectsManager.stopPublishing(nullptr)); + CHECK_NOTHROW(objectsManager.startPublishing(nullptr, PublicationPolicy::Forever)); + CHECK_NOTHROW(objectsManager.setDefaultDrawOptions(nullptr, "")); + CHECK_NOTHROW(objectsManager.setDisplayHint(nullptr, "")); + CHECK_NOTHROW(objectsManager.stopPublishing(nullptr)); } } // namespace o2::quality_control::core diff --git a/Framework/test/testPostProcessingConfig.cxx b/Framework/test/testPostProcessingConfig.cxx index c0c0fa621e..df96f539b9 100644 --- a/Framework/test/testPostProcessingConfig.cxx +++ b/Framework/test/testPostProcessingConfig.cxx @@ -17,39 +17,35 @@ #include "getTestDataDirectory.h" #include "QualityControl/PostProcessingConfig.h" #include "Configuration/ConfigurationFactory.h" +#include -#define BOOST_TEST_MODULE PostProcessingConfig test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include using namespace o2::quality_control::postprocessing; using namespace o2::configuration; -BOOST_AUTO_TEST_CASE(test_configuration_read) +TEST_CASE("test_configuration_read") { std::string configFilePath = std::string("json://") + getTestDataDirectory() + "testSharedConfig.json"; auto configFile = ConfigurationFactory::getConfiguration(configFilePath); PostProcessingConfig ppconfig("SkeletonPostProcessing", configFile->getRecursive()); - BOOST_CHECK_EQUAL(ppconfig.taskName, "SkeletonPostProcessing"); - BOOST_CHECK_EQUAL(ppconfig.detectorName, "TST"); - BOOST_CHECK_EQUAL(ppconfig.moduleName, "QcSkeleton"); - BOOST_CHECK_EQUAL(ppconfig.className, "o2::quality_control_modules::skeleton::SkeletonPostProcessing"); + CHECK(ppconfig.taskName == "SkeletonPostProcessing"); + CHECK(ppconfig.detectorName == "TST"); + CHECK(ppconfig.moduleName == "QcSkeleton"); + CHECK(ppconfig.className == "o2::quality_control_modules::skeleton::SkeletonPostProcessing"); - BOOST_REQUIRE_EQUAL(ppconfig.initTriggers.size(), 3); - BOOST_CHECK_EQUAL(ppconfig.initTriggers[0], "SOR"); - BOOST_CHECK_EQUAL(ppconfig.initTriggers[1], "EOR"); - BOOST_CHECK_EQUAL(ppconfig.initTriggers[2], "once"); + REQUIRE(ppconfig.initTriggers.size() == 3); + CHECK(ppconfig.initTriggers[0] == "SOR"); + CHECK(ppconfig.initTriggers[1] == "EOR"); + CHECK(ppconfig.initTriggers[2] == "once"); - BOOST_REQUIRE_EQUAL(ppconfig.updateTriggers.size(), 1); - BOOST_CHECK_EQUAL(ppconfig.updateTriggers[0], "once"); + REQUIRE(ppconfig.updateTriggers.size() == 1); + CHECK(ppconfig.updateTriggers[0] == "once"); - BOOST_REQUIRE_EQUAL(ppconfig.stopTriggers.size(), 1); - BOOST_CHECK_EQUAL(ppconfig.stopTriggers[0], "once"); + REQUIRE(ppconfig.stopTriggers.size() == 1); + CHECK(ppconfig.stopTriggers[0] == "once"); - BOOST_CHECK_EQUAL(ppconfig.customParameters.size(), 4); + CHECK(ppconfig.customParameters.size() == 4); - BOOST_CHECK_EQUAL(ppconfig.ccdbUrl, "localhost:8083"); + CHECK(ppconfig.ccdbUrl == "localhost:8083"); } \ No newline at end of file diff --git a/Framework/test/testPostProcessingInterface.cxx b/Framework/test/testPostProcessingInterface.cxx index 4123f0917a..bd88becf73 100644 --- a/Framework/test/testPostProcessingInterface.cxx +++ b/Framework/test/testPostProcessingInterface.cxx @@ -19,17 +19,15 @@ #include "QualityControl/PostProcessingFactory.h" #include #include - -#define BOOST_TEST_MODULE PostProcessingRunner test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include using namespace o2::quality_control::postprocessing; namespace o2::quality_control_modules::test { +// anonymous namespace to keep this class symbols visible only to this file (instead of all files combined into o2-qc-test-core) +namespace +{ class TestTask : public PostProcessingInterface { public: @@ -60,30 +58,31 @@ class TestTask : public PostProcessingInterface int test; }; +} // namespace } /* namespace o2::quality_control_modules::test */ using namespace o2::configuration; -BOOST_AUTO_TEST_CASE(test_factory) +TEST_CASE("PostProcessingInterface_test_factory") { std::string configFilePath = std::string("json://") + getTestDataDirectory() + "testSharedConfig.json"; auto configFile = ConfigurationFactory::getConfiguration(configFilePath); o2::quality_control_modules::test::TestTask task; - BOOST_CHECK_EQUAL(task.test, 0); + CHECK(task.test == 0); task.setName("asfd"); - BOOST_CHECK_EQUAL(task.getName(), "asfd"); + CHECK(task.getName() == "asfd"); task.configure(configFile->getRecursive()); - BOOST_CHECK_EQUAL(task.test, 1); + CHECK(task.test == 1); o2::framework::ServiceRegistry services; task.initialize({ TriggerType::No }, services); - BOOST_CHECK_EQUAL(task.test, 2); + CHECK(task.test == 2); task.update({ TriggerType::No }, services); - BOOST_CHECK_EQUAL(task.test, 3); + CHECK(task.test == 3); task.finalize({ TriggerType::No }, services); - BOOST_CHECK_EQUAL(task.test, 4); + CHECK(task.test == 4); } \ No newline at end of file diff --git a/Framework/test/testPublisher.cxx b/Framework/test/testPublisher.cxx index 697ad01202..2296873b64 100644 --- a/Framework/test/testPublisher.cxx +++ b/Framework/test/testPublisher.cxx @@ -16,12 +16,8 @@ #include "QualityControl/ObjectsManager.h" -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - #include -#include +#include using namespace std; using namespace o2::quality_control::core; @@ -31,7 +27,7 @@ namespace o2::quality_control::core { // fixme: unify with testObjectManager? -BOOST_AUTO_TEST_CASE(publisher_test) +TEST_CASE("publisher_test") { std::string taskName = "test"; std::string detectorName = "TST"; @@ -41,10 +37,10 @@ BOOST_AUTO_TEST_CASE(publisher_test) objectsManager.startPublishing(&s, PublicationPolicy::Forever); TObjString* s2 = (TObjString*)(objectsManager.getMonitorObject("content")->getObject()); - BOOST_CHECK_EQUAL(s.GetString(), s2->GetString()); + CHECK(s.GetString() == s2->GetString()); MonitorObject* mo = nullptr; - BOOST_CHECK_THROW(mo = objectsManager.getMonitorObject("test"), AliceO2::Common::ObjectNotFoundError); - BOOST_CHECK_EQUAL(mo, nullptr); + CHECK_THROWS_AS(mo = objectsManager.getMonitorObject("test"), AliceO2::Common::ObjectNotFoundError); + CHECK(mo == nullptr); mo = objectsManager.getMonitorObject("content"); } diff --git a/Framework/test/testQcInfoLogger.cxx b/Framework/test/testQcInfoLogger.cxx index fe77027b2e..60615fabc1 100644 --- a/Framework/test/testQcInfoLogger.cxx +++ b/Framework/test/testQcInfoLogger.cxx @@ -16,13 +16,10 @@ #include "QualityControl/QcInfoLogger.h" -#define BOOST_TEST_MODULE InfoLogger test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK -#include #include #include #include +#include using namespace std; using namespace AliceO2::InfoLogger; @@ -30,15 +27,15 @@ using namespace AliceO2::InfoLogger; namespace o2::quality_control::core { -BOOST_AUTO_TEST_CASE(qc_info_logger) +TEST_CASE("qc_info_logger") { AliceO2::InfoLogger::InfoLogger& qc1 = QcInfoLogger::GetInfoLogger(); AliceO2::InfoLogger::InfoLogger& qc2 = QcInfoLogger::GetInfoLogger(); - BOOST_CHECK_EQUAL(&qc1, &qc2); + CHECK(&qc1 == &qc2); qc1 << "test" << AliceO2::InfoLogger::InfoLogger::endm; } -BOOST_AUTO_TEST_CASE(qc_info_logger_2) +TEST_CASE("qc_info_logger_2") { // Decreasing verbosity of the code QcInfoLogger::GetInfoLogger() << "1. info message" << AliceO2::InfoLogger::InfoLogger::endm; @@ -74,7 +71,7 @@ BOOST_AUTO_TEST_CASE(qc_info_logger_2) ILOG(Info, Trace) << "LogInfoTrace" << ENDM; } -BOOST_AUTO_TEST_CASE(qc_info_logger_fields) +TEST_CASE("qc_info_logger_fields") { ILOG(Info, Support) << "No fields set, facility=QC, system=QC, detector=" << ENDM; QcInfoLogger::setDetector("ITS"); @@ -87,13 +84,15 @@ BOOST_AUTO_TEST_CASE(qc_info_logger_fields) ILOG(Info, Support) << "Partition set to physics_1, facility=Test, system=QC, detector=ITS" << ENDM; } -BOOST_AUTO_TEST_CASE(qc_info_logger_dplil) +TEST_CASE("qc_info_logger_dplil") { - AliceO2::InfoLogger::InfoLogger dplInfoLogger; + // QcInfoLogger::init() stores the pointers globally, so these must outlive the test case (deliberately leaked), + // otherwise any test running afterwards in the same process would use a dangling logger. + auto dplInfoLogger = new AliceO2::InfoLogger::InfoLogger(); auto dplContext = new AliceO2::InfoLogger::InfoLoggerContext(); dplContext->setField(infoContext::FieldName::Facility, "dplfacility"); dplContext->setField(infoContext::FieldName::System, "dplsystem"); - QcInfoLogger::init("facility", { false, 21, "" }, &dplInfoLogger, dplContext); + QcInfoLogger::init("facility", { false, 21, "" }, dplInfoLogger, dplContext); } } // namespace o2::quality_control::core diff --git a/Framework/test/testReductor.cxx b/Framework/test/testReductor.cxx index 7759fbcbbd..cdbd3046d4 100644 --- a/Framework/test/testReductor.cxx +++ b/Framework/test/testReductor.cxx @@ -25,12 +25,9 @@ #include #include -#define BOOST_TEST_MODULE Reductor test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include #include +#include +#include // These tests upload, so this has to be a WRITABLE instance -- ccdb-test by // default. ALICEO2_CCDB_HOST lets a network-isolated build container reach one @@ -45,6 +42,9 @@ using namespace o2::quality_control::core; using namespace o2::quality_control::postprocessing; using namespace o2::quality_control::repository; +// anonymous namespace to keep this class symbols visible only to this file (instead of all files combined into o2-qc-test-core) +namespace +{ class MyReductor : public ReductorTObject { public: @@ -73,7 +73,9 @@ class MyReductor : public ReductorTObject } mStats; }; -BOOST_AUTO_TEST_CASE(test_ReductorTObjectInterface) +} // namespace + +TEST_CASE("test_ReductorTObjectInterface") { auto histo = std::make_unique("test", "test", 10, 0, 1000); auto reductor = std::make_unique(); @@ -95,16 +97,19 @@ BOOST_AUTO_TEST_CASE(test_ReductorTObjectInterface) reductor->update(histo.get()); tree->Fill(); - BOOST_REQUIRE_EQUAL(tree->GetEntries(), 4); + REQUIRE(tree->GetEntries() == 4); tree->Draw("histo.integral", "", "goff"); Double_t* integrals = tree->GetVal(0); - BOOST_CHECK_EQUAL(integrals[0], 0); - BOOST_CHECK_EQUAL(integrals[1], 1); - BOOST_CHECK_EQUAL(integrals[2], 2); - BOOST_CHECK_EQUAL(integrals[3], 5); + CHECK(integrals[0] == 0); + CHECK(integrals[1] == 1); + CHECK(integrals[2] == 2); + CHECK(integrals[3] == 5); } +// anonymous namespace to keep this class symbols visible only to this file (instead of all files combined into o2-qc-test-core) +namespace +{ class MyReductorAny : public ReductorConditionAny { public: @@ -148,18 +153,27 @@ std::string fullTestObjectPath() return pathToTestObject() + "/string"; } -struct MyGlobalFixture { - void teardown() +// Cleans up the objects stored by the tests in this file once the whole test run is over +class ReductorCleanupListener : public Catch::EventListenerBase +{ + public: + using Catch::EventListenerBase::EventListenerBase; + + void testRunEnded(Catch::TestRunStats const&) override { - std::unique_ptr backend = std::make_unique(); - backend->connect(CCDB_ENDPOINT, "", "", ""); - // cannot use the test_fixture because we are tearing down - backend->truncate(pathToTestObject(), "*"); + try { + std::unique_ptr backend = std::make_unique(); + backend->connect(CCDB_ENDPOINT, "", "", ""); + backend->truncate(pathToTestObject(), "*"); + } catch (...) { + } } }; -BOOST_TEST_GLOBAL_FIXTURE(MyGlobalFixture); +} // namespace + +CATCH_REGISTER_LISTENER(ReductorCleanupListener) -BOOST_AUTO_TEST_CASE(test_ReductorAnyInterface) +TEST_CASE("test_ReductorAnyInterface", "[ccdb]") { std::unique_ptr backend = std::make_unique(); backend->connect(CCDB_ENDPOINT, "", "", ""); @@ -175,14 +189,14 @@ BOOST_AUTO_TEST_CASE(test_ReductorAnyInterface) tree->Branch("numbers", reductor->getBranchAddress(), reductor->getBranchLeafList()); reductor->update(conditionAccess, 5, fullTestObjectPath()); tree->Fill(); - BOOST_REQUIRE_EQUAL(tree->GetEntries(), 1); + REQUIRE(tree->GetEntries() == 1); tree->Draw("numbers.a", "", "goff"); Double_t* integrals = tree->GetVal(0); - BOOST_CHECK_EQUAL(integrals[0], secret.Length()); + CHECK(integrals[0] == secret.Length()); } -BOOST_AUTO_TEST_CASE(test_ReductorConfigurable) +TEST_CASE("test_ReductorConfigurable") { class ReductorTest : public Reductor { @@ -205,5 +219,5 @@ BOOST_AUTO_TEST_CASE(test_ReductorConfigurable) params.set("key", "value"); Reductor& r = reductor; r.setCustomConfig(params); - BOOST_REQUIRE_EQUAL(r.getBranchLeafList(), "value"); + REQUIRE(std::string(r.getBranchLeafList()) == "value"); } diff --git a/Framework/test/testRepoPathUtils.cxx b/Framework/test/testRepoPathUtils.cxx index 0a30699952..d11a18fc7b 100644 --- a/Framework/test/testRepoPathUtils.cxx +++ b/Framework/test/testRepoPathUtils.cxx @@ -17,65 +17,60 @@ #include "QualityControl/RepoPathUtils.h" #include "QualityControl/MonitorObject.h" #include "QualityControl/QualityObject.h" -#include "QualityControl/testUtils.h" +#include #include - -#define BOOST_TEST_MODULE RepoPathUtils test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK -#include +#include using namespace std; -using namespace o2::quality_control::test; using namespace o2::quality_control::core; -BOOST_AUTO_TEST_CASE(qopath) +TEST_CASE("RepoPathUtils_qopath") { // no policy QualityObject qo(Quality::Null, "xyzCheck", "DET"); string path = RepoPathUtils::getQoPath(&qo); - BOOST_CHECK_EQUAL(path, "qc/DET/QO/xyzCheck"); + CHECK(path == "qc/DET/QO/xyzCheck"); path = RepoPathUtils::getQoPath("DET", "xyzCheck"); - BOOST_CHECK_EQUAL(path, "qc/DET/QO/xyzCheck"); + CHECK(path == "qc/DET/QO/xyzCheck"); // provenance qo.getActivity().mProvenance = "qc_mc"; path = RepoPathUtils::getQoPath(&qo); - BOOST_CHECK_EQUAL(path, "qc_mc/DET/QO/xyzCheck"); + CHECK(path == "qc_mc/DET/QO/xyzCheck"); // a policy which is not OnEachSeparately QualityObject qo2(Quality::Null, "xyzCheck", "DET", "OnAnyNonZero"); string path2 = RepoPathUtils::getQoPath(&qo2); - BOOST_CHECK_EQUAL(path2, "qc/DET/QO/xyzCheck"); + CHECK(path2 == "qc/DET/QO/xyzCheck"); path2 = RepoPathUtils::getQoPath("DET", "xyzCheck", "OnAnyNonZero"); - BOOST_CHECK_EQUAL(path2, "qc/DET/QO/xyzCheck"); + CHECK(path2 == "qc/DET/QO/xyzCheck"); // policy is OnEachSeparately QualityObject qo3(Quality::Null, "xyzCheck", "DET", "OnEachSeparately", {}, { "objectABC" }); string path3 = RepoPathUtils::getQoPath(&qo3); - BOOST_CHECK_EQUAL(path3, "qc/DET/QO/xyzCheck/objectABC"); + CHECK(path3 == "qc/DET/QO/xyzCheck/objectABC"); path2 = RepoPathUtils::getQoPath("DET", "xyzCheck", "OnEachSeparately", { "objectABC" }); - BOOST_CHECK_EQUAL(path3, "qc/DET/QO/xyzCheck/objectABC"); + CHECK(path3 == "qc/DET/QO/xyzCheck/objectABC"); // policy is OnEachSeparately and the vector is empty QualityObject qo4(Quality::Null, "xyzCheck", "DET", "OnEachSeparately", {}, {}); - BOOST_CHECK_EXCEPTION(RepoPathUtils::getQoPath(&qo4), AliceO2::Common::FatalException, do_nothing); - BOOST_CHECK_EXCEPTION(RepoPathUtils::getQoPath("DET", "xyzCheck", "OnEachSeparately", {}), AliceO2::Common::FatalException, do_nothing); + CHECK_THROWS_AS(RepoPathUtils::getQoPath(&qo4), AliceO2::Common::FatalException); + CHECK_THROWS_AS(RepoPathUtils::getQoPath("DET", "xyzCheck", "OnEachSeparately", {}), AliceO2::Common::FatalException); } -BOOST_AUTO_TEST_CASE(mopath) +TEST_CASE("RepoPathUtils_mopath") { string objectName = "asdf"; TH1F h(objectName.data(), objectName.data(), 100, 0, 99); o2::quality_control::core::MonitorObject obj(&h, "task", "class", "DET"); obj.setIsOwner(false); string path = RepoPathUtils::getMoPath(&obj); - BOOST_CHECK_EQUAL(path, "qc/DET/MO/task/asdf"); + CHECK(path == "qc/DET/MO/task/asdf"); path = RepoPathUtils::getMoPath("DET", "task", "asdf"); - BOOST_CHECK_EQUAL(path, "qc/DET/MO/task/asdf"); + CHECK(path == "qc/DET/MO/task/asdf"); // provenance obj.getActivity().mProvenance = "qc_mc"; path = RepoPathUtils::getMoPath(&obj); - BOOST_CHECK_EQUAL(path, "qc_mc/DET/MO/task/asdf"); + CHECK(path == "qc_mc/DET/MO/task/asdf"); } diff --git a/Framework/test/testRunnerUtils.cxx b/Framework/test/testRunnerUtils.cxx index e9e15393fa..ed54bf8cc3 100644 --- a/Framework/test/testRunnerUtils.cxx +++ b/Framework/test/testRunnerUtils.cxx @@ -16,25 +16,21 @@ #include "QualityControl/runnerUtils.h" -#define BOOST_TEST_MODULE RunnerUtils test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - #include #include -#include +#include using namespace o2::quality_control::core; using namespace std; -BOOST_AUTO_TEST_CASE(test_computeActivity) +TEST_CASE("test_computeActivity") { string runType; - BOOST_CHECK_EQUAL(translateIntegerRunType("0"), "NONE"); - BOOST_CHECK_EQUAL(translateIntegerRunType("1"), "PHYSICS"); - BOOST_CHECK_EQUAL(translateIntegerRunType("18"), "CALIBRATION_VRESETD"); - BOOST_CHECK_EQUAL(translateIntegerRunType("34"), "NONE"); // unknown - BOOST_CHECK_EQUAL(translateIntegerRunType("-134"), "-134"); // not a uint - BOOST_CHECK_EQUAL(translateIntegerRunType("NONE"), "NONE"); - BOOST_CHECK_EQUAL(translateIntegerRunType("bla"), "bla"); + CHECK(translateIntegerRunType("0") == "NONE"); + CHECK(translateIntegerRunType("1") == "PHYSICS"); + CHECK(translateIntegerRunType("18") == "CALIBRATION_VRESETD"); + CHECK(translateIntegerRunType("34") == "NONE"); // unknown + CHECK(translateIntegerRunType("-134") == "-134"); // not a uint + CHECK(translateIntegerRunType("NONE") == "NONE"); + CHECK(translateIntegerRunType("bla") == "bla"); } \ No newline at end of file diff --git a/Framework/test/testTaskInterface.cxx b/Framework/test/testTaskInterface.cxx index 89b65e3eda..ce8fc4713c 100644 --- a/Framework/test/testTaskInterface.cxx +++ b/Framework/test/testTaskInterface.cxx @@ -203,7 +203,7 @@ TEST_CASE("test_task_factory") delete task; } -TEST_CASE("retrieveCondition") +TEST_CASE("retrieveCondition", "[ccdb]") { // first store a condition o2::emcal::BadChannelMap bad; diff --git a/Framework/test/testTaskRunner.cxx b/Framework/test/testTaskRunner.cxx index 7c8d8d5e56..af0e8d4752 100644 --- a/Framework/test/testTaskRunner.cxx +++ b/Framework/test/testTaskRunner.cxx @@ -27,12 +27,7 @@ #include #include #include - -#define BOOST_TEST_MODULE TaskRunner test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include using namespace o2::quality_control::core; using namespace std; @@ -41,6 +36,9 @@ using namespace o2::header; using namespace o2::utilities; using namespace o2::configuration; +// anonymous namespace to keep these symbols visible only to this file (instead of all files combined into o2-qc-test-core) +namespace +{ TaskRunnerConfig getTaskConfig(const std::string& configFilePath, const std::string& taskName, size_t id) { auto config = ConfigurationFactory::getConfiguration(configFilePath); @@ -56,49 +54,51 @@ TaskRunnerConfig getTaskConfig(const std::string& configFilePath, const std::str } } -BOOST_AUTO_TEST_CASE(test_factory) +} // namespace + +TEST_CASE("TaskRunner_test_factory") { std::string configFilePath = std::string("json://") + getTestDataDirectory() + "testSharedConfig.json"; DataProcessorSpec taskRunner = TaskRunnerFactory::create(getTaskConfig(configFilePath, "abcTask", 123)); - BOOST_CHECK_EQUAL(taskRunner.name, "qc-task-MISC-abcTask"); + CHECK(taskRunner.name == "qc-task-MISC-abcTask"); auto dataSamplingTree = ConfigurationFactory::getConfiguration(configFilePath)->getRecursive("dataSamplingPolicies"); - BOOST_REQUIRE_EQUAL(taskRunner.inputs.size(), 2); - BOOST_CHECK_EQUAL(taskRunner.inputs[0], DataSampling::InputSpecsForPolicy(dataSamplingTree, "tpcclust").at(0)); - BOOST_CHECK(taskRunner.inputs[1].lifetime == Lifetime::Timer); + REQUIRE(taskRunner.inputs.size() == 2); + CHECK(taskRunner.inputs[0] == DataSampling::InputSpecsForPolicy(dataSamplingTree, "tpcclust").at(0)); + CHECK(taskRunner.inputs[1].lifetime == Lifetime::Timer); - BOOST_REQUIRE_EQUAL(taskRunner.outputs.size(), 1); - BOOST_CHECK_EQUAL(taskRunner.outputs[0], createUserOutputSpec(DataSourceType::Task, "XXX", "abcTask", 123)); + REQUIRE(taskRunner.outputs.size() == 1); + CHECK(taskRunner.outputs[0] == createUserOutputSpec(DataSourceType::Task, "XXX", "abcTask", 123)); - BOOST_CHECK(taskRunner.algorithm.onInit != nullptr); + CHECK(taskRunner.algorithm.onInit != nullptr); - BOOST_REQUIRE_EQUAL(taskRunner.options.size(), 3); - BOOST_CHECK_EQUAL(taskRunner.options[0].name, "period-timer-cycle"); + REQUIRE(taskRunner.options.size() == 3); + CHECK(taskRunner.options[0].name == "period-timer-cycle"); } -BOOST_AUTO_TEST_CASE(test_task_runner_static) +TEST_CASE("test_task_runner_static") { - BOOST_CHECK_EQUAL(TaskRunner::createTaskRunnerIdString(), "qc-task"); + CHECK(TaskRunner::createTaskRunnerIdString() == "qc-task"); } -BOOST_AUTO_TEST_CASE(test_task_runner) +TEST_CASE("test_task_runner") { std::string configFilePath = std::string("json://") + getTestDataDirectory() + "testSharedConfig.json"; TaskRunner qcTask{ getTaskConfig(configFilePath, "abcTask", 0) }; - BOOST_CHECK_EQUAL(qcTask.getDeviceName(), "qc-task-MISC-abcTask"); + CHECK(qcTask.getDeviceName() == "qc-task-MISC-abcTask"); auto dataSamplingTree = ConfigurationFactory::getConfiguration(configFilePath)->getRecursive("dataSamplingPolicies"); - BOOST_REQUIRE_EQUAL(qcTask.getInputsSpecs().size(), 2); - BOOST_CHECK_EQUAL(qcTask.getInputsSpecs()[0], DataSampling::InputSpecsForPolicy(dataSamplingTree, "tpcclust").at(0)); - BOOST_CHECK(qcTask.getInputsSpecs()[1].lifetime == Lifetime::Timer); + REQUIRE(qcTask.getInputsSpecs().size() == 2); + CHECK(qcTask.getInputsSpecs()[0] == DataSampling::InputSpecsForPolicy(dataSamplingTree, "tpcclust").at(0)); + CHECK(qcTask.getInputsSpecs()[1].lifetime == Lifetime::Timer); - BOOST_CHECK_EQUAL(qcTask.getOutputSpec(), createUserOutputSpec(DataSourceType::Task, "XXX", "abcTask", 0)); + CHECK(qcTask.getOutputSpec() == createUserOutputSpec(DataSourceType::Task, "XXX", "abcTask", 0)); - BOOST_REQUIRE_EQUAL(qcTask.getOptions().size(), 3); - BOOST_CHECK_EQUAL(qcTask.getOptions()[0].name, "period-timer-cycle"); + REQUIRE(qcTask.getOptions().size() == 3); + CHECK(qcTask.getOptions()[0].name == "period-timer-cycle"); // This is maximum that we can do until we are able to test the DPL algorithms in isolation. // TODO: When it is possible, we should try calling run() and init() @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(test_task_runner) qcTask.init(initContext); } -BOOST_AUTO_TEST_CASE(test_task_wrong_detector_name) +TEST_CASE("test_task_wrong_detector_name") { std::string configFilePath = std::string("json://") + getTestDataDirectory() + "testSharedConfig.json"; @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(test_task_wrong_detector_name) // cout << "It should print an error message" << endl; } -BOOST_AUTO_TEST_CASE(test_task_good_detector_name) +TEST_CASE("test_task_good_detector_name") { std::string configFilePath = std::string("json://") + getTestDataDirectory() + "testSharedConfig.json"; diff --git a/Framework/test/testTrendingTask.cxx b/Framework/test/testTrendingTask.cxx index 0c3872483d..974855d221 100644 --- a/Framework/test/testTrendingTask.cxx +++ b/Framework/test/testTrendingTask.cxx @@ -80,7 +80,7 @@ struct ReductorConfigAccessor { template struct DeclareGlobalGet; template struct DeclareGlobalGet; -TEST_CASE("test_trending_task") +TEST_CASE("test_trending_task", "[ccdb]") { const std::string pid = std::to_string(getpid()); const std::string trendingTaskName = "TestTrendingTask"; diff --git a/Framework/test/testTriggerHelpers.cxx b/Framework/test/testTriggerHelpers.cxx index 15ad755491..888d9ffc86 100644 --- a/Framework/test/testTriggerHelpers.cxx +++ b/Framework/test/testTriggerHelpers.cxx @@ -31,7 +31,7 @@ const std::string QCDB_ENDPOINT = [] { return std::string((host && *host) ? host : "ali-qcdb-test.cern.ch:8083"); }(); -TEST_CASE("test_factory") +TEST_CASE("test_factory", "[ccdb]") { PostProcessingConfig dummyConfig; // check if it ignores letter case diff --git a/Framework/test/testTriggers.cxx b/Framework/test/testTriggers.cxx index c2ac29c80b..ced03a1aae 100644 --- a/Framework/test/testTriggers.cxx +++ b/Framework/test/testTriggers.cxx @@ -17,20 +17,16 @@ #include "QualityControl/ObjectMetadataKeys.h" #include "QualityControl/Triggers.h" -#define BOOST_TEST_MODULE Triggers test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - #include "QualityControl/MonitorObject.h" #include "QualityControl/DatabaseFactory.h" #include "QualityControl/CcdbDatabase.h" #include "QualityControl/RepoPathUtils.h" #include -#include #include #include #include +#include using namespace std::chrono; using namespace o2::quality_control::postprocessing; @@ -45,47 +41,47 @@ const std::string CCDB_ENDPOINT = [] { return std::string((host && *host) ? host : "ccdb-test.cern.ch:8080"); }(); -BOOST_AUTO_TEST_CASE(test_casting_triggers) +TEST_CASE("test_casting_triggers") { auto once = triggers::Once(); // confirm that enum values works - BOOST_CHECK_EQUAL(once(), TriggerType::Once); - BOOST_CHECK_EQUAL(once(), TriggerType::No); + CHECK(once() == TriggerType::Once); + CHECK(once() == TriggerType::No); // confirm that casting to booleans works - BOOST_CHECK_EQUAL(once(), false); - BOOST_CHECK(!once()); + CHECK(once() == false); + CHECK(!once()); once = triggers::Once(); - BOOST_CHECK_EQUAL(once(), true); + CHECK(once() == true); once = triggers::Once(); - BOOST_CHECK(once()); + CHECK(once()); } -BOOST_AUTO_TEST_CASE(test_timestamps_triggers) +TEST_CASE("test_timestamps_triggers") { Trigger t1(TriggerType::Once, false, 123); - BOOST_CHECK_EQUAL(t1.triggerType, TriggerType::Once); - BOOST_CHECK_EQUAL(t1.timestamp, 123); + CHECK(t1.triggerType == TriggerType::Once); + CHECK(t1.timestamp == 123); auto nowMs = duration_cast(system_clock::now().time_since_epoch()).count(); Trigger t2(TriggerType::Once); - BOOST_CHECK_EQUAL(t2.triggerType, TriggerType::Once); - BOOST_CHECK(std::abs(static_cast(t2.timestamp - nowMs)) < 100000); // 100 seconds of max. difference should be fine. + CHECK(t2.triggerType == TriggerType::Once); + CHECK(std::abs(static_cast(t2.timestamp - nowMs)) < 100000); // 100 seconds of max. difference should be fine. } -BOOST_AUTO_TEST_CASE(test_trigger_once) +TEST_CASE("test_trigger_once") { auto once = triggers::Once(); - BOOST_CHECK_EQUAL(once(), TriggerType::Once); - BOOST_CHECK_EQUAL(once(), TriggerType::No); - BOOST_CHECK_EQUAL(once(), TriggerType::No); - BOOST_CHECK_EQUAL(once(), TriggerType::No); - BOOST_CHECK_EQUAL(once(), TriggerType::No); + CHECK(once() == TriggerType::Once); + CHECK(once() == TriggerType::No); + CHECK(once() == TriggerType::No); + CHECK(once() == TriggerType::No); + CHECK(once() == TriggerType::No); } -BOOST_AUTO_TEST_CASE(test_trigger_new_object) +TEST_CASE("test_trigger_new_object", "[ccdb]") { // Setup and initialise objects const std::string pid = std::to_string(getpid()); @@ -104,13 +100,13 @@ BOOST_AUTO_TEST_CASE(test_trigger_new_object) // Clean up existing objects auto directDBAPI = std::make_shared(); directDBAPI->init(CCDB_ENDPOINT); - BOOST_REQUIRE(directDBAPI->isHostReachable()); + REQUIRE(directDBAPI->isHostReachable()); directDBAPI->truncate(fullObjectPath); // Check before update - no objects expected - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); + CHECK(newObjectTrigger() == TriggerType::No); + CHECK(newObjectTrigger() == TriggerType::No); + CHECK(newObjectTrigger() == TriggerType::No); // Send the object std::shared_ptr repository = DatabaseFactory::create("CCDB"); @@ -120,9 +116,9 @@ BOOST_AUTO_TEST_CASE(test_trigger_new_object) repository->storeMO(mo); // Check after sending - BOOST_CHECK_EQUAL(newObjectTrigger(), Trigger(TriggerType::NewObject, currentTimestamp)); - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); + CHECK(newObjectTrigger() == Trigger(TriggerType::NewObject, currentTimestamp)); + CHECK(newObjectTrigger() == TriggerType::No); + CHECK(newObjectTrigger() == TriggerType::No); // Update the object obj->Fill(10); @@ -131,15 +127,15 @@ BOOST_AUTO_TEST_CASE(test_trigger_new_object) repository->storeMO(mo); // Check after the update - BOOST_CHECK_EQUAL(newObjectTrigger(), Trigger(TriggerType::NewObject, currentTimestamp)); - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); - BOOST_CHECK_EQUAL(newObjectTrigger(), TriggerType::No); + CHECK(newObjectTrigger() == Trigger(TriggerType::NewObject, currentTimestamp)); + CHECK(newObjectTrigger() == TriggerType::No); + CHECK(newObjectTrigger() == TriggerType::No); // Clean up remaining objects directDBAPI->truncate(fullObjectPath); } -BOOST_AUTO_TEST_CASE(test_trigger_for_each_object) +TEST_CASE("test_trigger_for_each_object", "[ccdb]") { // Setup and initialise objects const std::string pid = std::to_string(getpid()); @@ -156,7 +152,7 @@ BOOST_AUTO_TEST_CASE(test_trigger_for_each_object) // Clean up existing objects auto directDBAPI = std::make_shared(); directDBAPI->init(CCDB_ENDPOINT); - BOOST_REQUIRE(directDBAPI->isHostReachable()); + REQUIRE(directDBAPI->isHostReachable()); directDBAPI->truncate(fullObjectPath); // Send three objects with different metadata @@ -176,14 +172,14 @@ BOOST_AUTO_TEST_CASE(test_trigger_for_each_object) auto forEachObjectTrigger = triggers::ForEachObject(CCDB_ENDPOINT, "qcdb", objectPath, activityAllRunsPass1); auto trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 0); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 0); trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 0); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 0); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::No); } { @@ -191,15 +187,15 @@ BOOST_AUTO_TEST_CASE(test_trigger_for_each_object) auto forEachObjectTrigger = triggers::ForEachObject(CCDB_ENDPOINT, "qcdb", objectPath, activityRun100AllPasses); auto trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 0); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 0); trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 1); - BOOST_CHECK_EQUAL(trigger.metadata.at(metadata_keys::cycleNumber), "42"); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 1); + CHECK(trigger.metadata.at(metadata_keys::cycleNumber) == "42"); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::No); } { @@ -207,33 +203,33 @@ BOOST_AUTO_TEST_CASE(test_trigger_for_each_object) auto forEachObjectTrigger = triggers::ForEachObject(CCDB_ENDPOINT, "qcdb", objectPath, activityAll); auto trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 0); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 0); trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 0); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 0); trigger = forEachObjectTrigger(); - BOOST_CHECK_EQUAL(trigger, TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(trigger.metadata.size(), 1); - BOOST_CHECK_EQUAL(trigger.metadata.at(metadata_keys::cycleNumber), "42"); + CHECK(trigger == TriggerType::ForEachObject); + CHECK(trigger.metadata.size() == 1); + CHECK(trigger.metadata.at(metadata_keys::cycleNumber) == "42"); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::No); } { const Activity activityTimeRestriction{ 0, "NONE", "", "", "qc", { static_cast(currentTimestamp), static_cast(currentTimestamp + 5) } }; auto forEachObjectTrigger = triggers::ForEachObject(CCDB_ENDPOINT, "qcdb", objectPath, activityTimeRestriction); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachObject); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::ForEachObject); + CHECK(forEachObjectTrigger() == TriggerType::No); } // Clean up remaining objects directDBAPI->truncate(fullObjectPath); } -BOOST_AUTO_TEST_CASE(test_trigger_for_each_latest) +TEST_CASE("test_trigger_for_each_latest", "[ccdb]") { // Setup and initialise objects const std::string pid = std::to_string(getpid()); @@ -250,7 +246,7 @@ BOOST_AUTO_TEST_CASE(test_trigger_for_each_latest) // Clean up existing objects auto directDBAPI = std::make_shared(); directDBAPI->init(CCDB_ENDPOINT); - BOOST_REQUIRE(directDBAPI->isHostReachable()); + REQUIRE(directDBAPI->isHostReachable()); directDBAPI->truncate(fullObjectPath); // Send three objects with different metadata @@ -271,28 +267,28 @@ BOOST_AUTO_TEST_CASE(test_trigger_for_each_latest) const Activity activityAllRunsPass1{ 0, "TECHNICAL", "FCC42x", "tpass1", "qc" }; auto forEachObjectTrigger = triggers::ForEachLatest(CCDB_ENDPOINT, "qcdb", objectPath, activityAllRunsPass1); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::No); } { const Activity activityRun100AllPasses{ 100, "TECHNICAL", "FCC42x", "", "qc" }; auto forEachObjectTrigger = triggers::ForEachLatest(CCDB_ENDPOINT, "qcdb", objectPath, activityRun100AllPasses); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::No); } { const Activity activityAll{ 0, "NONE", "", "", "qc" }; auto forEachObjectTrigger = triggers::ForEachLatest(CCDB_ENDPOINT, "qcdb", objectPath, activityAll); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::ForEachLatest); - BOOST_CHECK_EQUAL(forEachObjectTrigger(), TriggerType::No); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::ForEachLatest); + CHECK(forEachObjectTrigger() == TriggerType::No); } // Clean up remaining objects diff --git a/Framework/test/testUserCodeInterface.cxx b/Framework/test/testUserCodeInterface.cxx index 7aed577c89..adb3a9f966 100644 --- a/Framework/test/testUserCodeInterface.cxx +++ b/Framework/test/testUserCodeInterface.cxx @@ -16,11 +16,6 @@ #include "QualityControl/UserCodeInterface.h" -#define BOOST_TEST_MODULE CommonInterface test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include #include #include #include @@ -29,6 +24,8 @@ #include #include #include +#include +#include using namespace std; using namespace o2::quality_control::repository; @@ -50,6 +47,9 @@ namespace o2::quality_control namespace test { +// anonymous namespace to keep this class symbols visible only to this file (instead of all files combined into o2-qc-test-ccdb) +namespace +{ class TestInterface : public core::UserCodeInterface { public: @@ -72,26 +72,38 @@ class TestInterface : public core::UserCodeInterface bool configured = false; }; -struct MyGlobalFixture { - void teardown() +// Cleans up the objects stored by the tests in this file once the whole test run is over +class UserCodeInterfaceCleanupListener : public Catch::EventListenerBase +{ + public: + using Catch::EventListenerBase::EventListenerBase; + + void testRunEnded(Catch::TestRunStats const&) override { - auto backend = std::make_unique(); - backend->connect(QCDB_ENDPOINT, "", "", ""); - backend->truncate("qc/TST/MO/Test/pid" + std::to_string(getpid()), "*"); + try { + auto backend = std::make_unique(); + backend->connect(QCDB_ENDPOINT, "", "", ""); + backend->truncate("qc/TST/MO/Test/pid" + std::to_string(getpid()), "*"); + } catch (...) { + } } }; -BOOST_TEST_GLOBAL_FIXTURE(MyGlobalFixture); +} // namespace + +CATCH_REGISTER_LISTENER(UserCodeInterfaceCleanupListener) -BOOST_AUTO_TEST_CASE(test_invoke_all_methods) +TEST_CASE("UserCodeInterface_test_invoke_all_methods", "[ccdb]") { test::TestInterface testInterface; - BOOST_CHECK_EQUAL(testInterface.configured, false); + CHECK(testInterface.configured == false); TH1F* h1 = new TH1F("asdf", "asdf", 100, 0, 99); auto pid = std::to_string(getpid()); auto taskName = "Test/pid" + pid; shared_ptr mo1 = make_shared(h1, taskName, "task", "TST"); + // explicit validity, so that the object can be retrieved with an explicit timestamp below + mo1->setValidity({ 10000, 20000 }); auto backend = std::make_unique(); backend->connect(QCDB_ENDPOINT, "", "", ""); backend->storeMO(mo1); @@ -100,12 +112,12 @@ BOOST_AUTO_TEST_CASE(test_invoke_all_methods) CustomParameters customParameters; customParameters["test"] = "asdf"; testInterface.setCustomParameters(customParameters); - BOOST_CHECK_EQUAL(testInterface.configured, true); - BOOST_CHECK_EQUAL(testInterface.get("test"), "asdf"); + CHECK(testInterface.configured == true); + CHECK(testInterface.get("test") == "asdf"); testInterface.setCcdbUrl(QCDB_ENDPOINT); - auto obj = testInterface.retrieveConditionAny("qc/TST/MO/" + taskName + "/asdf"); - BOOST_CHECK_NE(obj, nullptr); + auto obj = testInterface.retrieveConditionAny("qc/TST/MO/" + taskName + "/asdf", {}, 15000); + CHECK(obj != nullptr); } } /* namespace test */ } /* namespace o2::quality_control */ \ No newline at end of file diff --git a/Modules/Benchmark/CMakeLists.txt b/Modules/Benchmark/CMakeLists.txt index aaf0f8d593..efacf0cb7e 100644 --- a/Modules/Benchmark/CMakeLists.txt +++ b/Modules/Benchmark/CMakeLists.txt @@ -31,18 +31,11 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Benchmark # ---- Test(s) ---- -#set(TEST_SRCS test/testQcBenchmark.cxx) # uncomment to reenable the test which was empty - -foreach(test ${TEST_SRCS}) - get_filename_component(test_name ${test} NAME) - string(REGEX REPLACE ".cxx" "" test_name ${test_name}) - - add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcBenchmark Boost::unit_test_framework) - add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) -endforeach() +# uncomment to reenable the test which was empty +#add_executable(o2-qc-test-benchmark test/testQcBenchmark.cxx) +#target_link_libraries(o2-qc-test-benchmark PRIVATE O2QcBenchmark O2::Catch2) +#set_property(TARGET o2-qc-test-benchmark +# PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +#add_test(NAME o2-qc-test-benchmark COMMAND o2-qc-test-benchmark) +#set_tests_properties(o2-qc-test-benchmark PROPERTIES TIMEOUT 20) diff --git a/Modules/Benchmark/test/testQcBenchmark.cxx b/Modules/Benchmark/test/testQcBenchmark.cxx index 7c8ddd5872..d2bbba6412 100644 --- a/Modules/Benchmark/test/testQcBenchmark.cxx +++ b/Modules/Benchmark/test/testQcBenchmark.cxx @@ -15,16 +15,11 @@ /// #include "QualityControl/TaskFactory.h" - -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include namespace o2::quality_control_modules::benchmark { -BOOST_AUTO_TEST_CASE(instantiate_task) { BOOST_CHECK(true); } +TEST_CASE("instantiate_task") { CHECK(true); } } // namespace o2::quality_control_modules::benchmark diff --git a/Modules/Common/CMakeLists.txt b/Modules/Common/CMakeLists.txt index ddd93c9122..b182ab174b 100644 --- a/Modules/Common/CMakeLists.txt +++ b/Modules/Common/CMakeLists.txt @@ -89,22 +89,14 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Common # ---- Tests ---- -set(TEST_SRCS - test/testMeanIsAbove.cxx - test/testNonEmpty.cxx - test/testCommonReductors.cxx - test/testCommonHistRatios.cxx - test/testWorstOfAllAggregator.cxx) - -foreach(test ${TEST_SRCS}) - get_filename_component(test_name ${test} NAME) - string(REGEX REPLACE ".cxx" "" test_name ${test_name}) - - add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcCommon Boost::unit_test_framework) - add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) -endforeach() +add_executable(o2-qc-test-common + test/testMeanIsAbove.cxx + test/testNonEmpty.cxx + test/testCommonReductors.cxx + test/testCommonHistRatios.cxx + test/testWorstOfAllAggregator.cxx) +target_link_libraries(o2-qc-test-common PRIVATE O2QcCommon O2::Catch2) +set_property(TARGET o2-qc-test-common + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +add_test(NAME o2-qc-test-common COMMAND o2-qc-test-common) +set_tests_properties(o2-qc-test-common PROPERTIES TIMEOUT 20) diff --git a/Modules/Common/test/testCommonHistRatios.cxx b/Modules/Common/test/testCommonHistRatios.cxx index c36557afc9..9a2a324d79 100644 --- a/Modules/Common/test/testCommonHistRatios.cxx +++ b/Modules/Common/test/testCommonHistRatios.cxx @@ -17,18 +17,13 @@ #include "QualityControl/QualityObject.h" #include "Common/TH1Ratio.h" #include "Common/TH2Ratio.h" - -#define BOOST_TEST_MODULE CommonHistRatios test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include using namespace o2::quality_control; using namespace o2::quality_control::core; using namespace o2::quality_control_modules::common; -BOOST_AUTO_TEST_CASE(test_TH1FRatioUniform) +TEST_CASE("test_TH1FRatioUniform") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, true); auto histo2 = std::make_unique("test2", "test2", 10, 0, 10.0, true); @@ -50,11 +45,11 @@ BOOST_AUTO_TEST_CASE(test_TH1FRatioUniform) for (int bin = 1; bin <= 10; bin++) { float value = 9.0 * bin / 5.0; - BOOST_REQUIRE_EQUAL(histoMerged->GetBinContent(bin), value); + REQUIRE(histoMerged->GetBinContent(bin) == value); } } -BOOST_AUTO_TEST_CASE(test_TH1FRatio) +TEST_CASE("test_TH1FRatio") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, false); auto histo2 = std::make_unique("test2", "test2", 10, 0, 10.0, false); @@ -76,11 +71,11 @@ BOOST_AUTO_TEST_CASE(test_TH1FRatio) for (int bin = 1; bin <= 10; bin++) { float value = 9.0 * bin / 7.0; - BOOST_REQUIRE_EQUAL(histoMerged->GetBinContent(bin), value); + REQUIRE(histoMerged->GetBinContent(bin) == value); } } -BOOST_AUTO_TEST_CASE(test_TH1FRatioCopy) +TEST_CASE("test_TH1FRatioCopy") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, true); auto histo2 = std::make_unique("test2", "test2", 100, 0, 10.0, false); @@ -97,32 +92,32 @@ BOOST_AUTO_TEST_CASE(test_TH1FRatioCopy) histo1->Copy(*(histo2.get())); histo1->Copy(*(histo3.get())); - BOOST_REQUIRE_EQUAL(histo2->hasUniformScaling(), true); - BOOST_REQUIRE_EQUAL(histo3->hasUniformScaling(), true); + REQUIRE(histo2->hasUniformScaling() == true); + REQUIRE(histo3->hasUniformScaling() == true); - BOOST_REQUIRE_EQUAL(histo2->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo3->GetXaxis()->GetNbins(), 10); + REQUIRE(histo2->GetXaxis()->GetNbins() == 10); + REQUIRE(histo3->GetXaxis()->GetNbins() == 10); - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo3->getNum()->GetXaxis()->GetNbins(), 10); + REQUIRE(histo2->getNum()->GetXaxis()->GetNbins() == 10); + REQUIRE(histo3->getNum()->GetXaxis()->GetNbins() == 10); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetXaxis()->GetNbins(), 1); - BOOST_REQUIRE_EQUAL(histo3->getDen()->GetXaxis()->GetNbins(), 1); + REQUIRE(histo2->getDen()->GetXaxis()->GetNbins() == 1); + REQUIRE(histo3->getDen()->GetXaxis()->GetNbins() == 1); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetBinContent(1), 2); - BOOST_REQUIRE_EQUAL(histo3->getDen()->GetBinContent(1), 2); + REQUIRE(histo2->getDen()->GetBinContent(1) == 2); + REQUIRE(histo3->getDen()->GetBinContent(1) == 2); for (int bin = 1; bin <= 10; bin++) { float value_num = bin * 4.0; - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetBinContent(bin), value_num); - BOOST_REQUIRE_EQUAL(histo3->getNum()->GetBinContent(bin), value_num); + REQUIRE(histo2->getNum()->GetBinContent(bin) == value_num); + REQUIRE(histo3->getNum()->GetBinContent(bin) == value_num); float value = bin * 2.0; - BOOST_REQUIRE_EQUAL(histo2->GetBinContent(bin), value); - BOOST_REQUIRE_EQUAL(histo3->GetBinContent(bin), value); + REQUIRE(histo2->GetBinContent(bin) == value); + REQUIRE(histo3->GetBinContent(bin) == value); } } -BOOST_AUTO_TEST_CASE(test_TH1FRatioClone) +TEST_CASE("test_TH1FRatioClone") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, true); @@ -136,23 +131,23 @@ BOOST_AUTO_TEST_CASE(test_TH1FRatioClone) TH1FRatio* histo2 = (TH1FRatio*)histo1->Clone("test1_clone"); - BOOST_REQUIRE_EQUAL(histo2->GetName(), "test1_clone"); - BOOST_REQUIRE_EQUAL(histo2->hasUniformScaling(), true); - BOOST_REQUIRE_EQUAL(histo2->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetXaxis()->GetNbins(), 1); + REQUIRE(std::string(histo2->GetName()) == "test1_clone"); + REQUIRE(histo2->hasUniformScaling() == true); + REQUIRE(histo2->GetXaxis()->GetNbins() == 10); + REQUIRE(histo2->getNum()->GetXaxis()->GetNbins() == 10); + REQUIRE(histo2->getDen()->GetXaxis()->GetNbins() == 1); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetBinContent(1), 2); + REQUIRE(histo2->getDen()->GetBinContent(1) == 2); for (int bin = 1; bin <= 10; bin++) { float value_num = bin * 4.0; - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetBinContent(bin), value_num); + REQUIRE(histo2->getNum()->GetBinContent(bin) == value_num); float value = bin * 2.0; - BOOST_REQUIRE_EQUAL(histo2->GetBinContent(bin), value); + REQUIRE(histo2->GetBinContent(bin) == value); } } -BOOST_AUTO_TEST_CASE(test_TH2FRatioUniform) +TEST_CASE("test_TH2FRatioUniform") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, 10, 0, 10.0, true); auto histo2 = std::make_unique("test2", "test2", 10, 0, 10.0, 10, 0, 10.0, true); @@ -177,12 +172,12 @@ BOOST_AUTO_TEST_CASE(test_TH2FRatioUniform) for (int ybin = 1; ybin <= 10; ybin++) { for (int xbin = 1; xbin <= 10; xbin++) { float value = 9.0 * xbin * ybin / 5.0; - BOOST_REQUIRE_EQUAL(histoMerged->GetBinContent(xbin, ybin), value); + REQUIRE(histoMerged->GetBinContent(xbin, ybin) == value); } } } -BOOST_AUTO_TEST_CASE(test_TH2FRatio) +TEST_CASE("test_TH2FRatio") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, 10, 0, 10.0, false); auto histo2 = std::make_unique("test2", "test2", 10, 0, 10.0, 10, 0, 10.0, false); @@ -207,12 +202,12 @@ BOOST_AUTO_TEST_CASE(test_TH2FRatio) for (int ybin = 1; ybin <= 10; ybin++) { for (int xbin = 1; xbin <= 10; xbin++) { float value = 9.0 * xbin * ybin / 7.0; - BOOST_REQUIRE_EQUAL(histoMerged->GetBinContent(xbin, ybin), value); + REQUIRE(histoMerged->GetBinContent(xbin, ybin) == value); } } } -BOOST_AUTO_TEST_CASE(test_TH2FRatioCopy) +TEST_CASE("test_TH2FRatioCopy") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, 10, 0, 10.0, true); auto histo2 = std::make_unique("test2", "test2", 100, 0, 10.0, 100, 0, 10.0, false); @@ -231,40 +226,40 @@ BOOST_AUTO_TEST_CASE(test_TH2FRatioCopy) histo1->Copy(*(histo2.get())); histo1->Copy(*(histo3.get())); - BOOST_REQUIRE_EQUAL(histo2->hasUniformScaling(), true); - BOOST_REQUIRE_EQUAL(histo3->hasUniformScaling(), true); + REQUIRE(histo2->hasUniformScaling() == true); + REQUIRE(histo3->hasUniformScaling() == true); - BOOST_REQUIRE_EQUAL(histo2->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo3->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo2->GetYaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo3->GetYaxis()->GetNbins(), 10); + REQUIRE(histo2->GetXaxis()->GetNbins() == 10); + REQUIRE(histo3->GetXaxis()->GetNbins() == 10); + REQUIRE(histo2->GetYaxis()->GetNbins() == 10); + REQUIRE(histo3->GetYaxis()->GetNbins() == 10); - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo3->getNum()->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetYaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo3->getNum()->GetYaxis()->GetNbins(), 10); + REQUIRE(histo2->getNum()->GetXaxis()->GetNbins() == 10); + REQUIRE(histo3->getNum()->GetXaxis()->GetNbins() == 10); + REQUIRE(histo2->getNum()->GetYaxis()->GetNbins() == 10); + REQUIRE(histo3->getNum()->GetYaxis()->GetNbins() == 10); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetXaxis()->GetNbins(), 1); - BOOST_REQUIRE_EQUAL(histo3->getDen()->GetXaxis()->GetNbins(), 1); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetYaxis()->GetNbins(), 1); - BOOST_REQUIRE_EQUAL(histo3->getDen()->GetYaxis()->GetNbins(), 1); + REQUIRE(histo2->getDen()->GetXaxis()->GetNbins() == 1); + REQUIRE(histo3->getDen()->GetXaxis()->GetNbins() == 1); + REQUIRE(histo2->getDen()->GetYaxis()->GetNbins() == 1); + REQUIRE(histo3->getDen()->GetYaxis()->GetNbins() == 1); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetBinContent(1, 1), 2); - BOOST_REQUIRE_EQUAL(histo3->getDen()->GetBinContent(1, 1), 2); + REQUIRE(histo2->getDen()->GetBinContent(1, 1) == 2); + REQUIRE(histo3->getDen()->GetBinContent(1, 1) == 2); for (int ybin = 1; ybin <= 10; ybin++) { for (int xbin = 1; xbin <= 10; xbin++) { float value_num = xbin * ybin * 4; - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetBinContent(xbin, ybin), value_num); - BOOST_REQUIRE_EQUAL(histo3->getNum()->GetBinContent(xbin, ybin), value_num); + REQUIRE(histo2->getNum()->GetBinContent(xbin, ybin) == value_num); + REQUIRE(histo3->getNum()->GetBinContent(xbin, ybin) == value_num); float value = xbin * ybin * 2; - BOOST_REQUIRE_EQUAL(histo2->GetBinContent(xbin, ybin), value); - BOOST_REQUIRE_EQUAL(histo3->GetBinContent(xbin, ybin), value); + REQUIRE(histo2->GetBinContent(xbin, ybin) == value); + REQUIRE(histo3->GetBinContent(xbin, ybin) == value); } } } -BOOST_AUTO_TEST_CASE(test_TH2FRatioClone) +TEST_CASE("test_TH2FRatioClone") { auto histo1 = std::make_unique("test1", "test1", 10, 0, 10.0, 10, 0, 10.0, true); @@ -280,26 +275,26 @@ BOOST_AUTO_TEST_CASE(test_TH2FRatioClone) TH2FRatio* histo2 = (TH2FRatio*)histo1->Clone("test1_clone"); - BOOST_REQUIRE_EQUAL(histo2->GetName(), "test1_clone"); - BOOST_REQUIRE_EQUAL(histo2->hasUniformScaling(), true); + REQUIRE(std::string(histo2->GetName()) == "test1_clone"); + REQUIRE(histo2->hasUniformScaling() == true); - BOOST_REQUIRE_EQUAL(histo2->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo2->GetYaxis()->GetNbins(), 10); + REQUIRE(histo2->GetXaxis()->GetNbins() == 10); + REQUIRE(histo2->GetYaxis()->GetNbins() == 10); - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetXaxis()->GetNbins(), 10); - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetYaxis()->GetNbins(), 10); + REQUIRE(histo2->getNum()->GetXaxis()->GetNbins() == 10); + REQUIRE(histo2->getNum()->GetYaxis()->GetNbins() == 10); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetXaxis()->GetNbins(), 1); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetYaxis()->GetNbins(), 1); + REQUIRE(histo2->getDen()->GetXaxis()->GetNbins() == 1); + REQUIRE(histo2->getDen()->GetYaxis()->GetNbins() == 1); - BOOST_REQUIRE_EQUAL(histo2->getDen()->GetBinContent(1, 1), 2); + REQUIRE(histo2->getDen()->GetBinContent(1, 1) == 2); for (int ybin = 1; ybin <= 10; ybin++) { for (int xbin = 1; xbin <= 10; xbin++) { float value_num = xbin * ybin * 4; - BOOST_REQUIRE_EQUAL(histo2->getNum()->GetBinContent(xbin, ybin), value_num); + REQUIRE(histo2->getNum()->GetBinContent(xbin, ybin) == value_num); float value = xbin * ybin * 2; - BOOST_REQUIRE_EQUAL(histo2->GetBinContent(xbin, ybin), value); + REQUIRE(histo2->GetBinContent(xbin, ybin) == value); } } } diff --git a/Modules/Common/test/testCommonReductors.cxx b/Modules/Common/test/testCommonReductors.cxx index d0d0f32bb9..956d9f00c1 100644 --- a/Modules/Common/test/testCommonReductors.cxx +++ b/Modules/Common/test/testCommonReductors.cxx @@ -22,19 +22,14 @@ #include #include #include - -#define BOOST_TEST_MODULE CommonReductors test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include using namespace o2::quality_control; using namespace o2::quality_control::core; using namespace o2::quality_control::postprocessing; using namespace o2::quality_control_modules::common; -BOOST_AUTO_TEST_CASE(test_TH1Reductor) +TEST_CASE("test_TH1Reductor") { auto histo = std::make_unique("test", "test", 10, 0, 10.0); auto reductor = std::make_unique(); @@ -53,26 +48,26 @@ BOOST_AUTO_TEST_CASE(test_TH1Reductor) reductor->update(histo.get()); tree->Fill(); - BOOST_REQUIRE_EQUAL(tree->GetEntries(), 3); + REQUIRE(tree->GetEntries() == 3); tree->Draw("histo.mean:histo.stddev:histo.entries", "", "goff"); Double_t* means = tree->GetVal(0); - BOOST_CHECK_CLOSE(means[0], 5, 0.01); - BOOST_CHECK_CLOSE(means[1], 3, 0.01); - BOOST_CHECK_CLOSE(means[2], 5, 0.01); + CHECK_THAT(means[0], Catch::Matchers::WithinRel(5, 0.01 / 100)); + CHECK_THAT(means[1], Catch::Matchers::WithinRel(3, 0.01 / 100)); + CHECK_THAT(means[2], Catch::Matchers::WithinRel(5, 0.01 / 100)); Double_t* stddevs = tree->GetVal(1); - BOOST_CHECK_CLOSE(stddevs[0], 0, 0.01); - BOOST_CHECK_CLOSE(stddevs[1], 2, 0.01); - BOOST_CHECK_CLOSE(stddevs[2], 2.55, 0.05); + CHECK_THAT(stddevs[0], Catch::Matchers::WithinRel(0, 0.01 / 100)); + CHECK_THAT(stddevs[1], Catch::Matchers::WithinRel(2, 0.01 / 100)); + CHECK_THAT(stddevs[2], Catch::Matchers::WithinRel(2.55, 0.05 / 100)); Double_t* entries = tree->GetVal(2); - BOOST_CHECK_CLOSE(entries[0], 1, 0.01); - BOOST_CHECK_CLOSE(entries[1], 2, 0.01); - BOOST_CHECK_CLOSE(entries[2], 4, 0.01); + CHECK_THAT(entries[0], Catch::Matchers::WithinRel(1, 0.01 / 100)); + CHECK_THAT(entries[1], Catch::Matchers::WithinRel(2, 0.01 / 100)); + CHECK_THAT(entries[2], Catch::Matchers::WithinRel(4, 0.01 / 100)); } -BOOST_AUTO_TEST_CASE(test_TH2Reductor) +TEST_CASE("test_TH2Reductor") { auto histo = std::make_unique("test", "test", 10, 0.0, 10.0, 10, 0.0, 10.0); auto reductor = std::make_unique(); @@ -91,26 +86,26 @@ BOOST_AUTO_TEST_CASE(test_TH2Reductor) reductor->update(histo.get()); tree->Fill(); - BOOST_REQUIRE_EQUAL(tree->GetEntries(), 3); + REQUIRE(tree->GetEntries() == 3); tree->Draw("histo.sumw:histo.sumwxy:histo.entries", "", "goff"); Double_t* sumws = tree->GetVal(0); - BOOST_CHECK_CLOSE(sumws[0], 1, 0.01); - BOOST_CHECK_CLOSE(sumws[1], 2, 0.01); - BOOST_CHECK_CLOSE(sumws[2], 4, 0.01); + CHECK_THAT(sumws[0], Catch::Matchers::WithinRel(1, 0.01 / 100)); + CHECK_THAT(sumws[1], Catch::Matchers::WithinRel(2, 0.01 / 100)); + CHECK_THAT(sumws[2], Catch::Matchers::WithinRel(4, 0.01 / 100)); Double_t* sumwxys = tree->GetVal(1); - BOOST_CHECK_CLOSE(sumwxys[0], 25, 0.01); - BOOST_CHECK_CLOSE(sumwxys[1], 25 + 1, 0.01); - BOOST_CHECK_CLOSE(sumwxys[2], 25 + 1 + 36 + 64, 0.01); + CHECK_THAT(sumwxys[0], Catch::Matchers::WithinRel(25, 0.01 / 100)); + CHECK_THAT(sumwxys[1], Catch::Matchers::WithinRel(25 + 1, 0.01 / 100)); + CHECK_THAT(sumwxys[2], Catch::Matchers::WithinRel(25 + 1 + 36 + 64, 0.01 / 100)); Double_t* entries = tree->GetVal(2); - BOOST_CHECK_CLOSE(entries[0], 1, 0.01); - BOOST_CHECK_CLOSE(entries[1], 2, 0.01); - BOOST_CHECK_CLOSE(entries[2], 4, 0.01); + CHECK_THAT(entries[0], Catch::Matchers::WithinRel(1, 0.01 / 100)); + CHECK_THAT(entries[1], Catch::Matchers::WithinRel(2, 0.01 / 100)); + CHECK_THAT(entries[2], Catch::Matchers::WithinRel(4, 0.01 / 100)); } -BOOST_AUTO_TEST_CASE(test_QualityReductor) +TEST_CASE("test_QualityReductor") { auto reductor = std::make_unique(); @@ -132,14 +127,14 @@ BOOST_AUTO_TEST_CASE(test_QualityReductor) reductor->update(&qoMedium); tree->Fill(); - BOOST_REQUIRE_EQUAL(tree->GetEntries(), 4); + REQUIRE(tree->GetEntries() == 4); tree->Draw("quality.level", "", "goff"); Double_t* levels = tree->GetVal(0); - BOOST_CHECK_CLOSE(levels[0], 3, 0.01); - BOOST_CHECK_CLOSE(levels[1], 1, 0.01); - BOOST_CHECK_CLOSE(levels[2], 1, 0.01); - BOOST_CHECK_CLOSE(levels[3], 2, 0.01); + CHECK_THAT(levels[0], Catch::Matchers::WithinRel(3, 0.01 / 100)); + CHECK_THAT(levels[1], Catch::Matchers::WithinRel(1, 0.01 / 100)); + CHECK_THAT(levels[2], Catch::Matchers::WithinRel(1, 0.01 / 100)); + CHECK_THAT(levels[3], Catch::Matchers::WithinRel(2, 0.01 / 100)); struct { UInt_t level; @@ -148,11 +143,11 @@ BOOST_AUTO_TEST_CASE(test_QualityReductor) tree->GetBranch("quality")->SetAddress(&qualityStats); tree->GetEntry(0); - BOOST_CHECK(!strncmp(qualityStats.name, "Bad", QualityReductor::NAME_SIZE)); + CHECK(!strncmp(qualityStats.name, "Bad", QualityReductor::NAME_SIZE)); tree->GetEntry(1); - BOOST_CHECK(!strncmp(qualityStats.name, "Good", QualityReductor::NAME_SIZE)); + CHECK(!strncmp(qualityStats.name, "Good", QualityReductor::NAME_SIZE)); tree->GetEntry(2); - BOOST_CHECK(!strncmp(qualityStats.name, "Good", QualityReductor::NAME_SIZE)); + CHECK(!strncmp(qualityStats.name, "Good", QualityReductor::NAME_SIZE)); tree->GetEntry(3); - BOOST_CHECK(!strncmp(qualityStats.name, "Medium", QualityReductor::NAME_SIZE)); + CHECK(!strncmp(qualityStats.name, "Medium", QualityReductor::NAME_SIZE)); } \ No newline at end of file diff --git a/Modules/Common/test/testMeanIsAbove.cxx b/Modules/Common/test/testMeanIsAbove.cxx index 89c856fb28..eb66b9f68d 100644 --- a/Modules/Common/test/testMeanIsAbove.cxx +++ b/Modules/Common/test/testMeanIsAbove.cxx @@ -17,19 +17,15 @@ //#define private public // hack to have access to everything #include "Common/MeanIsAbove.h" -#define BOOST_TEST_MODULE MO test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - #include "QualityControl/MonitorObject.h" #include #include -#include +#include namespace o2::quality_control_modules::common { -BOOST_AUTO_TEST_CASE(test_checks) +TEST_CASE("test_checks") { std::shared_ptr mo(new MonitorObject()); // here we are the owner of the histo TH1F th1f("h1", "h1", 10, 0, 9); @@ -43,25 +39,25 @@ BOOST_AUTO_TEST_CASE(test_checks) customParameters["meanThreshold"] = "1.0"; check.setCustomParameters(customParameters); Quality quality = check.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Bad); + CHECK(quality == Quality::Bad); th1f.Fill(1); // the threshold is set to 1 -> bad quality = check.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Bad); + CHECK(quality == Quality::Bad); th1f.Fill(2); // the threshold is set to 1 -> good quality = check.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Good); + CHECK(quality == Quality::Good); check.beautify(mo, Quality::Null); // add a line - BOOST_CHECK_EQUAL(1, th1f.GetListOfFunctions()->GetEntries()); + CHECK(1 == th1f.GetListOfFunctions()->GetEntries()); check.beautify(mo, Quality::Null); // Should update the line, not add one --> TODO THIS FAILS - // BOOST_CHECK_EQUAL(numberFunctions, th1f.GetListOfFunctions()->GetEntries()); // no modifications to the plot + // CHECK(numberFunctions == th1f.GetListOfFunctions()->GetEntries()); // no modifications to the plot } -BOOST_AUTO_TEST_CASE(test_types) +TEST_CASE("test_types") { std::shared_ptr mo(new MonitorObject()); // here we are the owner of the histo TObject obj; @@ -73,7 +69,7 @@ BOOST_AUTO_TEST_CASE(test_types) MeanIsAbove check; Quality quality = check.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Null); + CHECK(quality == Quality::Null); } } // namespace o2::quality_control_modules::common diff --git a/Modules/Common/test/testNonEmpty.cxx b/Modules/Common/test/testNonEmpty.cxx index ba2fdf5847..7c91857e26 100644 --- a/Modules/Common/test/testNonEmpty.cxx +++ b/Modules/Common/test/testNonEmpty.cxx @@ -16,18 +16,14 @@ #include "Common/NonEmpty.h" -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK -#include - #include "QualityControl/MonitorObject.h" #include +#include namespace o2::quality_control_modules::common { -BOOST_AUTO_TEST_CASE(checkable) +TEST_CASE("checkable") { TH1F histo("testObject", "test", 100, 0, 99); MonitorObject monitorObject(&histo, "task", "testClass", "TST"); @@ -35,26 +31,26 @@ BOOST_AUTO_TEST_CASE(checkable) NonEmpty myCheck; } -BOOST_AUTO_TEST_CASE(beautify) +TEST_CASE("beautify") { auto* histo = new TH1F("testObject", "test", 100, 0, 99); std::shared_ptr monitorObject(new MonitorObject(histo, "task", "testClass", "TST")); // here we are the owner of the histo NonEmpty myCheck; myCheck.beautify(monitorObject, Quality::Null); - BOOST_CHECK_EQUAL(histo->GetFillColor(), kWhite); + CHECK(histo->GetFillColor() == kWhite); /*myCheck.beautify(&monitorObject, Quality::Bad); - BOOST_CHECK_EQUAL(histo->GetFillColor(), kRed); + CHECK(histo->GetFillColor() == kRed); myCheck.beautify(&monitorObject, Quality::Good); - BOOST_CHECK_EQUAL(histo->GetFillColor(), kGreen); + CHECK(histo->GetFillColor() == kGreen); myCheck.beautify(&monitorObject, Quality::Medium); - BOOST_CHECK_EQUAL(histo->GetFillColor(), kOrange);*/ + CHECK(histo->GetFillColor() == kOrange);*/ } -BOOST_AUTO_TEST_CASE(nonempty) +TEST_CASE("nonempty") { TH1F histo("testObject", "test", 100, 0, 99); std::shared_ptr monitorObject(new MonitorObject(&histo, "task", "testClass", "TST")); // here we are the owner of the histo @@ -64,15 +60,15 @@ BOOST_AUTO_TEST_CASE(nonempty) std::map> moMap = { { "test", monitorObject } }; Quality quality = myCheck.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Bad); + CHECK(quality == Quality::Bad); histo.Fill(1); quality = myCheck.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Good); + CHECK(quality == Quality::Good); histo.Reset(); quality = myCheck.check(&moMap); - BOOST_CHECK_EQUAL(quality, Quality::Bad); + CHECK(quality == Quality::Bad); } } // namespace o2::quality_control_modules::common diff --git a/Modules/Common/test/testWorstOfAllAggregator.cxx b/Modules/Common/test/testWorstOfAllAggregator.cxx index f86109b891..3cde6ebf41 100644 --- a/Modules/Common/test/testWorstOfAllAggregator.cxx +++ b/Modules/Common/test/testWorstOfAllAggregator.cxx @@ -16,14 +16,10 @@ #include "Common/WorstOfAllAggregator.h" -#define BOOST_TEST_MODULE WorstOfAllAggregator test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK -#include - #include #include #include +#include using namespace o2::quality_control::checker; using namespace o2::quality_control::core; @@ -32,7 +28,7 @@ using namespace o2::quality_control; namespace o2::quality_control_modules::common { -BOOST_AUTO_TEST_CASE(test_WorstOfAllAggregator) +TEST_CASE("test_WorstOfAllAggregator") { WorstOfAllAggregator agg1; agg1.configure(); @@ -48,38 +44,38 @@ BOOST_AUTO_TEST_CASE(test_WorstOfAllAggregator) QualityObjectsMapType input; std::map result1 = agg1.aggregate(input); - BOOST_REQUIRE_EQUAL(result1.size(), 1); - BOOST_CHECK_EQUAL(result1["agg1"], Quality::Null); // because empty vector passed - BOOST_REQUIRE_EQUAL(result1["agg1"].getFlags().size(), 1); - BOOST_CHECK_EQUAL(result1["agg1"].getFlags().at(0).first, FlagTypeFactory::UnknownQuality()); + REQUIRE(result1.size() == 1); + CHECK(result1["agg1"] == Quality::Null); // because empty vector passed + REQUIRE(result1["agg1"].getFlags().size() == 1); + CHECK(result1["agg1"].getFlags().at(0).first == FlagTypeFactory::UnknownQuality()); input[qoGood->getName()] = qoGood; std::map result2 = agg1.aggregate(input); - BOOST_REQUIRE_EQUAL(result2.size(), 1); - BOOST_CHECK_EQUAL(result2["agg1"], Quality::Good); - BOOST_CHECK_EQUAL(result2["agg1"].getFlags().size(), 0); + REQUIRE(result2.size() == 1); + CHECK(result2["agg1"] == Quality::Good); + CHECK(result2["agg1"].getFlags().size() == 0); input[qoMedium->getName()] = qoMedium; std::map result3 = agg1.aggregate(input); - BOOST_REQUIRE_EQUAL(result3.size(), 1); - BOOST_CHECK_EQUAL(result3["agg1"], Quality::Medium); - BOOST_REQUIRE_EQUAL(result3["agg1"].getFlags().size(), 1); - BOOST_CHECK_EQUAL(result3["agg1"].getFlags().at(0).first, FlagTypeFactory::BadPID()); + REQUIRE(result3.size() == 1); + CHECK(result3["agg1"] == Quality::Medium); + REQUIRE(result3["agg1"].getFlags().size() == 1); + CHECK(result3["agg1"].getFlags().at(0).first == FlagTypeFactory::BadPID()); input[qoBad->getName()] = qoBad; std::map result4 = agg1.aggregate(input); - BOOST_REQUIRE_EQUAL(result4.size(), 1); - BOOST_CHECK_EQUAL(result4["agg1"], Quality::Bad); - BOOST_REQUIRE_EQUAL(result4["agg1"].getFlags().size(), 1); - BOOST_CHECK_EQUAL(result4["agg1"].getFlags().at(0).first, FlagTypeFactory::BadPID()); + REQUIRE(result4.size() == 1); + CHECK(result4["agg1"] == Quality::Bad); + REQUIRE(result4["agg1"].getFlags().size() == 1); + CHECK(result4["agg1"].getFlags().at(0).first == FlagTypeFactory::BadPID()); input[qoNull->getName()] = qoNull; std::map result5 = agg1.aggregate(input); - BOOST_REQUIRE_EQUAL(result5.size(), 1); - BOOST_CHECK_EQUAL(result5["agg1"], Quality::Null); - BOOST_REQUIRE_EQUAL(result5["agg1"].getFlags().size(), 2); - BOOST_CHECK_EQUAL(result5["agg1"].getFlags().at(0).first, FlagTypeFactory::BadPID()); - BOOST_CHECK_EQUAL(result5["agg1"].getFlags().at(1).first, FlagTypeFactory::BadTracking()); + REQUIRE(result5.size() == 1); + CHECK(result5["agg1"] == Quality::Null); + REQUIRE(result5["agg1"].getFlags().size() == 2); + CHECK(result5["agg1"].getFlags().at(0).first == FlagTypeFactory::BadPID()); + CHECK(result5["agg1"].getFlags().at(1).first == FlagTypeFactory::BadTracking()); } } // namespace o2::quality_control_modules::common diff --git a/Modules/Daq/CMakeLists.txt b/Modules/Daq/CMakeLists.txt index 6fe323f1b1..f4c6b02601 100644 --- a/Modules/Daq/CMakeLists.txt +++ b/Modules/Daq/CMakeLists.txt @@ -31,17 +31,9 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Daq # ---- Tests ---- -set(TEST_SRCS test/testQcDaq.cxx) - -foreach(test ${TEST_SRCS}) - get_filename_component(test_name ${test} NAME) - string(REGEX REPLACE ".cxx" "" test_name ${test_name}) - - add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcDaq Boost::unit_test_framework) - add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) -endforeach() +add_executable(o2-qc-test-daq test/testQcDaq.cxx) +target_link_libraries(o2-qc-test-daq PRIVATE O2QcDaq O2::Catch2) +set_property(TARGET o2-qc-test-daq + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +add_test(NAME o2-qc-test-daq COMMAND o2-qc-test-daq) +set_tests_properties(o2-qc-test-daq PROPERTIES TIMEOUT 20) diff --git a/Modules/Daq/test/testQcDaq.cxx b/Modules/Daq/test/testQcDaq.cxx index e9333367ff..17720b1854 100644 --- a/Modules/Daq/test/testQcDaq.cxx +++ b/Modules/Daq/test/testQcDaq.cxx @@ -7,12 +7,8 @@ //#include "QualityControl/TaskFactory.h" //#include -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - //#include -#include +#include using namespace std; @@ -25,7 +21,7 @@ struct Config { std::string consulUrl = "invalid"; }; -BOOST_AUTO_TEST_CASE(instantiate_task) +TEST_CASE("instantiate_task") { DaqTask task; Config config; @@ -37,7 +33,7 @@ BOOST_AUTO_TEST_CASE(instantiate_task) // o2::framework::InitContext ctx; // task.initialize(ctx); // TODO - // BOOST_CHECK(manager->getMonitorObject("payloadSize")->getObject() != nullptr); + // CHECK(manager->getMonitorObject("payloadSize")->getObject() != nullptr); // Activity activity; // task.startOfActivity(activity); @@ -47,7 +43,7 @@ BOOST_AUTO_TEST_CASE(instantiate_task) // task.monitorDataBlock(dataSet);// TODO // TH1F* histo = (TH1F*)manager->getMonitorObject("payloadSize")->getObject(); - // BOOST_CHECK(histo->GetEntries() == 1); + // CHECK(histo->GetEntries() == 1); // task.endOfCycle(); // task.endOfActivity(activity); diff --git a/Modules/Example/CMakeLists.txt b/Modules/Example/CMakeLists.txt index cc93eb287b..221b9a1b92 100644 --- a/Modules/Example/CMakeLists.txt +++ b/Modules/Example/CMakeLists.txt @@ -36,19 +36,13 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Example # ---- Tests ---- -set(TEST_SRCS test/testFactory.cxx test/testQcExample.cxx) - -foreach(test ${TEST_SRCS}) - get_filename_component(test_name ${test} NAME) - string(REGEX REPLACE ".cxx" "" test_name ${test_name}) - add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcExample Boost::unit_test_framework) - add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) -endforeach() - -target_sources(testFactory PRIVATE ${CMAKE_BINARY_DIR}/getTestDataDirectory.cxx) -target_include_directories(testFactory PRIVATE ${CMAKE_SOURCE_DIR}) +add_executable(o2-qc-test-example + test/testFactory.cxx + test/testQcExample.cxx) +target_link_libraries(o2-qc-test-example PRIVATE O2QcExample O2::Catch2) +target_sources(o2-qc-test-example PRIVATE ${CMAKE_BINARY_DIR}/getTestDataDirectory.cxx) +target_include_directories(o2-qc-test-example PRIVATE ${CMAKE_SOURCE_DIR}) +set_property(TARGET o2-qc-test-example + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +add_test(NAME o2-qc-test-example COMMAND o2-qc-test-example) +set_tests_properties(o2-qc-test-example PROPERTIES TIMEOUT 20) diff --git a/Modules/Example/test/testFactory.cxx b/Modules/Example/test/testFactory.cxx index e211673e98..383db2f20b 100644 --- a/Modules/Example/test/testFactory.cxx +++ b/Modules/Example/test/testFactory.cxx @@ -9,20 +9,15 @@ #include #include -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include using namespace std; -namespace utf = boost::unit_test; using namespace o2::quality_control::core; namespace o2::quality_control_modules::example { -BOOST_AUTO_TEST_CASE(Task_Factory) +TEST_CASE("Task_Factory") { TaskFactory factory; TaskRunnerConfig config; @@ -36,13 +31,12 @@ BOOST_AUTO_TEST_CASE(Task_Factory) gSystem->AddDynamicPath("lib:../../lib:../../../lib:.:"); // add local paths for the test factory.create(config, manager); } catch (...) { - BOOST_TEST_FAIL(boost::current_exception_diagnostic_information()); + FAIL(boost::current_exception_diagnostic_information()); } } -bool is_critical(AliceO2::Common::FatalException const&) { return true; } - -BOOST_AUTO_TEST_CASE(Task_Factory_failures, *utf::depends_on("Task_Factory") /* make sure we don't run both tests at the same time */) +// Catch2 runs the test cases sequentially in the order of declaration, so it is never run at the same time as "Task_Factory" +TEST_CASE("Task_Factory_failures") { TaskFactory factory; TaskRunnerConfig config; @@ -51,13 +45,13 @@ BOOST_AUTO_TEST_CASE(Task_Factory_failures, *utf::depends_on("Task_Factory") /* config.name = "task"; config.moduleName = "WRONGNAME"; config.className = "o2::quality_control_modules::example::ExampleTask"; - BOOST_CHECK_EXCEPTION(factory.create(config, manager), AliceO2::Common::FatalException, is_critical); + CHECK_THROWS_AS(factory.create(config, manager), AliceO2::Common::FatalException); gSystem->AddDynamicPath("lib:../../lib:../../../lib:"); // add local paths for the test config.name = "task"; config.moduleName = "QcCommon"; config.className = "WRONGCLASS"; - BOOST_CHECK_EXCEPTION(factory.create(config, manager), AliceO2::Common::FatalException, is_critical); + CHECK_THROWS_AS(factory.create(config, manager), AliceO2::Common::FatalException); } } // namespace o2::quality_control_modules::example diff --git a/Modules/Example/test/testQcExample.cxx b/Modules/Example/test/testQcExample.cxx index 0fa375a7f5..b59868a5ce 100644 --- a/Modules/Example/test/testQcExample.cxx +++ b/Modules/Example/test/testQcExample.cxx @@ -7,20 +7,15 @@ #include "QualityControl/TaskFactory.h" #include -#define BOOST_TEST_MODULE QcExample test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include - #include +#include using namespace std; namespace o2::quality_control_modules::example { -BOOST_AUTO_TEST_CASE(insantiate_task) +TEST_CASE("insantiate_task") { ExampleTask task; TaskRunnerConfig config; @@ -31,8 +26,8 @@ BOOST_AUTO_TEST_CASE(insantiate_task) task.setObjectsManager(manager); // task.initialize();// TODO - // BOOST_CHECK(task.getHisto1() != nullptr); - // BOOST_CHECK(task.getHisto2() != nullptr); + // CHECK(task.getHisto1() != nullptr); + // CHECK(task.getHisto2() != nullptr); Activity activity; task.startOfActivity(activity); @@ -41,13 +36,13 @@ BOOST_AUTO_TEST_CASE(insantiate_task) // DataSetReference dataSet = producer.getDataSet(); // task.monitorDataBlock(dataSet);// TODO - // BOOST_CHECK(task.getHisto1()->GetEntries() > 0); + // CHECK(task.getHisto1()->GetEntries() > 0); // task.endOfCycle(); task.endOfActivity(activity); task.startOfActivity(activity); - // BOOST_CHECK(task.getHisto1()->GetEntries() == 0); + // CHECK(task.getHisto1()->GetEntries() == 0); task.endOfActivity(activity); } diff --git a/Modules/Skeleton/.CMakeListsEmpty.txt b/Modules/Skeleton/.CMakeListsEmpty.txt index 073a7fd8f3..5d9b4b59b6 100644 --- a/Modules/Skeleton/.CMakeListsEmpty.txt +++ b/Modules/Skeleton/.CMakeListsEmpty.txt @@ -28,18 +28,10 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/QualityControl/Skeleton # ---- Test(s) ---- -set(TEST_SRCS test/testQcSkeleton.cxx) - -foreach(test ${TEST_SRCS}) - get_filename_component(test_name ${test} NAME) - string(REGEX REPLACE ".cxx" "" test_name ${test_name}) - - add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcSkeleton Boost::unit_test_framework) - add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) -endforeach() +add_executable(o2-qc-test-skeleton test/testQcSkeleton.cxx) +target_link_libraries(o2-qc-test-skeleton PRIVATE O2QcSkeleton O2::Catch2) +set_property(TARGET o2-qc-test-skeleton + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +add_test(NAME o2-qc-test-skeleton COMMAND o2-qc-test-skeleton) +set_tests_properties(o2-qc-test-skeleton PROPERTIES TIMEOUT 20) diff --git a/Modules/Skeleton/CMakeLists.txt b/Modules/Skeleton/CMakeLists.txt index 152e7f0b77..3ce17be14c 100644 --- a/Modules/Skeleton/CMakeLists.txt +++ b/Modules/Skeleton/CMakeLists.txt @@ -33,17 +33,9 @@ add_root_dictionary(O2QcSkeleton # ---- Tests ---- -set(TEST_SRCS test/testQcSkeleton.cxx) - -foreach(test ${TEST_SRCS}) - get_filename_component(test_name ${test} NAME) - string(REGEX REPLACE ".cxx" "" test_name ${test_name}) - - add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcSkeleton Boost::unit_test_framework) - add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) - set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) -endforeach() +add_executable(o2-qc-test-skeleton test/testQcSkeleton.cxx) +target_link_libraries(o2-qc-test-skeleton PRIVATE O2QcSkeleton O2::Catch2) +set_property(TARGET o2-qc-test-skeleton + PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) +add_test(NAME o2-qc-test-skeleton COMMAND o2-qc-test-skeleton) +set_tests_properties(o2-qc-test-skeleton PROPERTIES TIMEOUT 20) diff --git a/Modules/Skeleton/test/.testEmpty.cxx b/Modules/Skeleton/test/.testEmpty.cxx index d6b39f3234..6f0d353649 100644 --- a/Modules/Skeleton/test/.testEmpty.cxx +++ b/Modules/Skeleton/test/.testEmpty.cxx @@ -15,16 +15,11 @@ /// #include "QualityControl/TaskFactory.h" - -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include namespace o2::quality_control_modules::skeleton { -BOOST_AUTO_TEST_CASE(instantiate_task) { BOOST_CHECK(true); } +TEST_CASE("instantiate_task") { CHECK(true); } } // namespace o2::quality_control_modules::skeleton diff --git a/Modules/Skeleton/test/testQcSkeleton.cxx b/Modules/Skeleton/test/testQcSkeleton.cxx index af04a503ed..36dc0ecd67 100644 --- a/Modules/Skeleton/test/testQcSkeleton.cxx +++ b/Modules/Skeleton/test/testQcSkeleton.cxx @@ -19,19 +19,14 @@ //#include "Framework/InitContext.h" #include "QualityControl/TaskFactory.h" - -#define BOOST_TEST_MODULE Publisher test -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include using namespace std; namespace o2::quality_control_modules::skeleton { -BOOST_AUTO_TEST_CASE(instantiate_task) +TEST_CASE("instantiate_task") { SkeletonTask task; TaskRunnerConfig config; @@ -43,7 +38,7 @@ BOOST_AUTO_TEST_CASE(instantiate_task) // o2::framework::InitContext ctx; // task.initialize(ctx); - // BOOST_CHECK(manager->getMonitorObject("example")->getObject() != nullptr); + // CHECK(manager->getMonitorObject("example")->getObject() != nullptr); } } // namespace o2::quality_control_modules::skeleton diff --git a/Modules/o2-qc-module-configurator.sh b/Modules/o2-qc-module-configurator.sh index ba499c8ae3..256faeb2fb 100755 --- a/Modules/o2-qc-module-configurator.sh +++ b/Modules/o2-qc-module-configurator.sh @@ -45,6 +45,7 @@ function create_module() { sed 's/.testEmpty/test'$1'/; s/'${DONOR_LC}'/'${MODULE_LC}'/' ${DONOR}/test/.testEmpty.cxx >$1'/test/testQc'$1'.cxx' inplace_sed '/testQcSkeleton/s/Skeleton/'$1'/g' $1/CMakeLists.txt + inplace_sed 's/o2-qc-test-'${DONOR_LC}'/o2-qc-test-'${MODULE_LC}'/g' $1/CMakeLists.txt # add new module to the project if ! grep -c $1 CMakeLists.txt; then