From 008cca1a15ac9178c57de77d2f6699d9de3088cb Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Fri, 4 Aug 2017 14:41:26 +0200 Subject: Debugger bugfixes and improvements --- src/uscxml/debug/DebugSession.cpp | 100 +- src/uscxml/debug/DebugSession.h | 2 +- src/uscxml/debug/Debugger.cpp | 14 +- src/uscxml/debug/DebuggerServlet.cpp | 2 +- src/uscxml/debug/DebuggerServlet.h | 15 - test/src/test-http-debugger.pl | 269 +- test/w3c/compound/test-ecma-all.scxml | 5841 +++++++++++++++++++++++++++++++++ 7 files changed, 6066 insertions(+), 177 deletions(-) create mode 100644 test/w3c/compound/test-ecma-all.scxml diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp index b5c1605..69f9e6c 100644 --- a/src/uscxml/debug/DebugSession.cpp +++ b/src/uscxml/debug/DebugSession.cpp @@ -120,6 +120,9 @@ Data DebugSession::debugPrepare(const Data& data) { if (_interpreter) { // register ourself as a monitor _interpreter.addMonitor(_debugger); + ActionLanguage al; + al.logger = Logger(shared_from_this()); + _interpreter.setActionLanguage(al); _debugger->attachSession(_interpreter.getImpl()->getSessionId(), shared_from_this()); replyData.compound["status"] = Data("success", Data::VERBATIM); @@ -169,6 +172,12 @@ Data DebugSession::debugAttach(const Data& data) { Data DebugSession::debugDetach(const Data& data) { Data replyData; + if (!_isAttached) { + replyData.compound["status"] = Data("failure", Data::VERBATIM); + replyData.compound["reason"] = Data("Not attached to an interpreter", Data::VERBATIM); + return replyData; + } + _isAttached = false; _debugger->detachSession(_interpreter.getImpl()->getSessionId()); @@ -180,7 +189,7 @@ Data DebugSession::debugStart(const Data& data) { Data replyData; if (_isAttached) { - replyData.compound["reason"] = Data("Already started when attached", Data::VERBATIM); + replyData.compound["reason"] = Data("Interpreter always started when attached", Data::VERBATIM); replyData.compound["status"] = Data("failure", Data::VERBATIM); } else if (!_interpreter) { replyData.compound["reason"] = Data("No interpreter attached or loaded", Data::VERBATIM); @@ -194,34 +203,15 @@ Data DebugSession::debugStart(const Data& data) { return replyData; } -void DebugSession::run(void* instance) { - DebugSession* INSTANCE = (DebugSession*)instance; - -#ifdef APPLE - std::string threadName; - threadName += "uscxml::"; - threadName += (INSTANCE->_interpreter.getImpl()->_name.size() > 0 ? INSTANCE->_interpreter.getImpl()->_name : "anon"); - threadName += ".debug"; - - pthread_setname_np(threadName.c_str()); -#endif - - InterpreterState state = USCXML_UNDEF; - while(state != USCXML_FINISHED && INSTANCE->_isRunning) { - state = INSTANCE->_interpreter.step(); - - // if (!INSTANCE->_isStarted) { - // // we have been cancelled - // INSTANCE->_isActive = false; - // return; - // } - } - LOG(INSTANCE->_interpreter.getLogger(), USCXML_DEBUG) << "done" << std::endl; -} - Data DebugSession::debugStop(const Data& data) { Data replyData; + if (_isAttached) { + replyData.compound["reason"] = Data("Cannot stop an attached interpreter", Data::VERBATIM); + replyData.compound["status"] = Data("failure", Data::VERBATIM); + return replyData; + } + if (_interpreter) { // detach from old intepreter _debugger->detachSession(_interpreter.getImpl()->getSessionId()); @@ -246,6 +236,31 @@ Data DebugSession::debugStop(const Data& data) { return replyData; } +void DebugSession::run(void* instance) { + DebugSession* INSTANCE = (DebugSession*)instance; + +#ifdef APPLE + std::string threadName; + threadName += "uscxml::"; + threadName += (INSTANCE->_interpreter.getImpl()->_name.size() > 0 ? INSTANCE->_interpreter.getImpl()->_name : "anon"); + threadName += ".debug"; + + pthread_setname_np(threadName.c_str()); +#endif + + InterpreterState state = USCXML_UNDEF; + while(state != USCXML_FINISHED && INSTANCE->_isRunning) { + state = INSTANCE->_interpreter.step(); + + // if (!INSTANCE->_isStarted) { + // // we have been cancelled + // INSTANCE->_isActive = false; + // return; + // } + } + LOG(INSTANCE->_interpreter.getLogger(), USCXML_DEBUG) << "done" << std::endl; +} + Data DebugSession::debugStep(const Data& data) { std::lock_guard lock(_mutex); @@ -270,10 +285,16 @@ Data DebugSession::debugStep(const Data& data) { Data DebugSession::debugResume(const Data& data) { std::lock_guard lock(_mutex); + Data replyData; + + if (!_isStepping) { + replyData.compound["reason"] = Data("Interpreter not paused / stepping", Data::VERBATIM); + replyData.compound["status"] = Data("failure", Data::VERBATIM); + return replyData; + } stepping(false); - Data replyData; replyData.compound["status"] = Data("success", Data::VERBATIM); _resumeCond.notify_one(); @@ -283,11 +304,17 @@ Data DebugSession::debugResume(const Data& data) { Data DebugSession::debugPause(const Data& data) { std::lock_guard lock(_mutex); + Data replyData; - _skipTo = Breakpoint(); + if (_isStepping) { + replyData.compound["reason"] = Data("Interpreter already paused / stepping", Data::VERBATIM); + replyData.compound["status"] = Data("failure", Data::VERBATIM); + return replyData; + } + + _skipTo = Breakpoint(); // a generic breakpoint that always matches stepping(true); - Data replyData; replyData.compound["status"] = Data("success", Data::VERBATIM); return replyData; @@ -537,15 +564,24 @@ void DebugSession::log(LogSeverity severity, const Event& event) { namelist.compound[name.first] = name.second; } - _debugger->pushData(shared_from_this(), d); + Data toPush; + toPush["log"] = d; + toPush["severity"] = Data(Logger::severityToString(severity)); + _debugger->pushData(shared_from_this(), toPush); } void DebugSession::log(LogSeverity severity, const Data& data) { - _debugger->pushData(shared_from_this(), data); + Data toPush; + toPush["log"] = data; + toPush["severity"] = Data(Logger::severityToString(severity)); + _debugger->pushData(shared_from_this(), toPush); } void DebugSession::log(LogSeverity severity, const std::string& message) { - _debugger->pushData(shared_from_this(), Data(message)); + Data toPush; + toPush["log"] = Data(message); + toPush["severity"] = Data(Logger::severityToString(severity)); + _debugger->pushData(shared_from_this(), toPush); } } diff --git a/src/uscxml/debug/DebugSession.h b/src/uscxml/debug/DebugSession.h index ab4d79d..ec024f4 100644 --- a/src/uscxml/debug/DebugSession.h +++ b/src/uscxml/debug/DebugSession.h @@ -34,7 +34,7 @@ namespace uscxml { class Debugger; -class USCXML_API DebugSession : public LoggerImpl ,public std::enable_shared_from_this { +class USCXML_API DebugSession : public LoggerImpl, public std::enable_shared_from_this { public: DebugSession() { _isRunning = false; diff --git a/src/uscxml/debug/Debugger.cpp b/src/uscxml/debug/Debugger.cpp index cd7f0fe..fa173f0 100644 --- a/src/uscxml/debug/Debugger.cpp +++ b/src/uscxml/debug/Debugger.cpp @@ -145,7 +145,7 @@ void Debugger::handleExecutable(const std::string& sessionId, std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; std::list breakpoints; @@ -165,7 +165,7 @@ void Debugger::handleEvent(const std::string& sessionId, const Event& event, Bre std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; std::list breakpoints; @@ -184,7 +184,7 @@ void Debugger::handleStable(const std::string& sessionId, Breakpoint::When when) std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; std::list breakpoints; @@ -201,7 +201,7 @@ void Debugger::handleMicrostep(const std::string& sessionId, Breakpoint::When wh std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; std::list breakpoints; @@ -218,7 +218,7 @@ void Debugger::handleTransition(const std::string& sessionId, const XERCESC_NS:: std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; Breakpoint breakpointTemplate; @@ -231,7 +231,7 @@ void Debugger::handleState(const std::string& sessionId, const XERCESC_NS::DOMEl std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; Breakpoint breakpointTemplate; @@ -246,7 +246,7 @@ void Debugger::handleInvoke(const std::string& sessionId, const XERCESC_NS::DOME std::shared_ptr session = getSession(sessionId); if (!session) return; - if (!session->_isRunning) + if (!session->_isRunning && !session->_isAttached) return; Breakpoint breakpointTemplate; diff --git a/src/uscxml/debug/DebuggerServlet.cpp b/src/uscxml/debug/DebuggerServlet.cpp index 8a7e087..7363d23 100644 --- a/src/uscxml/debug/DebuggerServlet.cpp +++ b/src/uscxml/debug/DebuggerServlet.cpp @@ -134,6 +134,7 @@ bool DebuggerServlet::requestFromHTTP(const HTTPServer::Request& request) { serverPushData(session); } else if (boost::starts_with(request.data.at("path").atom, "/debug/disconnect")) { + session->debugDetach(request.data["content"]); processDisconnect(request); } else if (boost::starts_with(request.data.at("path").atom, "/debug/issues")) { @@ -196,7 +197,6 @@ void DebuggerServlet::processConnect(const HTTPServer::Request& request) { void DebuggerServlet::processDisconnect(const HTTPServer::Request& request) { std::lock_guard lock(_mutex); - Data replyData; if (!request.data.at("content").hasKey("session")) { diff --git a/src/uscxml/debug/DebuggerServlet.h b/src/uscxml/debug/DebuggerServlet.h index 674d842..2ba7eb9 100644 --- a/src/uscxml/debug/DebuggerServlet.h +++ b/src/uscxml/debug/DebuggerServlet.h @@ -52,21 +52,6 @@ public: void processIssues(const HTTPServer::Request& request); -// void processDebugPrepare(const HTTPServer::Request& request); -// void processDebugAttach(const HTTPServer::Request& request); -// void processDebugStart(const HTTPServer::Request& request); -// void processDebugStop(const HTTPServer::Request& request); - -// void processDebugEval(const HTTPServer::Request& request); -// void processDebugStart(const HTTPServer::Request& request); -// void processDebugStop(const HTTPServer::Request& request); -// void processDebugStep(const HTTPServer::Request& request); -// void processDebugResume(const HTTPServer::Request& request); -// void processDebugPause(const HTTPServer::Request& request); -// void processAddBreakPoint(const HTTPServer::Request& request); -// void processRemoveBreakPoint(const HTTPServer::Request& request); -// void processPoll(const HTTPServer::Request& request); - protected: void serverPushData(std::shared_ptr); diff --git a/test/src/test-http-debugger.pl b/test/src/test-http-debugger.pl index 4a28a52..fe9c036 100755 --- a/test/src/test-http-debugger.pl +++ b/test/src/test-http-debugger.pl @@ -53,12 +53,42 @@ sub dumpResponse { "\tCONTENT: " . $response->content() . "\n"; } +sub post { + my $path = shift; + my $session = shift; + my $data = shift || {}; + + $data->{'session'} = $session; + + my $response; + + # read reply until we have something other than a log message from the server + while(1) { + my $request = POST $baseURL.$path, $data; + print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; + $response = $ua->request($request); + print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + + # skip log messages + last if ($path ne '/poll'); + last if (!exists from_json($response->content())->{'severity'}); + + } + return $response; +} + sub assertSuccess { my $response = shift; my $message = shift; from_json($response->content())->{'status'} eq "success" or die($message); } +sub assertFailure { + my $response = shift; + my $message = shift; + from_json($response->content())->{'status'} eq "failure" or die($message); +} + sub attachSession { my $docName = shift; @@ -146,8 +176,8 @@ sub popAndCompare { my $bp = shift(@breakpointSeq); for my $key (keys %{$bp}) { if (! exists($qualified->{$key}) || $qualified->{$key} ne $bp->{$key}) { - print Dumper($qualified); - print Dumper($bp); + print "found: ".Dumper($qualified); + print "expected: ".Dumper($bp); die("Expected different breakpoint"); } } @@ -209,18 +239,12 @@ END_SCXML while(@breakpointSeq > 0) { ### Take a step - $request = POST $baseURL.'/step', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + + $response = post('/step', $session); assertSuccess($response, "Could not step"); - # this will cause the interpreter to pause execution ### Get the pending messages - $request = POST $baseURL.'/poll', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/poll', $session); assertSuccess($response, "Could not get breakpoint after step"); # compare to what we expect @@ -229,17 +253,11 @@ END_SCXML } ### last step will finalize the interpreter - $request = POST $baseURL.'/step', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; - assertSuccess($response, "Could not get breakpoint after step"); + $response = post('/step', $session); + assertSuccess($response, "Could not step"); ### get the pending server push reply - $request = POST $baseURL.'/poll', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/poll', $session); assertSuccess($response, "Could not get breakpoint after step"); $data = from_json($response->content()); @@ -272,56 +290,36 @@ END_SCXML my $session = &prepareSession({'xml' => $xml}); print BOLD . "Adding a dedicated breakpoint". RESET . "\n"; - - $request = POST $baseURL.'/breakpoint/add', - [ - 'session' => $session, - 'when' => 'after', - 'action' => 'enter', - 'subject' => 'state', - 'stateId' => 's1' - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/breakpoint/add', $session, { + 'session' => $session, + 'when' => 'after', + 'action' => 'enter', + 'subject' => 'state', + 'stateId' => 's1' + }); assertSuccess($response, "Could not add breakpoint"); print BOLD . "Starting interpretation (will run into breakpoint)". RESET . "\n"; - - $request = POST $baseURL.'/start', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; - assertSuccess($response, "Could not add breakpoint"); + $response = post('/start', $session); + assertSuccess($response, "Could not start interpreter"); print BOLD . "Polling asynchronously for breakpoint hit by interpreter". RESET . "\n"; - - $request = POST $baseURL.'/poll', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/poll', $session); assertSuccess($response, "Could not poll for breakpoint"); print BOLD . "Skipping to implicit breakpoint". RESET . "\n"; - $request = POST $baseURL.'/breakpoint/skipto', - [ - 'session' => $session, - 'when' => 'before', - 'action' => 'enter', - 'subject' => 'state', - 'stateId' => 's2' - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; - assertSuccess($response, "Could not add breakpoint"); + $response = post('/breakpoint/skipto', $session, { + 'session' => $session, + 'when' => 'before', + 'action' => 'enter', + 'subject' => 'state', + 'stateId' => 's2' + }); + assertSuccess($response, "Could not skip to breakpoint"); print BOLD . "Polling asynchronously for breakpoint hit by interpreter". RESET . "\n"; - $request = POST $baseURL.'/poll', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; - assertSuccess($response, "Could not get breakpoint after step"); + $response = post('/poll', $session); + assertSuccess($response, "Could not poll for breakpoint"); $data = from_json($response->content()); print Dumper($data); @@ -360,13 +358,7 @@ END_SCXML print BOLD . "Getting a list of issues with the document". RESET . "\n"; ### Get a list of issues - $request = POST $baseURL.'/issues', - [ - 'session' => $session - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/issues', $session); assertSuccess($response, "Could not get issues for prepared SCXML document"); $data = from_json($response->content()); @@ -385,46 +377,28 @@ sub testDataModelInspection { my $session = prepareSession({'url' => 'https://raw.githubusercontent.com/tklab-tud/uscxml/master/test/w3c/ecma/test144.scxml'}); print BOLD . "Skipping to first transition". RESET . "\n"; - $request = POST $baseURL.'/breakpoint/skipto', - [ - 'session' => $session, - 'when' => 'before', - 'subject' => 'transition', - 'target' => 's1' - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/breakpoint/skipto', $session, { + 'when' => 'before', + 'subject' => 'transition', + 'target' => 's1' + }); assertSuccess($response, "Could not add breakpoint"); print BOLD . "Polling asynchronously for breakpoint hit by interpreter". RESET . "\n"; - $request = POST $baseURL.'/poll', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/poll', $session); assertSuccess($response, "Could not get breakpoint after step"); print BOLD . "Evaluating expression '_event' on the datamodel". RESET . "\n"; - $request = POST $baseURL.'/eval', - [ - 'session' => $session, - 'expression' => '_event', - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/eval', $session, { + 'expression' => '_event' + }); assertSuccess($response, "Could not evaluate expression"); - print BOLD . "Evaluating expression '_ioprocessors' on the datamodel". RESET . "\n"; - $request = POST $baseURL.'/eval', - [ - 'session' => $session, - 'expression' => '_ioprocessors', - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + print BOLD . "Evaluating expression '_event' on the datamodel". RESET . "\n"; + $response = post('/eval', $session, { + 'expression' => '_ioprocessors' + }); assertSuccess($response, "Could not evaluate expression"); @@ -441,23 +415,15 @@ sub testSessionAttaching { my $session = attachSession("test-http-debugger.scxml"); print BOLD . "Skipping to first transition". RESET . "\n"; - $request = POST $baseURL.'/breakpoint/skipto', - [ - 'session' => $session, - 'when' => 'before', - 'subject' => 'transition', - 'target' => 's1' - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/breakpoint/skipto', $session, { + 'when' => 'before', + 'subject' => 'transition', + 'target' => 's1' + }); assertSuccess($response, "Could not add breakpoint"); print BOLD . "Polling asynchronously for breakpoint hit by interpreter". RESET . "\n"; - $request = POST $baseURL.'/poll', ['session' => $session]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/poll', $session); assertSuccess($response, "Could not get breakpoint after step"); &finishSession($session); @@ -485,26 +451,87 @@ END_SCXML my $session = prepareSession({'xml' => $xml}); print BOLD . "Sending event" . RESET . "\n"; - $request = POST $baseURL.'/event', - [ - 'session' => $session, - 'name' => 'foo', - ]; - print RED . "-> SEND === line:" . __LINE__ . "\n" . dumpRequest($request) . RESET . "\n"; - $response = $ua->request($request); - print CYAN . "<- RCVD === line:" . __LINE__ . "\n" . dumpResponse($response) . RESET . "\n"; + $response = post('/event', $session, { + 'name' => 'foo', + }); assertSuccess($response, "Could not send event"); &finishSession($session); } + +sub testRunningStates { + + print BOLD WHITE ON_RED . " " . RESET ."\n"; + print BOLD WHITE ON_RED . " testEventInsertion " . RESET ."\n"; + print BOLD WHITE ON_RED . " " . RESET ."\n\n"; + + my $session = attachSession("test-http-debugger.scxml"); + + print BOLD . "Stopping the intepreter". RESET . "\n"; + $response = post('/stop', $session); + assertFailure($response, "Should not be able to stop attached interpreter"); + + print BOLD . "Starting the intepreter". RESET . "\n"; + $response = post('/start', $session); + assertFailure($response, "Should not be able to start attached interpreter"); + + print BOLD . "Pausing the intepreter". RESET . "\n"; + $response = post('/pause', $session); + assertSuccess($response, "Could not pause the attached interpreter"); + + print BOLD . "Polling state of paused interpreter". RESET . "\n"; + $response = post('/poll', $session); + assertSuccess($response, "Could not poll state of paused interpreter"); + + print BOLD . "Pausing the intepreter again". RESET . "\n"; + $response = post('/pause', $session); + assertFailure($response, "Should not be able to pause attached interpreter twice"); + + print BOLD . "Resuming the intepreter". RESET . "\n"; + $response = post('/resume', $session); + assertSuccess($response, "Could not resume the attached interpreter"); + + print BOLD . "Resuming the intepreter again". RESET . "\n"; + $response = post('/resume', $session); + assertFailure($response, "Should not be able to resume attached interpreter twice"); + + &finishSession($session); + +} + +sub testLogReception { + + print BOLD WHITE ON_RED . " " . RESET ."\n"; + print BOLD WHITE ON_RED . " testLogReception " . RESET ."\n"; + print BOLD WHITE ON_RED . " " . RESET ."\n\n"; + + my $session = prepareSession({'url' => abs_path($baseDir).'/test-http-debugger.scxml'}); + + print BOLD . "Starting the intepreter". RESET . "\n"; + $response = post('/start', $session); + assertSuccess($response, "Could not start interpreter"); + + for (my $i = 0; $i < 5; $i++) { + print BOLD . "Polling interpreter for messages". RESET . "\n"; + # the trailing /# is only for poll above not to disregard the message + # You would just use /poll to get any pending message from the server + $response = post('/poll/#', $session); + assertSuccess($response, "Could not poll for messages"); + } + + &finishSession($session); + +} + &testSimpleStepping(); &testBreakpoint(); &testIssueReporting(); &testDataModelInspection(); &testSessionAttaching(); &testEventInsertion(); - +&testRunningStates(); +&testLogReception(); kill('TERM', $pid); \ No newline at end of file diff --git a/test/w3c/compound/test-ecma-all.scxml b/test/w3c/compound/test-ecma-all.scxml new file mode 100644 index 0000000..b087dcd --- /dev/null +++ b/test/w3c/compound/test-ecma-all.scxml @@ -0,0 +1,5841 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 123 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 123 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + foo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this is some content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 21 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + some content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [1,2,3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this is a + string + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { "productName" : "bar", "size" : 27 } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v0.12