17#include "../src/DeviceSpecHelpers.h"
18#include <catch_amalgamated.hpp>
24#include "../src/SimpleResourceManager.h"
25#include "../src/ComputingResourceHelpers.h"
30using CheckMatrix = std::map<std::string, std::vector<std::pair<std::string, std::string>>>;
35 bool foundOption =
false;
36 for (
auto const& execArg : execution.
args) {
37 if (execArg ==
nullptr) {
41 foundOption = option == execArg;
42 }
else if (argument == execArg) {
55 const std::vector<ConfigParamSpec>& workflowOptions,
56 const std::vector<DeviceSpec>& deviceSpecs,
64 std::vector<DeviceExecution> deviceExecutions(deviceSpecs.size());
65 std::vector<DeviceControl> deviceControls(deviceSpecs.size());
66 std::vector<DataProcessorInfo> dataProcessorInfos;
67 for (
auto& [
name, _] : matrix) {
70 .executable =
"executable-name",
72 .workflowOptions = workflowOptions,
85 const auto& deviceSpec = deviceSpecs[
index];
86 const auto& deviceExecution = deviceExecutions[
index];
87 std::stringstream execArgs;
88 for (
const auto& arg : deviceExecution.args) {
93 execArgs <<
" " << arg;
95 for (
auto const& testCase : matrix[deviceSpec.name]) {
96 INFO(std::string(
"can not find option: ") + testCase.first +
" " + testCase.second);
97 REQUIRE(
search(deviceExecution, testCase.first, testCase.second));
104 std::vector<ConfigParamSpec> workflowOptions{
114 {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe}},
120 {
InputSpec{
"input",
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe}},
128 std::vector<DeviceSpec> deviceSpecs;
131 auto rm = std::make_unique<SimpleResourceManager>(resources);
142 *rm,
"workflow-id", *configContext);
149 matrix[
"processor0"] = {{
"--depth",
"1"}, {
"--foo",
"bar"}, {
"--mode",
"default"}};
150 matrix[
"processor1"] = matrix[
"processor0"];
151 check({}, workflowOptions, deviceSpecs, matrix);
154 check({
"--unknown",
"option"}, workflowOptions, deviceSpecs, matrix);
157 matrix[
"processor0"] = {{
"--depth",
"1"}, {
"--foo",
"bar"}, {
"--mode",
"silly"}};
158 matrix[
"processor1"] = matrix[
"processor0"];
159 check({
"--mode",
"silly"}, workflowOptions, deviceSpecs, matrix);
162 matrix[
"processor0"] = {{
"--depth",
"1"}, {
"--foo",
"bar"}, {
"--mode",
"silly"}};
163 matrix[
"processor1"] = {{
"--depth",
"1"}, {
"--foo",
"bar"}, {
"--mode",
"default"}};
164 check({
"--processor0",
"--mode silly"}, workflowOptions, deviceSpecs, matrix);
167 matrix[
"processor0"] = {{
"--depth",
"1"}, {
"--foo",
"bar"}, {
"--mode",
"silly"}};
168 matrix[
"processor1"] = {{
"--depth",
"1"}, {
"--foo",
"bar"}, {
"--mode",
"advanced"}};
169 check({
"--mode",
"advanced",
"--processor0",
"--mode silly"}, workflowOptions, deviceSpecs, matrix);
172 matrix[
"processor0"] = {{
"--depth",
"2"}, {
"--foo",
"bar"}, {
"--mode",
"default"}};
173 matrix[
"processor1"] = matrix[
"processor0"];
174 check({
"--depth",
"2"}, workflowOptions, deviceSpecs, matrix);
177 matrix[
"processor0"] = {{
"--depth",
"2"}, {
"--foo",
"bar"}, {
"--mode",
"silly"}};
178 matrix[
"processor1"] = {{
"--depth",
"2"}, {
"--foo",
"bar"}, {
"--mode",
"default"}};
179 check({
"--depth",
"2",
"--processor0",
"--mode silly"}, workflowOptions, deviceSpecs, matrix);
185 std::vector<DataProcessorInfo> infos = {
186 {.cmdLineArgs = {
"--driver-client-backend",
"foo"}},
189 REQUIRE(infos[0].cmdLineArgs[1] ==
"foo");
190 REQUIRE(infos[1].cmdLineArgs[1] ==
"foo");
193 std::vector<DataProcessorInfo> infos = {
194 {.cmdLineArgs = {
"--driver-client-backend",
"foo"}},
195 {.cmdLineArgs = {
"--driver-client-backend",
"bar"}}};
199 std::vector<DataProcessorInfo> infos = {
200 {.cmdLineArgs = {
"--driver-client-backend",
"foo"}},
201 {.cmdLineArgs = {
"--driver-client-backend",
"foo"}}};
203 REQUIRE(infos[0].cmdLineArgs[1] ==
"foo");
204 REQUIRE(infos[1].cmdLineArgs[1] ==
"foo");
207 std::vector<DataProcessorInfo> infos = {
208 {.cmdLineArgs = {
"foo",
"bar"}},
209 {.cmdLineArgs = {
"fnjcnak",
"foo"}}};
211 REQUIRE(infos[0].cmdLineArgs[3] ==
"stdout://");
212 REQUIRE(infos[1].cmdLineArgs[3] ==
"stdout://");
215 std::vector<DataProcessorInfo> infos = {
216 {.cmdLineArgs = {
"foo",
"bar",
"--driver-client-backend",
"bar"}},
217 {.cmdLineArgs = {
"fnjcnak",
"foo"}}};
219 REQUIRE(infos[0].cmdLineArgs[3] ==
"bar");
220 REQUIRE(infos[1].cmdLineArgs[3] ==
"bar");
227 std::vector<DataProcessorInfo> infos = {
228 {{}, {}, {
"--readers",
"2"}},
231 infos,
"--readers",
nullptr, 1, [](
long long x,
long long y) {
return x >
y ?
x :
y; });
232 REQUIRE(infos[0].cmdLineArgs[1] ==
"2");
233 REQUIRE(infos[1].cmdLineArgs[1] ==
"2");
236 std::vector<DataProcessorInfo> infos = {
240 infos,
"--readers",
nullptr, 1, [](
long long x,
long long y) {
return x >
y ?
x :
y; });
241 REQUIRE(infos[0].cmdLineArgs.size() == 0);
242 REQUIRE(infos[1].cmdLineArgs.size() == 0);
245 std::vector<DataProcessorInfo> infos = {
249 infos,
"--readers", []() {
return 1; }, 3, [](
long long x,
long long y) {
return x >
y ?
x :
y; });
250 REQUIRE(infos[0].cmdLineArgs.size() == 2);
251 REQUIRE(infos[1].cmdLineArgs.size() == 2);
252 REQUIRE(infos[0].cmdLineArgs[1] ==
"1");
253 REQUIRE(infos[1].cmdLineArgs[1] ==
"1");
256 std::vector<DataProcessorInfo> infos = {
257 {{}, {}, {
"--readers",
"2"}},
258 {{}, {}, {
"--readers",
"3"}}};
260 infos,
"--readers", []() {
return 1; }, 1, [](
long long x,
long long y) {
return x >
y ?
x :
y; });
261 REQUIRE(infos[0].cmdLineArgs.size() == 2);
262 REQUIRE(infos[1].cmdLineArgs.size() == 2);
263 REQUIRE(infos[0].cmdLineArgs[1] ==
"3");
264 REQUIRE(infos[1].cmdLineArgs[1] ==
"3");
267 std::vector<DataProcessorInfo> infos = {
268 {{}, {}, {
"--readers",
"3"}},
269 {{}, {}, {
"--readers",
"2"}}};
271 infos,
"--readers", []() {
return 1; }, 1, [](
long long x,
long long y) {
return x >
y ?
x :
y; });
272 REQUIRE(infos[0].cmdLineArgs.size() == 2);
273 REQUIRE(infos[1].cmdLineArgs.size() == 2);
274 REQUIRE(infos[0].cmdLineArgs[1] ==
"3");
275 REQUIRE(infos[1].cmdLineArgs[1] ==
"3");
278 std::vector<DataProcessorInfo> infos = {
279 {.cmdLineArgs = {
"foo",
"bar",
"--readers",
"3"}},
280 {.cmdLineArgs = {
"--readers",
"2"}}};
282 infos,
"--readers", []() {
return 1; }, 1, [](
long long x,
long long y) {
return x >
y ?
x :
y; });
283 REQUIRE(infos[0].cmdLineArgs.size() == 4);
284 REQUIRE(infos[1].cmdLineArgs.size() == 2);
285 REQUIRE(infos[0].cmdLineArgs[3] ==
"3");
286 REQUIRE(infos[1].cmdLineArgs[1] ==
"3");
294 .name =
"processor0",
295 .outputs = {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe}},
298 .name =
"processor1",
299 .inputs = {
InputSpec{
"input",
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe}},
306 .name =
"processor0",
307 .outputs = {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe},
308 OutputSpec{{
"output2"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe}},
311 .name =
"processor1",
312 .inputs = {
InputSpec{
"input",
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe}},
319 .name =
"processor0",
320 .outputs = {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe},
321 OutputSpec{{
"output2"},
"TST",
"DUMMYDATA", 2, Lifetime::Sporadic}},
324 .name =
"processor1",
325 .outputs = {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 1, Lifetime::Timeframe},
326 OutputSpec{{
"output2"},
"TST",
"DUMMYDATA", 2, Lifetime::Sporadic}},
329 .name =
"processor2",
330 .inputs = {
InputSpec{
"input",
"TST",
"DUMMYDATA", 2, Lifetime::Timeframe}},
337 .name =
"processor0",
338 .outputs = {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe},
339 OutputSpec{{
"output2"},
"TST",
"DUMMYDATA", 2, Lifetime::Sporadic}},
342 .name =
"processor1",
343 .outputs = {
OutputSpec{{
"output"},
"TST",
"DUMMYDATA", 0, Lifetime::Timeframe},
344 OutputSpec{{
"output2"},
"TST",
"DUMMYDATA", 2, Lifetime::Sporadic}},
347 .name =
"processor2",
348 .inputs = {
InputSpec{
"input",
"TST",
"DUMMYDATA", 2, Lifetime::Timeframe}},
357 std::string env =
"FOO={timeslice0}";
359 env =
"FOO={timeslice0} BAR={timeslice4}";
361 env =
"FOO={timeslice0} BAR={timeslice4} BAZ={timeslice5}";
369 env =
"{timeslicepluto";
std::unique_ptr< ConfigContext > makeEmptyConfigContext()
GLuint const GLchar * name
bpo::variables_map arguments
Defining PrimaryVertex explicitly as messageable.
void check(const std::vector< std::string > &arguments, const std::vector< ConfigParamSpec > &workflowOptions, const std::vector< DeviceSpec > &deviceSpecs, CheckMatrix &matrix)
TEST_CASE("test_prepareArguments")
bool search(DeviceExecution const &execution, std::string const &option, std::string const &argument)
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< ConfigParamSpec > Options
std::map< std::string, std::vector< std::pair< std::string, std::string > > > CheckMatrix
static std::vector< CallbacksPolicy > createDefaultPolicies()
static std::vector< ChannelConfigurationPolicy > createDefaultPolicies(ConfigContext const &configContext)
Default policies to use, based on the contents of the @configContex content.
static std::vector< CompletionPolicy > createDefaultPolicies()
Helper to create the default configuration.
static ComputingResource getLocalhostResource()
std::string name
Name of the associated DataProcessorSpec.
std::vector< char * > args
The options passed to a given device.
static void validate(WorkflowSpec const &workflow)
static std::string reworkTimeslicePlaceholder(std::string const &str, DeviceSpec const &spec)
static void prepareArguments(bool defaultQuiet, bool defaultStopped, bool intereactive, unsigned short driverPort, DriverConfig const &driverConfig, std::vector< DataProcessorInfo > const &processorInfos, std::vector< DeviceSpec > const &deviceSpecs, std::vector< DeviceExecution > &deviceExecutions, std::vector< DeviceControl > &deviceControls, std::vector< ConfigParamSpec > const &detectedOptions, std::string const &uniqueWorkflowId)
static void reworkHomogeneousOption(std::vector< DataProcessorInfo > &infos, char const *name, char const *defaultValue)
static void reworkIntegerOption(std::vector< DataProcessorInfo > &infos, char const *name, std::function< long long()> defaultValueCallback, long long startValue, std::function< long long(long long, long long)> bestValue)
static void dataProcessorSpecs2DeviceSpecs(const WorkflowSpec &workflow, std::vector< ChannelConfigurationPolicy > const &channelPolicies, std::vector< CompletionPolicy > const &completionPolicies, std::vector< DispatchPolicy > const &dispatchPolicies, std::vector< ResourcePolicy > const &resourcePolicies, std::vector< CallbacksPolicy > const &callbacksPolicies, std::vector< SendingPolicy > const &sendingPolicy, std::vector< ForwardingPolicy > const &forwardingPolicies, std::vector< DeviceSpec > &devices, ResourceManager &resourceManager, std::string const &uniqueWorkflowId, ConfigContext const &configContext, bool optimizeTopology=false, unsigned short resourcesMonitoringInterval=0, std::string const &channelPrefix="", OverrideServiceSpecs const &overrideServices={})
size_t inputTimesliceId
The time pipelining id of this particular device.