Fix nswering procedure: have to use source resource.
[anna.git] / example / diameter / launcher / testing / TestStep.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 // Standard
10 #include <string>
11 #include <iostream>
12 #include <errno.h>
13
14 #include <signal.h>     // sigaction, sigemptyset, struct sigaction, SIGCHLD, SA_RESTART, SA_NOCLDSTOP
15 #include <stdio.h>      // perror
16 #include <stdlib.h>     // exit
17 #include <sys/wait.h>   // waitpid, pid_t, WNOHANG
18
19 // Project
20 #include <anna/xml/Compiler.hpp>
21 #include <anna/core/util/Millisecond.hpp>
22 #include <anna/diameter.comm/Message.hpp>
23 #include <anna/diameter.comm/ClientSession.hpp>
24 #include <anna/diameter.comm/ServerSession.hpp>
25 #include <anna/diameter.comm/Server.hpp>
26 #include <anna/core/tracing/Logger.hpp>
27 #include <anna/diameter/codec/Message.hpp>
28 #include <anna/diameter/codec/functions.hpp>
29 #include <anna/diameter/helpers/base/functions.hpp>
30
31 // Process
32 #include <RealmNode.hpp>
33 #include <MyDiameterEntity.hpp>
34 #include <MyLocalServer.hpp>
35 #include <TestStep.hpp>
36 #include <Launcher.hpp>
37 #include <TestCase.hpp>
38 #include <TestManager.hpp>
39 #include <TestTimer.hpp>
40
41
42 namespace {
43
44   void handle_sigchld(int sig) {
45     while (waitpid((pid_t)(-1 /* any child (the only) */), 0, WNOHANG|WNOWAIT) > 0) {}
46   }
47
48   void cmdRunOnThread (TestStepCmd *step, const std::string &cmd) {
49
50     // Thread running:
51     step->setThreadRunning(true);
52
53     int status = -2;
54
55     struct sigaction sa;
56     sa.sa_handler = &handle_sigchld;
57     sigemptyset(&sa.sa_mask);
58     sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
59     if (sigaction(SIGCHLD, &sa, 0) != -1) {
60       status = system(cmd.c_str());
61      /* POPEN version:
62       char readbuf[256];
63       FILE *fp = popen(cmd.c_str(), "r");
64       if (fp) {
65         while(fgets(readbuf, sizeof(readbuf), fp))
66           step->appendOutput("\n");
67           step->appendOutput(readbuf);
68           status = pclose(fp);
69       }
70       else {
71         status = -1;
72       }
73       */
74     }
75     else {
76       perror(0);
77     }
78     // This can be implemented portably and somewhat more concisely with the signal function if you prefer:
79     // if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
80     //   perror(0);
81     //   exit(1);
82     // }
83
84     if (status < 0) {
85       char buf[256];
86       char const * str = strerror_r(errno, buf, 256);
87       step->setErrorMsg(anna::functions::asString("errno = %d (%s)", errno, str));
88     }
89
90     step->setResultCode(WEXITSTATUS(status)); // rc = status >>= 8; // divide by 256
91     step->complete();
92     // TODO: terminate thread when deprecated (RT signal ?)
93     // TODO: mutex the step while setting data here !!
94   }
95
96   bool decodeMessage(const anna::DataBlock &message, anna::diameter::codec::Message *messageCodec) throw() {
97
98     if (message.isEmpty())
99       return false;
100
101     bool result = true;
102     try {
103       if (!messageCodec) {
104         Launcher& my_app = static_cast <Launcher&>(anna::app::functions::getApp());
105         messageCodec = new anna::diameter::codec::Message(my_app.getCodecEngine());
106       }
107
108       messageCodec->decode(message);
109     }
110     catch (anna::RuntimeException &ex) {
111       ex.trace();
112       result = false;
113     }
114
115     return result;
116   }
117
118 }
119
120
121 ////////////////////////////////////////////////////////////////////////////////////////////////////////
122 // TestStep
123 ////////////////////////////////////////////////////////////////////////////////////////////////////////
124 void TestStep::initialize(TestCase *testCase) {
125   a_testCase = testCase;
126   a_completed = false;
127   a_type = Type::Unconfigured;
128   a_beginTimestamp = 0;
129   a_endTimestamp = 0;
130   a_number = testCase->steps() + 1; // testCase is not NULL
131 }
132
133 const char* TestStep::asText(const Type::_v type)
134 throw() {
135   static const char* text [] = { "Unconfigured", "Timeout", "Sendxml2e", "Sendxml2c", "Delay", "Wait", "Cmd" };
136   return text [type];
137 }
138
139 anna::xml::Node* TestStep::asXML(anna::xml::Node* parent) const
140 throw() {
141   anna::xml::Node* result = parent->createChild("TestStep");
142
143   result->createAttribute("Number", a_number);
144   result->createAttribute("Type", asText(a_type));
145   result->createAttribute("Completed", (a_completed ? "yes":"no"));
146
147   // Begin
148   std::string s_aux = a_beginTimestamp.asString();
149 //  int deltaMs = (int)(a_beginTimestamp - a_testCase->getStartTimestamp());
150 //  if (a_beginTimestamp != 0 && deltaMs > 0) s_aux += anna::functions::asString(" [%.3f]", deltaMs/1000.0);
151   result->createAttribute("BeginTimestamp", s_aux);
152
153   // End
154   s_aux = a_endTimestamp.asString();
155 //  deltaMs = (int)(a_endTimestamp - a_testCase->getStartTimestamp());
156 //  if (a_endTimestamp != 0 && deltaMs > 0) s_aux += anna::functions::asString(" [%.3f]", deltaMs/1000.0);
157   result->createAttribute("EndTimestamp", s_aux);
158
159   return result;
160 }
161
162 std::string TestStep::asXMLString() const throw() {
163   anna::xml::Node root("root");
164   return anna::xml::Compiler().apply(asXML(&root));
165 }
166
167 bool TestStep::execute() throw() {
168   LOGDEBUG(anna::Logger::debug(anna::functions::asString("EXECUTING %s (step number %d) for Test Case %llu (%p) (%p)", asText(a_type), a_number, a_testCase->getId(), (TestCaseStep*)this, this), ANNA_FILE_LOCATION));
169   setBeginTimestamp(anna::functions::millisecond());
170   return do_execute();
171 }
172
173 void TestStep::complete() throw() {
174   LOGDEBUG(anna::Logger::debug(anna::functions::asString("COMPLETE %s (step number %d) for Test Case %llu (%p) (%p)", asText(a_type), a_number, a_testCase->getId(), (TestCaseStep*)this, this), ANNA_FILE_LOCATION));
175   a_completed = true;
176   setEndTimestamp(anna::functions::millisecond());
177   do_complete();
178 }
179
180 void TestStep::reset() throw() {
181   LOGDEBUG(anna::Logger::debug(anna::functions::asString("RESET %s (step number %d) for Test Case %llu (%p) (%p)", asText(a_type), a_number, a_testCase->getId(), (TestCaseStep*)this, this), ANNA_FILE_LOCATION));
182   // type and testCase kept
183   a_completed = false;
184   a_beginTimestamp = 0;
185   a_endTimestamp = 0;
186   do_reset();
187 }
188
189 void TestStep::next() throw() {
190   a_testCase->nextStep();
191   a_testCase->process();
192 }
193
194
195 ////////////////////////////////////////////////////////////////////////////////////////////////////////
196 // TestStepTimeout
197 ////////////////////////////////////////////////////////////////////////////////////////////////////////
198 anna::xml::Node* TestStepTimeout::asXML(anna::xml::Node* parent) const
199 throw() {
200   anna::xml::Node* result = TestStep::asXML(parent); // end timestamp will be 0 if test finished OK
201   //parent->createChild("TestStepTimeout");
202   result->createAttribute("Timeout", a_timeout.asString());
203
204   return result;
205 }
206
207 bool TestStepTimeout::do_execute() throw() {
208   try {
209     a_timer = TestManager::instantiate().createTimer((TestCaseStep*)this, a_timeout, TestTimer::Type::TimeLeft);
210   }
211   catch (anna::RuntimeException &ex) {
212     ex.trace();
213     a_testCase->addDebugSummaryHint(ex.asString()); // before report (when set Failed state)
214     a_testCase->setState(TestCase::State::Failed);
215   }
216
217   return true; // go next
218 }
219
220 void TestStepTimeout::do_complete() throw() {
221   int stepNumber = getNumber();
222   if (stepNumber == a_testCase->steps()) {
223     a_testCase->addDebugSummaryHint(anna::functions::asString("Timeout expired (step number %d) but it was the last test case step", stepNumber)); // before report (when set Failed state)
224     a_testCase->setState(TestCase::State::Success);
225   }
226   else if (a_testCase->getState() == TestCase::State::InProgress) { // sure
227     a_testCase->addDebugSummaryHint(anna::functions::asString("Timeout expired (step number %d) before test case finished", stepNumber)); // before report (when set Failed state)
228     a_testCase->setState(TestCase::State::Failed);
229   }
230
231   a_timer = NULL;
232 }
233
234 void TestStepTimeout::do_reset() throw() {
235   LOGDEBUG(anna::Logger::debug(anna::functions::asString("REXXXXXET %s for Test Case %llu (%p) (%p) (a_timer %p)", asText(a_type), a_testCase->getId(), (TestCaseStep*)this, this, a_timer), ANNA_FILE_LOCATION));
236
237   try {
238     TestManager::instantiate().cancelTimer(a_timer);
239   }
240   catch (anna::RuntimeException &ex) {
241     ex.trace();
242   }
243   a_timer = NULL;
244   //a_timeout = 0; THIS IS CONFIGURATION INFO
245 }
246
247 ////////////////////////////////////////////////////////////////////////////////////////////////////////
248 // TestStepSendxml
249 ////////////////////////////////////////////////////////////////////////////////////////////////////////
250 TestStepSendxml::~TestStepSendxml() {
251   delete a_messageCodec;
252   a_messageCodec = NULL;
253 }
254
255 anna::xml::Node* TestStepSendxml::asXML(anna::xml::Node* parent) const
256 throw() {
257   anna::xml::Node* result = TestStep::asXML(parent);
258   //parent->createChild("TestStepSendxml");
259   std::string msg = "", xmlmsg = "";
260
261   // Message
262   if (TestManager::instantiate().getDumpHex()) {
263     if (a_message.isEmpty()) {
264       msg = "<empty>";
265     }
266     else {
267       msg = "\n"; msg += a_message.asString(); msg += "\n";
268     }
269   }
270
271   if (decodeMessage(a_message, a_messageCodec)) {
272     xmlmsg = "\n";
273     xmlmsg += a_messageCodec->asXMLString();
274     xmlmsg += "\n";
275   }
276
277   if (msg != "") result->createAttribute("Message", msg);
278   if (xmlmsg != "") result->createAttribute("XMLMessage", xmlmsg);
279   result->createAttribute("Expired", (a_expired ? "yes":"no"));
280   if (a_waitForRequestStepNumber != -1)
281     result->createAttribute("WaitForRequestStepNumber", a_waitForRequestStepNumber);
282
283   return result;
284 }
285
286 bool TestStepSendxml::do_execute() throw() {
287   bool success = false;
288   std::string failReason, s_warn;
289   MyDiameterEntity *entity = a_realmNode->getEntity(); // by default
290   MyLocalServer *localServer = a_realmNode->getDiameterServer(); // by default
291   const TestStepWait *tsw = NULL;
292
293   // Create comm message:
294   anna::diameter::comm::Message *msg = a_realmNode->createCommMessage();
295   //msg->clearBody();
296   msg->setBody(a_message);
297
298   try {
299     // Update sequence for answers:
300     if (a_waitForRequestStepNumber != -1) { // is an answer: try to copy sequence information; alert about Session-Id discrepance
301       // Request which was received:
302       tsw = (const TestStepWait*)(a_testCase->getStep(a_waitForRequestStepNumber));
303       const anna::DataBlock &request = tsw->getMsgDataBlock();
304       anna::diameter::HopByHop hbh = anna::diameter::codec::functions::getHopByHop(request);
305       anna::diameter::EndToEnd ete = anna::diameter::codec::functions::getEndToEnd(request);
306       // Update sequence:
307       anna::diameter::codec::functions::setHopByHop(a_message, hbh);
308       anna::diameter::codec::functions::setEndToEnd(a_message, ete);
309
310       // Check Session-Id for warning ...
311       std::string sessionIdAnswer = anna::diameter::helpers::base::functions::getSessionId(a_message);
312       std::string sessionIdRequest = anna::diameter::helpers::base::functions::getSessionId(request);
313       if (sessionIdRequest != sessionIdAnswer) {
314         s_warn = anna::functions::asString("Sending an answer which Session-Id (%s) is different than supposed corresponding request (%s)", sessionIdAnswer.c_str(), sessionIdRequest.c_str());
315         LOGWARNING(anna::Logger::warning(s_warn, ANNA_FILE_LOCATION));
316         a_testCase->addDebugSummaryHint(s_warn);
317       }
318     }
319
320     if (getType() == Type::Sendxml2e) {
321       anna::diameter::comm::ClientSession *usedClientSession = NULL;
322
323       if (tsw) { // is an answer for a received request on wait condition
324         anna::diameter::comm::ClientSession *clientSession = tsw->getClientSession();
325         if (clientSession) {
326           /* response NULL (is an answer) */clientSession->send(msg);
327           success = true;
328           usedClientSession = clientSession;
329         }
330         else {
331           failReason = "Reference wait step didn't store a valid client session. Unable to send the message";
332           LOGWARNING(anna::Logger::warning(failReason, ANNA_FILE_LOCATION));
333         }
334       }
335       else {
336         if (entity) {
337           success = entity->send(msg);
338           anna::diameter::comm::Server *usedServer = entity->getLastUsedResource();
339           usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL;
340         }
341         else {
342           failReason = "There is no diameter entity currently configured. Unable to send the message";
343           LOGWARNING(anna::Logger::warning(failReason, ANNA_FILE_LOCATION));
344         }
345       } // else (normal sending)
346
347       // Detailed log:
348       if(a_realmNode->logEnabled()) {
349         if (!a_messageCodec)
350           decodeMessage(a_message, a_messageCodec);
351
352         if (a_messageCodec) {
353           std::string detail = usedClientSession ? usedClientSession->asString() : "<null client session>"; // shouldn't happen
354           a_realmNode->writeLogFile(*a_messageCodec, (success ? "sent2e" : "send2eError"), detail);
355         }
356       }
357     }
358     else if (getType() == Type::Sendxml2c) {
359       anna::diameter::comm::ServerSession *usedServerSession = NULL;
360
361       if (tsw) { // is an answer for a received request on wait condition
362         anna::diameter::comm::ServerSession *serverSession = tsw->getServerSession();
363         if (serverSession) {
364           /* response NULL (is an answer) */serverSession->send(msg);
365           success = true;
366           usedServerSession = serverSession;
367         }
368         else {
369           failReason = "Reference wait step didn't store a valid server session. Unable to send the message";
370           LOGWARNING(anna::Logger::warning(failReason, ANNA_FILE_LOCATION));
371         }
372       }
373       else {
374         if (localServer) {
375           success = localServer->send(msg);
376           usedServerSession = localServer->getLastUsedResource();
377         }
378         else {
379           failReason = "There is no diameter local server currently configured. Unable to send the message";
380           LOGWARNING(anna::Logger::warning(failReason, ANNA_FILE_LOCATION));
381         }
382       } // else (normal sending)
383
384       // Detailed log:
385       if(a_realmNode->logEnabled()) {
386         if (!a_messageCodec)
387           decodeMessage(a_message, a_messageCodec);
388
389         if (a_messageCodec) {
390           std::string detail = usedServerSession ? usedServerSession->asString() : "<null server session>"; // shouldn't happen
391           a_realmNode->writeLogFile(*a_messageCodec, (success ? "sent2c" : "send2cError"), detail);
392         }
393       }
394     }
395
396   } catch(anna::RuntimeException &ex) {
397     failReason = ex.asString();
398   }
399
400   // release msg
401   a_realmNode->releaseCommMessage(msg);
402
403   if (!success) {
404     a_testCase->addDebugSummaryHint(failReason); // before report (when set Failed state);
405     a_testCase->setState(TestCase::State::Failed);
406   }
407   else {
408     complete();
409   }
410
411   return success; // go next if sent was OK
412 }
413
414 void TestStepSendxml::do_reset() throw() {
415   a_expired = false;
416   //a_message.clear();
417 }
418
419 ////////////////////////////////////////////////////////////////////////////////////////////////////////
420 // TestStepDelay
421 ////////////////////////////////////////////////////////////////////////////////////////////////////////
422 anna::xml::Node* TestStepDelay::asXML(anna::xml::Node* parent) const
423 throw() {
424   anna::xml::Node* result = TestStep::asXML(parent);
425   //parent->createChild("TestStepDelay");
426
427   result->createAttribute("Delay", a_delay.asString());
428
429   return result;
430 }
431
432 bool TestStepDelay::do_execute() throw() {
433   try {
434     a_timer = TestManager::instantiate().createTimer((TestCaseStep*)this, a_delay, TestTimer::Type::Delay);
435   }
436   catch (anna::RuntimeException &ex) {
437     ex.trace();
438     a_testCase->addDebugSummaryHint(ex.asString()); // before report (when set Failed state)
439     a_testCase->setState(TestCase::State::Failed);
440   }
441
442   return false; // don't go next (wait complete)
443 }
444
445 void TestStepDelay::do_complete() throw() {
446   a_timer = NULL;
447   next(); // next() invoked here because execute() is always false for delay and never advance the iterator
448 }
449
450 void TestStepDelay::do_reset() throw() {
451   try {
452     TestManager::instantiate().cancelTimer(a_timer);
453   }
454   catch (anna::RuntimeException &ex) {
455     ex.trace();
456   }
457   a_timer = NULL;
458   //a_delay = 0; THIS IS CONFIGURATION INFO
459 }
460
461 ////////////////////////////////////////////////////////////////////////////////////////////////////////
462 // TestStepWait
463 ////////////////////////////////////////////////////////////////////////////////////////////////////////
464 TestStepWait::~TestStepWait() {
465   delete a_messageCodec;
466   a_messageCodec = NULL;
467 }
468
469 void TestStepWait::setCondition(bool fromEntity,
470                                   const std::string &code, const std::string &bitR, const std::string &resultCode, const std::string &sessionId,
471                                   const std::string &hopByHop, const std::string &msisdn, const std::string &imsi, const std::string &serviceContextId) throw() {
472
473   a_condition.setReceivedFromEntity(fromEntity);
474   a_condition.setCode(code);
475   a_condition.setBitR(bitR);
476   a_condition.setResultCode(resultCode);
477   a_condition.setSessionId(sessionId);
478   a_condition.setHopByHop(hopByHop);
479   a_condition.setMsisdn(msisdn);
480   a_condition.setImsi(imsi);
481   a_condition.setServiceContextId(serviceContextId);
482 }
483
484 void TestStepWait::setCondition(bool fromEntity, const std::string &regexp) throw() {
485
486   a_condition.setReceivedFromEntity(fromEntity);
487   a_condition.setRegexp(regexp);
488 }
489
490 anna::xml::Node* TestStepWait::asXML(anna::xml::Node* parent) const
491 throw() {
492   anna::xml::Node* result = TestStep::asXML(parent);
493   //parent->createChild("TestStepWait");
494   std::string msg = "", xmlmsg = "";
495
496   // Condition
497   a_condition.asXML(result);
498
499   // Message
500   if (TestManager::instantiate().getDumpHex()) {
501     if (a_message.isEmpty()) {
502       msg = "<empty>";
503     }
504     else {
505       msg = "\n"; msg += a_message.asString(); msg += "\n";
506     }
507   }
508
509   if (decodeMessage(a_message, a_messageCodec)) {
510     xmlmsg = "\n";
511     xmlmsg += a_messageCodec->asXMLString();
512     xmlmsg += "\n";
513   }
514
515   if (msg != "") result->createAttribute("MatchedMessage", msg);
516   if (xmlmsg != "") result->createAttribute("MatchedXMLMessage", xmlmsg);
517
518   return result;
519 }
520
521 bool TestStepWait::do_execute() throw() {
522   return a_completed;
523 }
524
525 void TestStepWait::do_complete() throw() {
526   a_testCase->process(); // next() not invoked; we only want to reactivate the test case
527 }
528
529 bool TestStepWait::fulfilled(const anna::DataBlock &db/*, bool matchSessionId*/) throw() {
530   if (a_condition.comply(db/*, matchSessionId*/)) {
531     //a_message = db; // store matched
532     a_message.assign(db);
533     complete();
534     return true;
535   }
536
537   return false;
538 }
539
540 void TestStepWait::do_reset() throw() {
541   a_message.clear();
542   a_clientSession = NULL;
543   a_serverSession = NULL;
544 }
545
546 ////////////////////////////////////////////////////////////////////////////////////////////////////////
547 // TestStepCmd
548 ////////////////////////////////////////////////////////////////////////////////////////////////////////
549 anna::xml::Node* TestStepCmd::asXML(anna::xml::Node* parent) const
550 throw() {
551   anna::xml::Node* result = TestStep::asXML(parent);
552   //parent->createChild("TestStepCmd");
553
554   result->createAttribute("Script", (a_script != "") ? a_script:"<no script>");
555   result->createAttribute("Parameters", (a_parameters != "") ? a_parameters:"<no parameters>");
556   if (a_errorMsg != "") result->createAttribute("ErrorMessage", a_errorMsg);
557   if (!a_threadRunning && a_resultCode != -2) {
558     result->createAttribute("ResultCode", a_resultCode);
559     //if (a_output != "") result->createAttribute("Output", a_output);
560   }
561
562   return result;
563 }
564
565 bool TestStepCmd::do_execute() throw() {
566   if (!a_threadRunning /* || a_threadDeprecated DO NOT WANT TO OVERLAP ... */) {
567     // Special tags to replace:
568     std::string cmd = getScript();
569     cmd += " ";
570     cmd += getParameters();
571     size_t index;
572     while ((index = cmd.find(SH_COMMAND_TAG_FOR_REPLACE__CYCLE_ID)) != std::string::npos)
573       cmd.replace(index, strlen(SH_COMMAND_TAG_FOR_REPLACE__CYCLE_ID), anna::functions::asString(TestManager::instantiate().getPoolCycle()));
574     while ((index = cmd.find(SH_COMMAND_TAG_FOR_REPLACE__TESTCASE_ID)) != std::string::npos)
575       cmd.replace(index, strlen(SH_COMMAND_TAG_FOR_REPLACE__TESTCASE_ID), anna::functions::asString(a_testCase->getId()));
576     while ((index = cmd.find(SH_COMMAND_TAG_FOR_REPLACE__TESTSTEP_ID)) != std::string::npos)
577       cmd.replace(index, strlen(SH_COMMAND_TAG_FOR_REPLACE__TESTSTEP_ID), anna::functions::asString(getNumber()));
578
579     a_thread = std::thread(cmdRunOnThread, this, cmd);
580     a_thread.detach();
581   }
582
583   return false; // don't go next (wait complete): If system function on thread stucks, then the reset test case will stuck here forever.
584                 // We must implement a interrupt procedure for the thread on reset call... TODO !       
585 }
586
587 void TestStepCmd::do_complete() throw() {
588
589   a_threadRunning = false;
590   if (a_threadDeprecated) {
591     a_threadDeprecated = false;
592     do_reset();
593     setErrorMsg(anna::functions::asString("Step %d deprecated due to previous reset for Test Case %llu", getNumber(), a_testCase->getId()));
594     a_testCase->setState(TestCase::State::Failed);
595     return; // ignore TODO: interrupt the thread to avoid execution of the script
596   }
597
598   if (getResultCode() != 0)
599     a_testCase->setState(TestCase::State::Failed);
600   else
601     next(); // next() invoked here because execute() is always false for delay and never advance the iterator
602 }
603
604 void TestStepCmd::do_reset() throw() {
605
606   if (a_threadRunning) {
607     std::string s_warn = anna::functions::asString("Thread still in progress: deprecating step %d for Test Case %llu", getNumber(), a_testCase->getId());
608     LOGWARNING(anna::Logger::warning(s_warn, ANNA_FILE_LOCATION));
609     a_threadDeprecated = true;
610   }
611
612   a_resultCode = -2;
613   //a_output = "";
614 }
615