2 #include "../../../tests/catch2/catch.hpp"
5 #include "../xindiserver.hpp"
29 SCENARIO(
"xindiserver constructs inserver options",
"[xindiserver]" )
31 GIVEN(
"A default constructed xindiserver")
38 WHEN(
"Option m with argument provided")
40 std::vector<std::string> clargs;
46 REQUIRE(clargs[0] ==
"indiserver");
53 WHEN(
"Option n provided")
55 std::vector<std::string> clargs;
61 REQUIRE(clargs[0] ==
"indiserver");
65 WHEN(
"Option p provided with argument")
67 std::vector<std::string> clargs;
73 REQUIRE(clargs[0] ==
"indiserver");
78 WHEN(
"1 Option v provided with argument (-v)")
80 std::vector<std::string> clargs;
86 REQUIRE(clargs[0] ==
"indiserver");
90 WHEN(
"2 Option v provided with argument (-vv)")
92 std::vector<std::string> clargs;
98 REQUIRE(clargs[0] ==
"indiserver");
102 WHEN(
"3 Option v provided with argument (3==>-vvv)")
104 std::vector<std::string> clargs;
110 REQUIRE(clargs[0] ==
"indiserver");
114 WHEN(
"Option v provided with argument (4==>-vvv)")
116 std::vector<std::string> clargs;
122 REQUIRE(clargs[0] ==
"indiserver");
126 WHEN(
"Option v provided with argument (0==>)")
128 std::vector<std::string> clargs;
134 REQUIRE(clargs[0] ==
"indiserver");
137 WHEN(
"Option x provided")
139 std::vector<std::string> clargs;
145 REQUIRE(clargs[0] ==
"indiserver");
149 WHEN(
"All options provided")
151 std::vector<std::string> clargs;
161 REQUIRE(clargs[0] ==
"indiserver");
173 SCENARIO(
"xindiserver constructs local driver arguments",
"[xindiserver]" )
175 GIVEN(
"A default constructed xindiserver")
182 WHEN(
"Single local driver")
184 std::vector<std::string> ml({
"driverX"});
187 std::vector<std::string> clargs;
191 REQUIRE(clargs[0] ==
"/opt/MagAOX/drivers/driverX");
194 WHEN(
"Two local drivers")
196 std::vector<std::string> ml({
"driverY",
"driverZ"});
199 std::vector<std::string> clargs;
203 REQUIRE(clargs[0] ==
"/opt/MagAOX/drivers/driverY");
204 REQUIRE(clargs[1] ==
"/opt/MagAOX/drivers/driverZ");
207 WHEN(
"Three local drivers")
209 std::vector<std::string> ml({
"driverX",
"driverY",
"driverZ"});
212 std::vector<std::string> clargs;
216 REQUIRE(clargs[0] ==
"/opt/MagAOX/drivers/driverX");
217 REQUIRE(clargs[1] ==
"/opt/MagAOX/drivers/driverY");
218 REQUIRE(clargs[2] ==
"/opt/MagAOX/drivers/driverZ");
221 WHEN(
"Three local drivers, with an error (@)")
223 std::vector<std::string> ml({
"driverX",
"driver@Y",
"driverZ"});
226 std::vector<std::string> clargs;
231 WHEN(
"Three local drivers, with an error (/)")
233 std::vector<std::string> ml({
"driver/X",
"driverY",
"driverZ"});
236 std::vector<std::string> clargs;
241 WHEN(
"Three local drivers, with an error (:)")
243 std::vector<std::string> ml({
"driverX",
"driverY",
"driver:Z"});
246 std::vector<std::string> clargs;
251 WHEN(
"Three local drivers, duplicate")
253 std::vector<std::string> ml({
"driverX",
"driverY",
"driverX"});
256 std::vector<std::string> clargs;
263 SCENARIO(
"xindiserver constructs remote driver arguments",
"[xindiserver]" )
265 GIVEN(
"A default constructed xindiserver")
272 WHEN(
"Single remote driver, single remote host")
274 std::vector<std::string> mr({
"driverX@host1"});
277 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1" },
278 {
"remoteHost",
"localPort",
"remotePort" },
279 {
"host1",
"1000",
"81" } );
280 mx::app::appConfigurator config;
281 config.readConfig(
"/tmp/xindiserver_test.conf");
285 std::vector<std::string> clargs;
289 REQUIRE(clargs[0] ==
"driverX@localhost:1000");
292 WHEN(
"Two remote drivers, single remote host")
294 std::vector<std::string> mr({
"driverX@host1",
"driverY@host1"});
297 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1" },
298 {
"remoteHost",
"localPort",
"remotePort" },
299 {
"host1",
"1000",
"81" } );
300 mx::app::appConfigurator config;
301 config.readConfig(
"/tmp/xindiserver_test.conf");
306 std::vector<std::string> clargs;
310 REQUIRE(clargs[0] ==
"driverX@localhost:1000");
311 REQUIRE(clargs[1] ==
"driverY@localhost:1000");
315 WHEN(
"Two remote drivers, two remote hosts")
317 std::vector<std::string> mr({
"driverX@host1",
"driverY@host2"});
320 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1",
"host2",
"host2",
"host2" },
321 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
322 {
"host1",
"1000",
"81" ,
"host2",
"1002",
"86"} );
323 mx::app::appConfigurator config;
324 config.readConfig(
"/tmp/xindiserver_test.conf");
329 std::vector<std::string> clargs;
333 REQUIRE(clargs[0] ==
"driverX@localhost:1000");
334 REQUIRE(clargs[1] ==
"driverY@localhost:1002");
338 WHEN(
"Three remote drivers, two remote hosts, in order")
340 std::vector<std::string> mr({
"driverX@host1",
"driverZ@host1",
"driverY@host2"});
343 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1",
"host2",
"host2",
"host2" },
344 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
345 {
"host1",
"1000",
"81" ,
"host2",
"1002",
"86"} );
347 mx::app::appConfigurator config;
348 config.readConfig(
"/tmp/xindiserver_test.conf");
353 std::vector<std::string> clargs;
358 REQUIRE(clargs[0] ==
"driverX@localhost:1000");
359 REQUIRE(clargs[1] ==
"driverZ@localhost:1000");
360 REQUIRE(clargs[2] ==
"driverY@localhost:1002");
364 WHEN(
"Three remote drivers, two remote hosts, arb order")
366 std::vector<std::string> mr({
"driverX@host1",
"driverZ@host2",
"driverY@host1"});
369 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1",
"host2",
"host2",
"host2" },
370 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
371 {
"host1",
"1000",
"81" ,
"host2",
"1002",
"86"} );
373 mx::app::appConfigurator config;
374 config.readConfig(
"/tmp/xindiserver_test.conf");
379 std::vector<std::string> clargs;
384 REQUIRE(clargs[0] ==
"driverX@localhost:1000");
385 REQUIRE(clargs[1] ==
"driverZ@localhost:1002");
386 REQUIRE(clargs[2] ==
"driverY@localhost:1000");
389 WHEN(
"Three remote drivers, two remote hosts, error in host")
391 std::vector<std::string> mr({
"driverX@host1",
"driverZ@host2",
"driverY@host1"});
394 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1",
"host2",
"host2" },
395 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort" },
396 {
"exao2",
"1000",
"81" ,
"exao2",
"1002"} );
398 mx::app::appConfigurator config;
399 config.readConfig(
"/tmp/xindiserver_test.conf");
404 std::vector<std::string> clargs;
409 WHEN(
"Three remote drivers, two remote hosts, error in driver")
411 std::vector<std::string> mr({
"driverX",
"driverZ@host2",
"driverY@host1"});
414 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1",
"host2",
"host2",
"host2" },
415 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
416 {
"host1",
"1000",
"81" ,
"host2",
"1002",
"86"} );
418 mx::app::appConfigurator config;
419 config.readConfig(
"/tmp/xindiserver_test.conf");
424 std::vector<std::string> clargs;
429 WHEN(
"Three remote drivers, two remote hosts, duplicate driver")
431 std::vector<std::string> mr({
"driverX@host2",
"driverX@host1",
"driverY@host1"});
434 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1",
"host2",
"host2",
"host2" },
435 {
"remoteHost",
"localPort",
"remotePort",
"remoteHost",
"localPort",
"remotePort" },
436 {
"host1",
"1000",
"81" ,
"host2",
"1002",
"86"} );
438 mx::app::appConfigurator config;
439 config.readConfig(
"/tmp/xindiserver_test.conf");
442 std::vector<std::string> clargs;
449 SCENARIO(
"xindiserver constructs both local and remote driver arguments",
"[xindiserver]" )
451 GIVEN(
"A default constructed xindiserver")
458 WHEN(
"single local driver, single remote driver, single remote host")
461 std::vector<std::string> ml({
"driverX"});
464 std::vector<std::string> mr({
"driverY@host1"});
467 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1" },
468 {
"remoteHost",
"localPort",
"remotePort" },
469 {
"host1",
"1000",
"81" } );
470 mx::app::appConfigurator config;
471 config.readConfig(
"/tmp/xindiserver_test.conf");
475 std::vector<std::string> clargs;
485 REQUIRE(clargs[0] ==
"driverY@localhost:1000");
486 REQUIRE(clargs[1] ==
"/opt/MagAOX/drivers/driverX");
489 WHEN(
"single local driver, single remote driver, single remote host -- duplicate driver")
492 std::vector<std::string> ml({
"driverX"});
495 std::vector<std::string> mr({
"driverX@host1"});
498 mx::app::writeConfigFile(
"/tmp/xindiserver_test.conf", {
"host1",
"host1",
"host1" },
499 {
"remoteHost",
"localPort",
"remotePort" },
500 {
"host1",
"1000",
"81" } );
501 mx::app::appConfigurator config;
502 config.readConfig(
"/tmp/xindiserver_test.conf");
506 std::vector<std::string> clargs;
int indiserver_m
The indiserver MB behind setting (passed to indiserver)
int addRemoteDrivers(std::vector< std::string > &driverArgs)
Validate the remote driver entries, and append them to the indi server command line arguments.
std::vector< std::string > m_local
List of local drivers passed in by config.
bool indiserver_n
The indiserver ignore /tmp/noindi flag (passed to indiserver)
int addLocalDrivers(std::vector< std::string > &driverArgs)
Validate the local driver strings, and append them to the indi server command line arguments.
bool indiserver_x
The indiserver terminate after last exit flag (passed to indiserver)
std::vector< std::string > m_remote
List of remote drivers passed in by config.
tunnelMapT m_tunnels
Map of the ssh tunnels, used for processing the remote drivers in m_remote.
int indiserver_v
The indiserver verbosity (passed to indiserver)
int indiserver_p
The indiserver port (passed to indiserver)
int constructIndiserverCommand(std::vector< std::string > &indiserverCommand)
Construct the vector of indiserver arguments for exec.
std::unordered_map< std::string, sshTunnel > tunnelMapT
The map used to hold tunnel specifications.
int loadSSHTunnelConfigs(tunnelMapT &tmap, mx::app::appConfigurator &config)
Create the tunnel map from a configurator.
void m_local(xindiserver &xi, const std::vector< std::string > &ml)
void indiserver_n(xindiserver &xi, const bool &n)
void indiserver_p(xindiserver &xi, const int &p)
void indiserver_m(xindiserver &xi, const int &m)
tunnelMapT & tunnelMap(xindiserver &xi)
void indiserver_v(xindiserver &xi, const int &v)
void indiserver_x(xindiserver &xi, const bool &x)
void m_remote(xindiserver &xi, const std::vector< std::string > &mr)
#define XINDISERVER_E_BADDRIVERSPEC
#define XINDISERVER_E_DUPLICATEDRIVER
#define XINDISERVER_E_TUNNELNOTFOUND
SCENARIO("xindiserver constructs inserver options", "[xindiserver]")