summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-01-18 17:15:46 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-01-18 17:15:46 (GMT)
commitfc78cfdc4d1f5bba8dbd6a412f23651e185cb191 (patch)
treedd32929c07e6c19250f2e8fde1e73712bab0c6fb /test/src
parent01ee860a88b5c8cf25fb7dcc145662d2c27f3ebe (diff)
downloaduscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.zip
uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.tar.gz
uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.tar.bz2
Worked on passing even more IRP tests
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-extensions.cpp8
-rw-r--r--test/src/test-gen-c.cpp78
-rwxr-xr-xtest/src/test-http-debugger.pl9
3 files changed, 74 insertions, 21 deletions
diff --git a/test/src/test-extensions.cpp b/test/src/test-extensions.cpp
index 7686f9f..da81f3b 100644
--- a/test/src/test-extensions.cpp
+++ b/test/src/test-extensions.cpp
@@ -75,10 +75,14 @@ bool testPausableEventQueue() {
interpreter.addMonitor(&mon);
size_t iterations = 10;
+ int now = time(NULL);
+ int startedAt = time(NULL);
InterpreterState state = InterpreterState::USCXML_UNDEF;
- while (state != USCXML_FINISHED) {
- state = interpreter.step();
+ while (state != USCXML_FINISHED && now - startedAt < 5) {
+ state = interpreter.step(200);
+ now = time(NULL);
+
if (nestedDelayQueue) {
/*
* As soon as we have the nested event queue instantiated, we pause and resume it
diff --git a/test/src/test-gen-c.cpp b/test/src/test-gen-c.cpp
index acf1246..3971845 100644
--- a/test/src/test-gen-c.cpp
+++ b/test/src/test-gen-c.cpp
@@ -17,16 +17,20 @@
#endif
#ifndef AUTOINCLUDE_TEST
-#include "test-c-machine.scxml.c"
-//#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/ecma/test329.scxml.machine.c"
+//#include "test-c-machine.scxml.c"
+//#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/ecma/test562.scxml.machine.c"
+//#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/ecma/test558.scxml.machine.c"
+#include "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/test/gen/c/lua/test530.scxml.machine.c"
#endif
#include "uscxml/util/URL.h"
//#include "uscxml/concurrency/Timer.h"
//#include "uscxml/dom/DOMUtils.h"
#include "uscxml/plugins/Factory.h"
+#include "uscxml/plugins/IOProcessorImpl.h"
//#include "uscxml/Interpreter.h"
#include "uscxml/util/UUID.h"
+//#include "uscxml/server/HTTPServer.h"
#include "uscxml/interpreter/InterpreterImpl.h"
#include "uscxml/interpreter/BasicEventQueue.h"
@@ -40,7 +44,7 @@
using namespace uscxml;
-class StateMachine : public DataModelCallbacks, public DelayedEventQueueCallbacks {
+class StateMachine : public DataModelCallbacks, public IOProcessorCallbacks, public DelayedEventQueueCallbacks {
public:
StateMachine(const uscxml_machine* machine) : machine(machine), parentMachine(NULL), topMostMachine(NULL), invocation(NULL) {
allMachines[sessionId] = this;
@@ -70,6 +74,23 @@ public:
return ioProcs;
}
+ void enqueueInternal(const Event& event) {
+ iq.push_back(event);
+ }
+ void enqueueExternal(const Event& event) {
+ eq.push_back(event);
+ }
+
+ void enqueueAtInvoker(const std::string& invokeId, const Event& event) {
+ if (invokers.find(invokeId) != invokers.end())
+ invokers[invokeId].eventFromSCXML(event);
+ }
+
+ void enqueueAtParent(const Event& event) {
+ if (parentMachine != NULL)
+ parentMachine->enqueueExternal(event);
+ }
+
bool isInState(const std::string& stateId) {
for (size_t i = 0; i < ctx.machine->nr_states; i++) {
if (ctx.machine->states[i].name &&
@@ -119,6 +140,16 @@ public:
name = machine->name;
+ // register IO Procs
+ std::map<std::string, IOProcessorImpl*> allIOProcs = Factory::getInstance()->getIOProcessors();
+ for (auto ioProcImpl : allIOProcs) {
+ ioProcs[ioProcImpl.first] = Factory::getInstance()->createIOProcessor(ioProcImpl.first, this);
+ std::list<std::string> names = ioProcImpl.second->getNames();
+ for (auto name : names) {
+ ioProcs[name] = ioProcs[ioProcImpl.first];
+ }
+ }
+
delayQueue = DelayedEventQueue(std::shared_ptr<DelayedEventQueueImpl>(new BasicDelayedEventQueue(this)));
dataModel = Factory::getInstance()->createDataModel(machine->datamodel, this);
@@ -310,7 +341,12 @@ public:
if (donedata) {
if (donedata->content != NULL) {
- e.data = Data(donedata->content, Data::VERBATIM);
+ if (isNumeric(donedata->content, 10)) {
+ // test 529
+ e.data = Data(strTo<double>(donedata->content), Data::INTERPRETED);
+ } else {
+ e.data = Data(donedata->content, Data::VERBATIM);
+ }
} else if (donedata->contentexpr != NULL) {
try {
e.data = USER_DATA(ctx)->dataModel.getAsData(donedata->contentexpr);
@@ -369,13 +405,13 @@ public:
}
if (target.size() > 0 && (target[0] != '#' || target[1] != '_')) {
+ std::cerr << "Target '" << target << "' is not supported yet" << std::endl;
e.name = "error.execution";
execContentRaise(ctx, e);
return USCXML_ERR_INVALID_TARGET;
}
e.origintype = "http://www.w3.org/TR/scxml/#SCXMLEventProcessor";
-// e.origin = target;
std::string type;
try {
@@ -400,6 +436,7 @@ public:
}
e.origintype = type;
+ e.origin = "#_scxml_" + USER_DATA(ctx)->sessionId;
e.invokeid = USER_DATA(ctx)->invokeId;
if (send->eventexpr != NULL) {
@@ -446,11 +483,13 @@ public:
}
if (send->content != NULL) {
- // will it parse as json?
- Data d = USER_DATA(ctx)->dataModel.getAsData(send->content);
- if (!d.empty()) {
- e.data = d;
- } else {
+ try {
+ // will it parse as json?
+ Data d = USER_DATA(ctx)->dataModel.getAsData(send->content);
+ if (!d.empty()) {
+ e.data = d;
+ }
+ } catch (Event err) {
e.data = Data(spaceNormalize(send->content), Data::VERBATIM);
}
}
@@ -560,8 +599,9 @@ public:
try {
// Data d = USER_DATA(ctx)->dataModel.getStringAsData(expr);
if (assign->expr != NULL) {
- USER_DATA(ctx)->dataModel.assign(key,
- USER_DATA(ctx)->dataModel.evalAsData(assign->expr));
+// USER_DATA(ctx)->dataModel.assign(key,
+// USER_DATA(ctx)->dataModel.evalAsData(assign->expr));
+ USER_DATA(ctx)->dataModel.assign(key, Data(assign->expr, Data::INTERPRETED));
} else if (assign->content != NULL) {
Data d = Data(assign->content, Data::INTERPRETED);
USER_DATA(ctx)->dataModel.assign(key, d);
@@ -628,7 +668,8 @@ public:
try {
if (data->expr != NULL) {
- d = USER_DATA(ctx)->dataModel.evalAsData(data->expr);
+ d = Data(data->expr, Data::INTERPRETED);
+// d = USER_DATA(ctx)->dataModel.evalAsData(data->expr);
} else if (data->content != NULL || data->src != NULL) {
if (data->content) {
@@ -647,7 +688,9 @@ public:
* as space normalized string literals if this fails below
*/
d = USER_DATA(ctx)->dataModel.getAsData(content.str());
-
+ if (d.empty()) {
+ d = Data(escape(spaceNormalize(content.str())), Data::VERBATIM);
+ }
} else {
// leave d undefined
}
@@ -895,6 +938,8 @@ NEXT_DESC:
std::deque<Event> eq;
DataModel dataModel;
+ std::map<std::string, IOProcessor> ioProcs;
+ std::map<std::string, Invoker> invokers;
protected:
struct scxml_foreach_info {
@@ -903,8 +948,6 @@ protected:
};
X xmlPrefix;
- std::map<std::string, IOProcessor> ioProcs;
- std::map<std::string, Invoker> invokers;
XERCESC_NS::DOMDocument* document;
DelayedEventQueue delayQueue;
@@ -925,6 +968,9 @@ int main(int argc, char** argv) {
benchmarkRuns = strTo<size_t>(envBenchmarkRuns);
}
+ // start the webserver for the basichttp tests
+// HTTPServer::getInstance(3453, 3454, NULL);
+
size_t remainingRuns = benchmarkRuns;
size_t microSteps = 0;
diff --git a/test/src/test-http-debugger.pl b/test/src/test-http-debugger.pl
index a7a1d0a..fcc675f 100755
--- a/test/src/test-http-debugger.pl
+++ b/test/src/test-http-debugger.pl
@@ -26,16 +26,19 @@ my @breakpointSeq;
my $pid = fork;
if (!$pid) {
- # exec("$scxmlBin -t4088 -d");
+ exec("$scxmlBin -t4088 -d");
exit;
}
-# my $baseURL = 'http://localhost:4088/debug';
-my $baseURL = 'http://localhost:5080/debug';
+my $baseURL = 'http://localhost:4088/debug';
+# my $baseURL = 'http://localhost:5080/debug';
sub assertSuccess {
my $response = shift;
my $message = shift;
+ print "-----\n";
+ print $response->content();
+ print "-----\n";
from_json($response->content())->{'status'} eq "success" or die($message);
}