diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index 898fb3f6441fd..e58a6414e06ac 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -275,11 +275,15 @@ o2_add_test(O2DatabasePDG NAME test_Framework_test_O2DatabasePDG LABELS framework PUBLIC_LINK_LIBRARIES O2::Framework O2::FrameworkPhysicsSupport) -o2_add_test(Root2ArrowTable NAME test_Framework_test_Root2ArrowTable - SOURCES test/test_Root2ArrowTable.cxx - COMPONENT_NAME Framework - LABELS framework - PUBLIC_LINK_LIBRARIES O2::Framework ROOT::ROOTDataFrame) +# All the tests which require ROOT to work +add_executable(o2-test-framework-root + test/test_Root2ArrowTable.cxx + ) +target_link_libraries(o2-test-framework-root PRIVATE O2::Framework) +target_link_libraries(o2-test-framework-root PRIVATE O2::Catch2) +target_link_libraries(o2-test-framework-root PRIVATE ROOT::ROOTDataFrame) +set_property(TARGET o2-test-framework-root PROPERTY RUNTIME_OUTPUT_DIRECTORY ${outdir}) +add_test(NAME framework:root COMMAND o2-test-framework-root --skip-benchmarks) o2_add_test(InfoLogger NAME test_Framework_test_InfoLogger SOURCES test/test_InfoLogger.cxx diff --git a/Framework/Core/test/test_Root2ArrowTable.cxx b/Framework/Core/test/test_Root2ArrowTable.cxx index 43876b3230bae..b22432d8565a5 100644 --- a/Framework/Core/test/test_Root2ArrowTable.cxx +++ b/Framework/Core/test/test_Root2ArrowTable.cxx @@ -9,11 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#define BOOST_TEST_MODULE Test Framework TableBuilder -#define BOOST_TEST_MAIN -#define BOOST_TEST_DYN_LINK - -#include +#include #include "Framework/TableBuilder.h" #include "Framework/RootTableBuilderHelpers.h" @@ -32,7 +28,7 @@ using namespace o2::framework; -BOOST_AUTO_TEST_CASE(RootTree2Table) +TEST_CASE("RootTree2Table") { using namespace o2::framework; /// Create a simple TTree @@ -78,43 +74,43 @@ BOOST_AUTO_TEST_CASE(RootTree2Table) RootTableBuilderHelpers::convertTTree(builder, reader, std::move(xyzReader), std::move(ijkReader), std::move(pxReader), std::move(pyReader), std::move(pzReader), std::move(randomReader), std::move(evReader)); auto table = builder.finalize(); - BOOST_REQUIRE_EQUAL(table->num_rows(), 1000); - BOOST_REQUIRE_EQUAL(table->num_columns(), 7); - BOOST_REQUIRE_EQUAL(table->schema()->field(0)->type()->id(), arrow::fixed_size_list(arrow::float32(), 3)->id()); - BOOST_REQUIRE_EQUAL(table->schema()->field(1)->type()->id(), arrow::fixed_size_list(arrow::int32(), 2)->id()); - BOOST_REQUIRE_EQUAL(table->schema()->field(2)->type()->id(), arrow::float32()->id()); - BOOST_REQUIRE_EQUAL(table->schema()->field(3)->type()->id(), arrow::float32()->id()); - BOOST_REQUIRE_EQUAL(table->schema()->field(4)->type()->id(), arrow::float32()->id()); - BOOST_REQUIRE_EQUAL(table->schema()->field(5)->type()->id(), arrow::float64()->id()); - BOOST_REQUIRE_EQUAL(table->schema()->field(6)->type()->id(), arrow::int32()->id()); + REQUIRE(table->num_rows() == 1000); + REQUIRE(table->num_columns() == 7); + REQUIRE(table->schema()->field(0)->type()->id() == arrow::fixed_size_list(arrow::float32(), 3)->id()); + REQUIRE(table->schema()->field(1)->type()->id() == arrow::fixed_size_list(arrow::int32(), 2)->id()); + REQUIRE(table->schema()->field(2)->type()->id() == arrow::float32()->id()); + REQUIRE(table->schema()->field(3)->type()->id() == arrow::float32()->id()); + REQUIRE(table->schema()->field(4)->type()->id() == arrow::float32()->id()); + REQUIRE(table->schema()->field(5)->type()->id() == arrow::float64()->id()); + REQUIRE(table->schema()->field(6)->type()->id() == arrow::int32()->id()); { auto chunkToUse = table->column(0)->chunk(0); chunkToUse = std::dynamic_pointer_cast(chunkToUse)->values(); auto array = std::static_pointer_cast(chunkToUse); // array of 3 floats, time 1000. - BOOST_REQUIRE_EQUAL(array->length(), 3000); + REQUIRE(array->length() == 3000); const float* c = reinterpret_cast(array->values()->data()); //auto array = std::static_pointer_cast(table->column(0)->chunk(0)); - //BOOST_CHECK_EQUAL(array->byte_width(), sizeof(float[3])); + //CHECK_EQUAL(array->byte_width(), sizeof(float[3])); //const float* c = reinterpret_cast(array->Value(0)); - BOOST_CHECK_EQUAL(c[0], 1); - BOOST_CHECK_EQUAL(c[1], 2); - BOOST_CHECK_EQUAL(c[2], 1); + CHECK(c[0] == 1); + CHECK(c[1] == 2); + CHECK(c[2] == 1); } { //auto values = std::static_pointer_cast(table->column(1)->chunk(0)); auto chunkToUse = table->column(1)->chunk(0); chunkToUse = std::dynamic_pointer_cast(chunkToUse)->values(); auto array = std::static_pointer_cast(chunkToUse); - BOOST_REQUIRE_EQUAL(array->length(), 2000); + REQUIRE(array->length() == 2000); const int* ptr = reinterpret_cast(array->values()->data()); for (size_t i = 0; i < 1000; i++) { - BOOST_CHECK_EQUAL(ptr[2 * i + 0], i); - BOOST_CHECK_EQUAL(ptr[2 * i + 1], i + 1); + CHECK(ptr[2 * i + 0] == i); + CHECK(ptr[2 * i + 1] == i + 1); } } } @@ -138,7 +134,7 @@ DECLARE_SOA_TABLE(Test, "AOD", "ETAPHI", test::Random, test::Ev); } // namespace o2::aod -BOOST_AUTO_TEST_CASE(RootTree2TableViaASoA) +TEST_CASE("RootTree2TableViaASoA") { using namespace o2::framework; /// Create a simple TTree @@ -171,23 +167,23 @@ BOOST_AUTO_TEST_CASE(RootTree2TableViaASoA) // Create an arrow table from this. TableBuilder builder; TTreeReader reader(&t2); - BOOST_REQUIRE_EQUAL(t2.GetEntries(), 1000); + REQUIRE(t2.GetEntries() == 1000); RootTableBuilderHelpers::convertASoA(builder, reader); auto table = builder.finalize(); - BOOST_REQUIRE_EQUAL(table->num_rows(), 1000); - BOOST_REQUIRE_EQUAL(table->num_columns(), 7); - BOOST_REQUIRE_EQUAL(table->column(0)->type()->id(), arrow::float32()->id()); - BOOST_REQUIRE_EQUAL(table->column(1)->type()->id(), arrow::float32()->id()); - BOOST_REQUIRE_EQUAL(table->column(2)->type()->id(), arrow::float32()->id()); - BOOST_REQUIRE_EQUAL(table->column(3)->type()->id(), arrow::fixed_size_list(arrow::float32(), 3)->id()); - BOOST_REQUIRE_EQUAL(table->column(4)->type()->id(), arrow::fixed_size_list(arrow::int32(), 2)->id()); - BOOST_REQUIRE_EQUAL(table->column(5)->type()->id(), arrow::float64()->id()); - BOOST_REQUIRE_EQUAL(table->column(6)->type()->id(), arrow::int32()->id()); + REQUIRE(table->num_rows() == 1000); + REQUIRE(table->num_columns() == 7); + REQUIRE(table->column(0)->type()->id() == arrow::float32()->id()); + REQUIRE(table->column(1)->type()->id() == arrow::float32()->id()); + REQUIRE(table->column(2)->type()->id() == arrow::float32()->id()); + REQUIRE(table->column(3)->type()->id() == arrow::fixed_size_list(arrow::float32(), 3)->id()); + REQUIRE(table->column(4)->type()->id() == arrow::fixed_size_list(arrow::int32(), 2)->id()); + REQUIRE(table->column(5)->type()->id() == arrow::float64()->id()); + REQUIRE(table->column(6)->type()->id() == arrow::int32()->id()); o2::aod::Test testTable{table}; for (auto& row : testTable) { - BOOST_REQUIRE_EQUAL(row.ij()[0], row.ij()[1] - 1); - BOOST_REQUIRE_EQUAL(row.ij()[1], row.ev()); + REQUIRE(row.ij()[0] == row.ij()[1] - 1); + REQUIRE(row.ij()[1] == row.ev()); } }