Instrument Neutral Distributed Interface INDI 2.2.5
test_lx200_onstep.cpp
Go to the documentation of this file.
1/*
2 Regression tests for the LX200 OnStep driver: every goto must be answered with an EQUATORIAL_EOD_COORD
3 update, also a goto that OnStep completes before the next status poll without changing the reported
4 position (e.g. a goto to the position the mount is already at). Clients mark the property busy when they
5 send a goto and wait for the driver's answer, so a goto without an answer leaves them waiting forever.
6
7 The driver talks to a fake OnStep controller on a pseudo terminal. Its replies are copied from a log
8 of a real OnStep 4.24 controller.
9
10 SPDX-License-Identifier: LGPL-2.1-or-later
11*/
12
13#include <gtest/gtest.h>
14
15#include <atomic>
16#include <chrono>
17#include <cstdio>
18#include <cstdlib>
19#include <fcntl.h>
20#include <map>
21#include <mutex>
22#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__)
23#include <util.h>
24#elif defined(__FreeBSD__)
25#include <libutil.h>
26#else
27#include <pty.h>
28#endif
29#include <regex>
30#include <string>
31#include <termios.h>
32#include <thread>
33#include <unistd.h>
34#include <vector>
35
36#include "indilogger.h"
38
39namespace
40{
41
42// OnStep :GU# status strings. 'N' = not slewing, 'n' = not tracking, 'p' = not parked.
43const char *STATUS_TRACKING = "Npa/ET160";
44const char *STATUS_SLEWING = "pa/ET160";
45
46// Fake OnStep controller answering the commands the driver sends during a goto and a status poll.
47class FakeOnStep
48{
49 public:
50 FakeOnStep()
51 {
52 if (openpty(&m_Master, &m_Slave, nullptr, nullptr, nullptr) != 0)
53 return;
54 makeRaw(m_Master);
55 makeRaw(m_Slave);
56 m_Thread = std::thread(&FakeOnStep::serve, this);
57 }
58
59 ~FakeOnStep()
60 {
61 m_Stop = true;
62 if (m_Thread.joinable())
63 m_Thread.join();
64 if (m_Slave >= 0)
65 close(m_Slave);
66 if (m_Master >= 0)
67 close(m_Master);
68 }
69
70 int driverFD() const
71 {
72 return m_Slave;
73 }
74
75 void setStatus(const std::string &status, const std::string &ra, const std::string &dec)
76 {
77 std::lock_guard<std::mutex> lock(m_Mutex);
78 m_Status = status;
79 m_RA = ra;
80 m_DEC = dec;
81 }
82
83 int gotos()
84 {
85 std::lock_guard<std::mutex> lock(m_Mutex);
86 return m_Gotos;
87 }
88
89 // Leave the next n :GU# requests unanswered, as a real controller sometimes does right after :MS#.
90 void dropStatusReplies(int n)
91 {
92 std::lock_guard<std::mutex> lock(m_Mutex);
93 m_DropStatusReplies = n;
94 }
95
96 private:
97 static void makeRaw(int fd)
98 {
99 struct termios tio;
100 tcgetattr(fd, &tio);
101 cfmakeraw(&tio);
102 tcsetattr(fd, TCSANOW, &tio);
103 }
104
105 void serve()
106 {
107 std::string buffer;
108 while (!m_Stop)
109 {
110 fd_set readSet;
111 FD_ZERO(&readSet);
112 FD_SET(m_Master, &readSet);
113 struct timeval timeout = {0, 20000};
114 if (select(m_Master + 1, &readSet, nullptr, nullptr, &timeout) <= 0)
115 continue;
116
117 char chunk[256];
118 ssize_t n = read(m_Master, chunk, sizeof(chunk));
119 if (n <= 0)
120 continue;
121 buffer.append(chunk, n);
122
123 size_t end;
124 while ((end = buffer.find('#')) != std::string::npos)
125 {
126 // Commands start at the first ':' (RA/DEC arguments contain ':' too)
127 size_t start = buffer.find(':');
128 std::string command = (start != std::string::npos && start < end) ? buffer.substr(start, end - start + 1) : "";
129 buffer.erase(0, end + 1);
130 if (!command.empty())
131 reply(command);
132 }
133 }
134 }
135
136 void reply(const std::string &command)
137 {
138 std::string answer;
139 {
140 std::lock_guard<std::mutex> lock(m_Mutex);
141 if (command == ":GU#" && m_DropStatusReplies > 0)
142 m_DropStatusReplies--;
143 else if (command == ":GU#")
144 answer = m_Status + "#";
145 else if (command == ":GR#")
146 answer = m_RA + "#";
147 else if (command == ":GD#")
148 answer = m_DEC + "#";
149 else if (command.rfind(":Sr", 0) == 0 || command.rfind(":Sd", 0) == 0)
150 answer = "1";
151 else if (command == ":MS#")
152 {
153 // Goto accepted
154 answer = "0";
155 m_Gotos++;
156 }
157 else if (command == ":Q#")
158 answer = "";
159 else if (command == ":GX90#")
160 answer = "0.50#";
161 else if (command == ":GX96#")
162 answer = "E#";
163 else if (command == ":Go#")
164 answer = "80*#";
165 else if (command == ":Gh#")
166 answer = "+5*#";
167 else if (command == ":A?#")
168 answer = "900#";
169 else
170 answer = "0#";
171 }
172 if (!answer.empty() && write(m_Master, answer.data(), answer.size()) < 0)
173 return;
174 }
175
176 int m_Master {-1};
177 int m_Slave {-1};
178 std::thread m_Thread;
179 std::atomic<bool> m_Stop {false};
180 std::mutex m_Mutex;
181 std::string m_Status {STATUS_TRACKING};
182 std::string m_RA {"17:57:13"};
183 std::string m_DEC {"+51*29:19"};
184 int m_Gotos {0};
185 int m_DropStatusReplies {0};
186};
187
188class OnStepUnderTest : public LX200_OnStep
189{
190 public:
191 explicit OnStepUnderTest(int fd)
192 {
193 setDeviceName("Mock OnStep");
194 initProperties();
195 PortFD = fd;
196 }
197
198 bool poll()
199 {
200 return ReadScopeStatus();
201 }
202
203 // Send a goto the way a client does it.
204 bool requestGoto(double ra, double dec)
205 {
206 double values[2] = {ra, dec};
207 char ra_name[] = "RA", dec_name[] = "DEC";
208 char *names[2] = {ra_name, dec_name};
209 return ISNewNumber(getDeviceName(), "EQUATORIAL_EOD_COORD", values, names, 2);
210 }
211
212 // Send a park request the way a client does it.
213 bool requestPark()
214 {
215 ISState states[2] = {ISS_ON, ISS_OFF};
216 char park_name[] = "PARK", unpark_name[] = "UNPARK";
217 char *names[2] = {park_name, unpark_name};
218 return ISNewSwitch(getDeviceName(), "TELESCOPE_PARK", states, names, 2);
219 }
220
221 bool parked()
222 {
223 return isParked();
224 }
225
226 void setParkTimeoutSeconds(int seconds)
227 {
228 m_ParkTimeoutSeconds = seconds;
229 }
230};
231
232// Captures what the driver publishes on stdout and returns the states of the EQUATORIAL_EOD_COORD updates.
233class PublishedStates
234{
235 public:
236 PublishedStates()
237 {
238 fflush(stdout);
239 m_File = tmpfile();
240 m_SavedStdout = dup(STDOUT_FILENO);
241 dup2(fileno(m_File), STDOUT_FILENO);
242 }
243
244 ~PublishedStates()
245 {
246 restore();
247 if (m_File)
248 fclose(m_File);
249 }
250
251 std::vector<std::string> eqStates()
252 {
253 return states("setNumberVector", "EQUATORIAL_EOD_COORD");
254 }
255
256 std::vector<std::string> parkStates()
257 {
258 return states("setSwitchVector", "TELESCOPE_PARK");
259 }
260
261 private:
262 std::vector<std::string> states(const std::string &vector, const std::string &property)
263 {
264 restore();
265 std::string text;
266 rewind(m_File);
267 char chunk[4096];
268 size_t n;
269 while ((n = fread(chunk, 1, sizeof(chunk), m_File)) > 0)
270 text.append(chunk, n);
271
272 std::vector<std::string> states;
273 std::regex update("<" + vector + "[^>]*name=['\"]" + property + "['\"][^>]*state=['\"](\\w+)['\"]");
274 for (auto it = std::sregex_iterator(text.begin(), text.end(), update); it != std::sregex_iterator(); ++it)
275 states.push_back((*it)[1]);
276 return states;
277 }
278
279 void restore()
280 {
281 if (m_SavedStdout < 0)
282 return;
283 fflush(stdout);
284 dup2(m_SavedStdout, STDOUT_FILENO);
285 close(m_SavedStdout);
286 m_SavedStdout = -1;
287 }
288
289 FILE *m_File {nullptr};
290 int m_SavedStdout {-1};
291};
292
293const double ELTANIN_RA = 17.0 + 57.0 / 60 + 13.0 / 3600;
294const double ELTANIN_DEC = 51.0 + 29.0 / 60 + 19.0 / 3600;
295
296}
297
298// The mount already sits on the target and keeps tracking: OnStep never reports a slew and the position doesn't
299// change. The driver must still answer the goto, first busy, then the tracking state after the next poll.
300TEST(LX200OnStepTest, gotoToCurrentPositionIsAnswered)
301{
302 FakeOnStep mount;
303 ASSERT_GE(mount.driverFD(), 0);
304 OnStepUnderTest driver(mount.driverFD());
305
306 ASSERT_TRUE(driver.poll());
307
308 PublishedStates published;
309 ASSERT_TRUE(driver.requestGoto(ELTANIN_RA, ELTANIN_DEC));
310 ASSERT_TRUE(driver.poll());
311 ASSERT_TRUE(driver.poll());
312 std::vector<std::string> states = published.eqStates();
313
314 EXPECT_EQ(mount.gotos(), 1);
315 ASSERT_FALSE(states.empty()) << "The goto was never answered";
316 EXPECT_EQ(states.front(), "Busy");
317 EXPECT_EQ(states.back(), "Ok");
318}
319
320// Same, with the reported position 1" off the target before and after the goto (OnStep doesn't move for it).
321TEST(LX200OnStepTest, gotoWithoutPositionChangeIsAnswered)
322{
323 FakeOnStep mount;
324 ASSERT_GE(mount.driverFD(), 0);
325 mount.setStatus(STATUS_TRACKING, "17:57:13", "+51*29:18");
326 OnStepUnderTest driver(mount.driverFD());
327
328 ASSERT_TRUE(driver.poll());
329
330 PublishedStates published;
331 ASSERT_TRUE(driver.requestGoto(ELTANIN_RA, ELTANIN_DEC));
332 ASSERT_TRUE(driver.poll());
333 std::vector<std::string> states = published.eqStates();
334
335 ASSERT_FALSE(states.empty()) << "The goto was never answered";
336 EXPECT_EQ(states.front(), "Busy");
337 EXPECT_EQ(states.back(), "Ok");
338}
339
340// A real slew: busy while OnStep reports slewing, tracking only once it reports the slew done.
341TEST(LX200OnStepTest, realSlewStaysBusyUntilOnStepReportsTracking)
342{
343 FakeOnStep mount;
344 ASSERT_GE(mount.driverFD(), 0);
345 mount.setStatus(STATUS_TRACKING, "17:31:01", "+52*17:02");
346 OnStepUnderTest driver(mount.driverFD());
347
348 ASSERT_TRUE(driver.poll());
349
350 PublishedStates published;
351 ASSERT_TRUE(driver.requestGoto(ELTANIN_RA, ELTANIN_DEC));
352 mount.setStatus(STATUS_SLEWING, "17:44:07", "+51*53:10");
353 ASSERT_TRUE(driver.poll());
354 mount.setStatus(STATUS_SLEWING, "17:57:10", "+51*29:40");
355 ASSERT_TRUE(driver.poll());
356 std::vector<std::string> whileSlewing = published.eqStates();
357
358 ASSERT_FALSE(whileSlewing.empty());
359 for (const auto &state : whileSlewing)
360 EXPECT_EQ(state, "Busy");
361
362 PublishedStates afterSlew;
363 mount.setStatus(STATUS_TRACKING, "17:57:13", "+51*29:19");
364 ASSERT_TRUE(driver.poll());
365 std::vector<std::string> states = afterSlew.eqStates();
366
367 ASSERT_FALSE(states.empty());
368 EXPECT_EQ(states.back(), "Ok");
369}
370
371// The controller doesn't answer the first status poll after the goto (seen on a WD-20EP 50 ms after :MS#). The
372// driver must skip that poll instead of failing it: a failed poll puts EQUATORIAL_EOD_COORD into Alert, clients
373// then abort and resend the goto, which OnStep refuses with "Goto in progress".
374TEST(LX200OnStepTest, missedStatusReplyDuringGotoIsNotAnError)
375{
376 FakeOnStep mount;
377 ASSERT_GE(mount.driverFD(), 0);
378 mount.setStatus(STATUS_TRACKING, "17:31:01", "+52*17:02");
379 OnStepUnderTest driver(mount.driverFD());
380
381 ASSERT_TRUE(driver.poll());
382
383 PublishedStates published;
384 ASSERT_TRUE(driver.requestGoto(ELTANIN_RA, ELTANIN_DEC));
385 mount.setStatus(STATUS_SLEWING, "17:44:07", "+51*53:10");
386 mount.dropStatusReplies(1);
387 EXPECT_TRUE(driver.poll()) << "A missed :GU# reply failed the status poll";
388 ASSERT_TRUE(driver.poll());
389 mount.setStatus(STATUS_TRACKING, "17:57:13", "+51*29:19");
390 ASSERT_TRUE(driver.poll());
391 std::vector<std::string> states = published.eqStates();
392
393 ASSERT_FALSE(states.empty());
394 for (const auto &state : states)
395 EXPECT_NE(state, "Alert");
396 EXPECT_EQ(states.front(), "Busy");
397 EXPECT_EQ(states.back(), "Ok");
398 EXPECT_EQ(mount.gotos(), 1);
399}
400
401// OnStep :GU# while parking ('I' = park in progress), parked ('P') and after a failed park ('F').
402const char *STATUS_IDLE = "nNpa/ET160";
403const char *STATUS_PARKING = "nIa/ET160";
404const char *STATUS_PARKED = "nNPa/ET160";
405const char *STATUS_PARK_FAILED = "nNFa/ET160";
406
407// The park must stay busy until OnStep reports the mount parked. A client that waits for the park (e.g. a scheduler
408// before it disconnects) must not see it done while the mount still moves, also not on an early poll that doesn't
409// show the park yet.
410TEST(LX200OnStepTest, parkStaysBusyUntilOnStepReportsParked)
411{
412 FakeOnStep mount;
413 ASSERT_GE(mount.driverFD(), 0);
414 OnStepUnderTest driver(mount.driverFD());
415
416 ASSERT_TRUE(driver.poll());
417
418 PublishedStates published;
419 ASSERT_TRUE(driver.requestPark());
420 mount.setStatus(STATUS_IDLE, "02:34:50", "+61*34:42");
421 ASSERT_TRUE(driver.poll());
422 mount.setStatus(STATUS_PARKING, "03:10:12", "+75*02:44");
423 ASSERT_TRUE(driver.poll());
424 std::vector<std::string> whileParking = published.parkStates();
425 bool parkedEarly = driver.parked();
426
427 ASSERT_FALSE(whileParking.empty());
428 for (const auto &state : whileParking)
429 EXPECT_EQ(state, "Busy") << "The park was reported done before OnStep reported the mount parked";
430 EXPECT_FALSE(parkedEarly);
431
432 PublishedStates afterPark;
433 mount.setStatus(STATUS_PARKED, "06:01:00", "+89*59:59");
434 ASSERT_TRUE(driver.poll());
435 std::vector<std::string> states = afterPark.parkStates();
436
437 ASSERT_FALSE(states.empty());
438 EXPECT_EQ(states.back(), "Ok");
439 EXPECT_TRUE(driver.parked());
440}
441
442// A park that OnStep reports as failed ends with an error, not as parked.
443TEST(LX200OnStepTest, failedParkIsReported)
444{
445 FakeOnStep mount;
446 ASSERT_GE(mount.driverFD(), 0);
447 OnStepUnderTest driver(mount.driverFD());
448
449 ASSERT_TRUE(driver.poll());
450
451 PublishedStates published;
452 ASSERT_TRUE(driver.requestPark());
453 mount.setStatus(STATUS_PARKING, "03:10:12", "+75*02:44");
454 ASSERT_TRUE(driver.poll());
455 mount.setStatus(STATUS_PARK_FAILED, "04:00:00", "+80*00:00");
456 ASSERT_TRUE(driver.poll());
457 std::vector<std::string> states = published.parkStates();
458
459 ASSERT_FALSE(states.empty());
460 EXPECT_EQ(states.back(), "Alert");
461 EXPECT_FALSE(driver.parked());
462}
463
464// A controller that never reports the mount parked (no 'P') nor a failed park ('F') must not leave the park running
465// forever: after the park timeout it ends with an error.
466TEST(LX200OnStepTest, parkWithoutParkedStatusTimesOut)
467{
468 FakeOnStep mount;
469 ASSERT_GE(mount.driverFD(), 0);
470 OnStepUnderTest driver(mount.driverFD());
471 driver.setParkTimeoutSeconds(1);
472
473 ASSERT_TRUE(driver.poll());
474
475 PublishedStates published;
476 ASSERT_TRUE(driver.requestPark());
477 mount.setStatus(STATUS_PARKING, "03:10:12", "+75*02:44");
478 ASSERT_TRUE(driver.poll());
479 mount.setStatus(STATUS_IDLE, "06:01:00", "+89*59:59");
480 ASSERT_TRUE(driver.poll());
481 std::vector<std::string> beforeTimeout = published.parkStates();
482
483 PublishedStates afterTimeout;
484 std::this_thread::sleep_for(std::chrono::milliseconds(1200));
485 ASSERT_TRUE(driver.poll());
486 std::vector<std::string> states = afterTimeout.parkStates();
487
488 ASSERT_FALSE(beforeTimeout.empty());
489 for (const auto &state : beforeTimeout)
490 EXPECT_EQ(state, "Busy") << "The park ended before the timeout";
491 ASSERT_FALSE(states.empty()) << "The park was never ended";
492 EXPECT_EQ(states.back(), "Alert");
493 EXPECT_FALSE(driver.parked());
494}
495
496// A lost connection must still be reported: a single missed :GU# answer is skipped, but after
497// MAX_MISSED_STATUS_REPLIES in a row the poll fails (the base class then sets EQUATORIAL_EOD_COORD to Alert), and
498// the first answer afterwards ends the error.
499TEST(LX200OnStepTest, lostConnectionFailsPollAfterThreeMissedReplies)
500{
501 FakeOnStep mount;
502 ASSERT_GE(mount.driverFD(), 0);
503 OnStepUnderTest driver(mount.driverFD());
504
505 ASSERT_TRUE(driver.poll());
506
507 mount.dropStatusReplies(5);
508 std::vector<bool> results;
509 for (int i = 0; i < 5; i++)
510 results.push_back(driver.poll());
511 EXPECT_EQ(results, (std::vector<bool> {true, true, false, false, false}));
512
513 // The connection is back: polls succeed again, and a single missed answer is skipped again
514 EXPECT_TRUE(driver.poll());
515 mount.dropStatusReplies(1);
516 EXPECT_TRUE(driver.poll());
517 EXPECT_TRUE(driver.poll());
518}
519
520// OnStep :GU# of a mount that is idle with no error ('0') and with the meridian limit error ('7' = ERR_MERIDIAN).
521// Both seen on a WD-20EP: a goto with tracking off ends "nN...0", a goto that OnStep stopped at its meridian limit
522// ends "nN...7", and OnStep then keeps the error and accepts gotos without moving.
523const char *STATUS_MERIDIAN_LIMIT = "nNpa/ET167";
524
525// A goto that OnStep stops at a limit must be reported as failed (Alert), not as an idle mount: a client waiting
526// for the goto to end (e.g. Ekos Align waiting for tracking) would otherwise wait forever.
527TEST(LX200OnStepTest, gotoStoppedAtLimitIsReported)
528{
529 FakeOnStep mount;
530 ASSERT_GE(mount.driverFD(), 0);
531 mount.setStatus(STATUS_TRACKING, "03:48:37", "+24*14:05");
532 OnStepUnderTest driver(mount.driverFD());
533
534 ASSERT_TRUE(driver.poll());
535 ASSERT_TRUE(driver.requestGoto(3.0 + 48.0 / 60 + 37.0 / 3600, 24.0 + 14.0 / 60 + 5.0 / 3600));
536 mount.setStatus(STATUS_SLEWING, "04:20:00", "+40*00:00");
537 ASSERT_TRUE(driver.poll());
538
539 PublishedStates atStop;
540 mount.setStatus(STATUS_MERIDIAN_LIMIT, "03:49:10", "+24*29:00");
541 ASSERT_TRUE(driver.poll());
542 std::vector<std::string> states = atStop.eqStates();
543
544 ASSERT_FALSE(states.empty()) << "The end of the goto was never published";
545 EXPECT_EQ(states.front(), "Alert") << "The goto stopped at the limit was not reported as failed";
546
547 // The mount stays idle afterwards
548 PublishedStates afterStop;
549 mount.setStatus(STATUS_MERIDIAN_LIMIT, "03:49:14", "+24*29:00");
550 ASSERT_TRUE(driver.poll());
551 std::vector<std::string> later = afterStop.eqStates();
552 ASSERT_FALSE(later.empty());
553 EXPECT_EQ(later.back(), "Idle");
554}
555
556// While the limit error is set, OnStep accepts a goto (":MS#" answers "0") but doesn't move. That goto must fail too.
557TEST(LX200OnStepTest, gotoNotStartedAtLimitIsReported)
558{
559 FakeOnStep mount;
560 ASSERT_GE(mount.driverFD(), 0);
561 mount.setStatus(STATUS_MERIDIAN_LIMIT, "03:49:10", "+24*29:00");
562 OnStepUnderTest driver(mount.driverFD());
563
564 ASSERT_TRUE(driver.poll());
565
566 PublishedStates published;
567 ASSERT_TRUE(driver.requestGoto(3.0 + 48.0 / 60 + 37.0 / 3600, 24.0 + 14.0 / 60 + 5.0 / 3600));
568 mount.setStatus(STATUS_MERIDIAN_LIMIT, "03:49:14", "+24*29:00");
569 ASSERT_TRUE(driver.poll());
570 std::vector<std::string> states = published.eqStates();
571
572 EXPECT_EQ(mount.gotos(), 1);
573 ASSERT_FALSE(states.empty()) << "The goto was never answered";
574 EXPECT_EQ(states.front(), "Busy");
575 EXPECT_EQ(states.back(), "Alert") << "The goto that OnStep didn't start was not reported as failed";
576}
577
578// Controls: a goto that ends idle without an error (tracking switched off before it) and an idle mount polled with
579// the limit error but without a goto are not errors.
580TEST(LX200OnStepTest, idleWithoutGotoErrorIsNotAnError)
581{
582 {
583 FakeOnStep mount;
584 ASSERT_GE(mount.driverFD(), 0);
585 mount.setStatus(STATUS_IDLE, "17:31:01", "+52*17:02");
586 OnStepUnderTest driver(mount.driverFD());
587
588 ASSERT_TRUE(driver.poll());
589 PublishedStates published;
590 ASSERT_TRUE(driver.requestGoto(ELTANIN_RA, ELTANIN_DEC));
591 mount.setStatus(STATUS_SLEWING, "17:44:07", "+51*53:10");
592 ASSERT_TRUE(driver.poll());
593 mount.setStatus(STATUS_IDLE, "17:57:13", "+51*29:19");
594 ASSERT_TRUE(driver.poll());
595 std::vector<std::string> states = published.eqStates();
596
597 ASSERT_FALSE(states.empty());
598 for (const auto &state : states)
599 EXPECT_NE(state, "Alert") << "A goto that ended idle without an error was reported as failed";
600 EXPECT_EQ(states.back(), "Idle");
601 }
602 {
603 FakeOnStep mount;
604 ASSERT_GE(mount.driverFD(), 0);
605 mount.setStatus(STATUS_MERIDIAN_LIMIT, "03:49:10", "+24*29:00");
606 OnStepUnderTest driver(mount.driverFD());
607
608 PublishedStates published;
609 ASSERT_TRUE(driver.poll());
610 mount.setStatus(STATUS_MERIDIAN_LIMIT, "03:49:14", "+24*29:05");
611 ASSERT_TRUE(driver.poll());
612 std::vector<std::string> states = published.eqStates();
613
614 ASSERT_FALSE(states.empty());
615 for (const auto &state : states)
616 EXPECT_NE(state, "Alert") << "An idle mount without a goto was reported as failed";
617 }
618}
619
620int main(int argc, char **argv)
621{
622 // Never touch the user's real ~/.indi (park data is written to $HOME/.indi).
623 char homeTemplate[] = "/tmp/test_lx200_onstep_home_XXXXXX";
624 const char *home = mkdtemp(homeTemplate);
625 if (home)
626 setenv("HOME", home, 1);
627 // Never read or write the user's real ~/.indi driver configuration.
628 const std::string configFile = "/tmp/test_lx200_onstep_" + std::to_string(getpid()) + "_config.xml";
629 setenv("INDICONFIG", configFile.c_str(), 1);
632 ::testing::InitGoogleTest(&argc, argv);
633 int rc = RUN_ALL_TESTS();
634 std::remove(configFile.c_str());
635 std::remove((configFile + ".default").c_str());
636 if (home)
637 {
638 const std::string parkData = std::string(home) + "/.indi/ParkData.xml";
639 std::remove(parkData.c_str());
640 std::remove((std::string(home) + "/.indi").c_str());
641 std::remove(home);
642 }
643 return rc;
644}
static const loggerConf file_off
Definition indilogger.h:219
void configure(const std::string &outputFile, const loggerConf configuration, const int fileVerbosityLevel, const int screenVerbosityLevel)
Method to configure the logger. Called by the DEBUG_CONF() macro. To make implementation easier,...
static Logger & getInstance()
Method to get a reference to the object (i.e., Singleton) It is a static method.
int main()
double ra
double dec
void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
ISState
Switch state.
Definition indiapi.h:148
@ ISS_OFF
Definition indiapi.h:149
@ ISS_ON
Definition indiapi.h:150
*brief user defined string literal for JSON values *sa std::size_t n
#define getDeviceName
int fd
std::vector< uint8_t > buffer
bool isParked(const int fd)
*brief create JSON pointer *sa reference_tokens end()
void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Update the value of an existing switch vector property.
const char * STATUS_PARKED
const char * STATUS_IDLE
const char * STATUS_PARK_FAILED
const char * STATUS_MERIDIAN_LIMIT
const char * STATUS_PARKING
TEST(LX200OnStepTest, gotoToCurrentPositionIsAnswered)