|
21 | 21 | #include <boost/test/unit_test.hpp> |
22 | 22 |
|
23 | 23 | #include <algorithm> |
| 24 | +#include <array> |
| 25 | +#include <limits> |
24 | 26 | #include <string> |
25 | 27 |
|
26 | 28 | #include "Framework/DataProcessorSpec.h" |
@@ -94,28 +96,58 @@ BOOST_AUTO_TEST_CASE(DeviceNameIsStable) |
94 | 96 | BOOST_CHECK_EQUAL(spec.name, "its-ca-tracker"); |
95 | 97 | } |
96 | 98 |
|
97 | | -BOOST_AUTO_TEST_CASE(PublicationCompatibilityIsClearedOnEveryWorkflowExit) |
| 99 | +BOOST_AUTO_TEST_CASE(PublicationFlagsAreClearedOnEveryWorkflowExit) |
98 | 100 | { |
99 | 101 | o2::its::ca::PublicationAdapter publication; |
100 | | - o2::itsmft::tracking::ITSSharedClusterCompatibility compatibility; |
101 | | - publication.adoptITSSharedClusterCompatibility(&compatibility); |
102 | 102 | o2::itsmft::tracking::TimeFrame frame; |
| 103 | + frame.getGenericTracks().resize(1); |
103 | 104 | o2::itsmft::IterationParameters parameters; |
| 105 | + parameters.AllowSharingFirstCluster = false; |
| 106 | + const std::array<uint32_t, 1> indices{0}; |
104 | 107 | for (bool fail : {false, true}) { |
105 | | - BOOST_REQUIRE(publication.completeAccepted({}, parameters, frame, true)); |
106 | | - BOOST_REQUIRE(compatibility.isSealed()); |
| 108 | + BOOST_REQUIRE(publication.completeAccepted(indices, parameters, frame, true)); |
| 109 | + BOOST_REQUIRE_EQUAL(publication.sharedClusterFlags().size(), 1u); |
107 | 110 | try { |
108 | 111 | auto cleanup = publication.cleanupOnExit(); |
109 | | - BOOST_CHECK(!compatibility.isSealed()); |
110 | | - BOOST_REQUIRE(publication.completeAccepted({}, parameters, frame, true)); |
111 | | - BOOST_CHECK(compatibility.isSealed()); |
| 112 | + BOOST_CHECK(publication.sharedClusterFlags().empty()); |
| 113 | + BOOST_REQUIRE(publication.completeAccepted(indices, parameters, frame, true)); |
| 114 | + BOOST_REQUIRE_EQUAL(publication.sharedClusterFlags().size(), 1u); |
| 115 | + BOOST_CHECK_EQUAL(publication.sharedClusterFlags()[0], 0); |
112 | 116 | if (fail) { |
113 | 117 | throw std::runtime_error{"publication failure"}; |
114 | 118 | } |
115 | 119 | } catch (const std::runtime_error&) { |
116 | 120 | BOOST_CHECK(fail); |
117 | 121 | } |
118 | | - BOOST_CHECK(!compatibility.isSealed()); |
119 | | - BOOST_CHECK(compatibility.entries().empty()); |
| 122 | + BOOST_CHECK(publication.sharedClusterFlags().empty()); |
120 | 123 | } |
121 | 124 | } |
| 125 | + |
| 126 | +BOOST_AUTO_TEST_CASE(PublicationFlagsRequireFinalCompletionAndAcceptedIndices) |
| 127 | +{ |
| 128 | + o2::its::ca::PublicationAdapter publication; |
| 129 | + o2::itsmft::tracking::TimeFrame frame; |
| 130 | + frame.getGenericTracks().resize(3); |
| 131 | + o2::itsmft::IterationParameters parameters; |
| 132 | + parameters.AllowSharingFirstCluster = false; |
| 133 | + const std::array<uint32_t, 1> first{0}, last{2}, outOfRange{3}; |
| 134 | + BOOST_REQUIRE(publication.completeAccepted(first, parameters, frame, false)); |
| 135 | + BOOST_CHECK(publication.sharedClusterFlags().empty()); |
| 136 | + BOOST_REQUIRE(publication.completeAccepted(last, parameters, frame, true)); |
| 137 | + const auto flags = publication.sharedClusterFlags(); |
| 138 | + BOOST_REQUIRE_EQUAL(flags.size(), 3u); |
| 139 | + BOOST_CHECK_EQUAL(flags[0], 0); |
| 140 | + BOOST_CHECK_EQUAL(flags[1], std::numeric_limits<uint8_t>::max()); |
| 141 | + BOOST_CHECK_EQUAL(flags[2], 0); |
| 142 | + BOOST_CHECK(!publication.completeAccepted(last, parameters, frame, true)); |
| 143 | + BOOST_CHECK(publication.sharedClusterFlags().empty()); |
| 144 | + publication.reset(); |
| 145 | + BOOST_CHECK(!publication.completeAccepted(outOfRange, parameters, frame, true)); |
| 146 | + const std::array<uint32_t, 2> reversed{2, 0}, repeated{0, 0}; |
| 147 | + BOOST_CHECK(!publication.completeAccepted(reversed, parameters, frame, true)); |
| 148 | + BOOST_CHECK(!publication.completeAccepted(repeated, parameters, frame, true)); |
| 149 | + BOOST_REQUIRE(publication.completeAccepted(first, parameters, frame, false)); |
| 150 | + BOOST_REQUIRE(publication.completeAccepted({}, parameters, frame, true)); |
| 151 | + BOOST_REQUIRE_EQUAL(publication.sharedClusterFlags().size(), 1u); |
| 152 | + BOOST_CHECK_EQUAL(publication.sharedClusterFlags()[0], 0); |
| 153 | +} |
0 commit comments