|
14 | 14 | #include "Framework/AnalysisTask.h" |
15 | 15 | #include "Framework/AnalysisDataModel.h" |
16 | 16 | #include <iostream> |
| 17 | +#include <unistd.h> |
17 | 18 |
|
18 | 19 | #include <catch_amalgamated.hpp> |
19 | 20 |
|
@@ -197,6 +198,46 @@ struct MTask { |
197 | 198 | void process(aod::McCollision const&, soa::SmallGroups<soa::Join<aod::Collisions, aod::McCollisionLabels>> const&) {} |
198 | 199 | }; |
199 | 200 |
|
| 201 | +struct BuildCounter { |
| 202 | + static inline int built = 0; |
| 203 | + BuildCounter() { ++built; } |
| 204 | +}; |
| 205 | + |
| 206 | +struct CountedTask { |
| 207 | + BuildCounter counter; |
| 208 | + void process(aod::Tracks const&) {} |
| 209 | +}; |
| 210 | + |
| 211 | +TEST_CASE("AdaptorBuildsOnlyTheTaskOfTheDevice") |
| 212 | +{ |
| 213 | + auto cfgc = makeEmptyConfigContext(); |
| 214 | + // A device gets the workflow from the driver on stdin. |
| 215 | + int fds[2]; |
| 216 | + REQUIRE(pipe(fds) == 0); |
| 217 | + int stdinCopy = dup(STDIN_FILENO); |
| 218 | + dup2(fds[0], STDIN_FILENO); |
| 219 | + char const* otherArgs[] = {"workflow", "--id", "another-task"}; |
| 220 | + char const* ownArgs[] = {"workflow", "--id", "counted-task_t1"}; |
| 221 | + ConfigContext otherDevice{cfgc->options(), cfgc->services(), 3, const_cast<char**>(otherArgs)}; |
| 222 | + ConfigContext ownDevice{cfgc->options(), cfgc->services(), 3, const_cast<char**>(ownArgs)}; |
| 223 | + auto skipped = adaptAnalysisTask<CountedTask>(otherDevice); |
| 224 | + auto own = adaptAnalysisTask<CountedTask>(ownDevice); |
| 225 | + auto renamed = adaptAnalysisTask<CountedTask>(otherDevice, SetDefaultProcesses{}, TaskName{"another-task"}); |
| 226 | + dup2(stdinCopy, STDIN_FILENO); |
| 227 | + close(stdinCopy); |
| 228 | + close(fds[0]); |
| 229 | + close(fds[1]); |
| 230 | + auto driver = adaptAnalysisTask<CountedTask>(*cfgc); |
| 231 | + |
| 232 | + REQUIRE(BuildCounter::built == 3); |
| 233 | + REQUIRE(DataProcessorSpecHelpers::isPlaceholder(skipped)); |
| 234 | + REQUIRE(skipped.name == own.name); |
| 235 | + REQUIRE(skipped.inputs.empty()); |
| 236 | + REQUIRE(!DataProcessorSpecHelpers::isPlaceholder(own)); |
| 237 | + REQUIRE(own.inputs.size() == driver.inputs.size()); |
| 238 | + REQUIRE(!DataProcessorSpecHelpers::isPlaceholder(renamed)); |
| 239 | +} |
| 240 | + |
200 | 241 | TEST_CASE("AdaptorCompilation") |
201 | 242 | { |
202 | 243 | auto cfgc = makeEmptyConfigContext(); |
|
0 commit comments