From 10e6e1db531a682f852b488ba8bf4cbb2f984d88 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Sat, 23 Aug 2014 00:40:46 +0200 Subject: Spring cleaning of tests --- src/bindings/swig/csharp/uscxml.i | 2 + src/bindings/swig/java/uscxml.i | 2 + src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp | 10 + test/CMakeLists.txt | 213 +++--------- test/src/test-apache-commons.cpp | 128 ------- test/src/test-arabica-namespaces.cpp | 7 - test/src/test-arabica-xpath.cpp | 4 +- test/src/test-cmdline-parsing.cpp | 2 +- test/src/test-curl-multi-api.cpp | 404 ---------------------- test/src/test-ecmascript-v8.cpp.old | 24 -- test/src/test-execution.cpp.old | 16 - test/src/test-initial-config.cpp | 36 -- test/src/test-instant-messaging.cpp | 2 +- test/src/test-osg.cpp | 26 -- test/src/test-prolog-swi.cpp.old | 93 ----- test/src/test-w3c.cpp | 9 +- test/uscxml/test-initial-config.scxml | 58 ---- 17 files changed, 76 insertions(+), 960 deletions(-) delete mode 100644 test/src/test-apache-commons.cpp delete mode 100644 test/src/test-curl-multi-api.cpp delete mode 100644 test/src/test-ecmascript-v8.cpp.old delete mode 100644 test/src/test-execution.cpp.old delete mode 100644 test/src/test-initial-config.cpp delete mode 100644 test/src/test-osg.cpp delete mode 100644 test/src/test-prolog-swi.cpp.old delete mode 100644 test/uscxml/test-initial-config.scxml diff --git a/src/bindings/swig/csharp/uscxml.i b/src/bindings/swig/csharp/uscxml.i index 5e98544..334a534 100644 --- a/src/bindings/swig/csharp/uscxml.i +++ b/src/bindings/swig/csharp/uscxml.i @@ -26,6 +26,7 @@ typedef uscxml::InvokerImpl InvokerImpl; typedef uscxml::IOProcessorImpl IOProcessorImpl; typedef uscxml::DataModelImpl DataModelImpl; typedef uscxml::ExecutableContentImpl ExecutableContentImpl; +typedef uscxml::InterpreterIssue InterpreterIssue; %feature("director") uscxml::WrappedInvoker; %feature("director") uscxml::WrappedDataModel; @@ -384,6 +385,7 @@ using System.Runtime.InteropServices; %include "../../../uscxml/concurrency/BlockingQueue.h" %include "../../../uscxml/server/HTTPServer.h" //%include "../../../uscxml/debug/DebuggerServlet.h" +%include "../../../uscxml/debug/InterpreterIssue.h" %include "../../../uscxml/messages/Blob.h" %include "../../../uscxml/messages/Data.h" diff --git a/src/bindings/swig/java/uscxml.i b/src/bindings/swig/java/uscxml.i index 7f25fc3..22fad3c 100644 --- a/src/bindings/swig/java/uscxml.i +++ b/src/bindings/swig/java/uscxml.i @@ -26,6 +26,7 @@ typedef uscxml::InvokerImpl InvokerImpl; typedef uscxml::IOProcessorImpl IOProcessorImpl; typedef uscxml::DataModelImpl DataModelImpl; typedef uscxml::ExecutableContentImpl ExecutableContentImpl; +typedef uscxml::InterpreterIssue InterpreterIssue; %feature("director") uscxml::WrappedInvoker; %feature("director") uscxml::WrappedDataModel; @@ -412,6 +413,7 @@ import java.util.LinkedList; %include "../../../uscxml/concurrency/BlockingQueue.h" %include "../../../uscxml/server/HTTPServer.h" //%include "../../../uscxml/debug/DebuggerServlet.h" +%include "../../../uscxml/debug/InterpreterIssue.h" %include "../../../uscxml/messages/Blob.h" %include "../../../uscxml/messages/Data.h" diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp index 6fa56df..8eb1ce1 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp @@ -341,6 +341,16 @@ bool LuaDataModel::isLocation(const std::string& expr) { } bool LuaDataModel::isValidSyntax(const std::string& expr) { + int preStack = lua_gettop(_luaState); + int err = luaL_loadstring (_luaState, expr.c_str()); + + // clean stack again + lua_pop(_luaState, lua_gettop(_luaState) - preStack); + + + if (err == LUA_ERRSYNTAX) + return false; + return true; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a5840dc..c9f0a9f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,180 +1,73 @@ -# find_program(XMLLINT xmllint) -# if (XMLLINT) -# file(GLOB SCXML_FILES uscxml/*.scxml) -# endif() +function(USCXML_TEST_COMPILE) + set(options BUILD_ONLY) + set(oneValueArgs LABEL NAME) + set(multiValueArgs FILES ARGS) + cmake_parse_arguments(USCXML_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_executable(${USCXML_TEST_NAME} ${USCXML_TEST_FILES}) + target_link_libraries(${USCXML_TEST_NAME} uscxml) + if (NOT ${USCXML_TEST_BUILD_ONLY}) + add_test(${USCXML_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${USCXML_TEST_NAME} ${USCXML_TEST_ARGS}) + set_property(TEST ${USCXML_TEST_NAME} PROPERTY LABELS ${USCXML_TEST_LABEL}) + endif() + set_target_properties(${USCXML_TEST_NAME} PROPERTIES FOLDER "Tests") +endfunction() if (NOT WIN32) - add_executable(test-predicates src/test-predicates.cpp) - target_link_libraries(test-predicates uscxml) - add_test(test-predicates ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-predicates ${CMAKE_SOURCE_DIR}/test/uscxml/test-predicates.scxml) - set_target_properties(test-predicates PROPERTIES FOLDER "Tests") + USCXML_TEST_COMPILE(NAME test-predicates LABEL general/test-predicates FILES src/test-predicates.cpp) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-vxml-mmi-socket LABEL general/test-vxml-mmi-socket FILES src/test-vxml-mmi-socket.cpp) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-vxml-mmi-http LABEL general/test-vxml-mmi-http FILES src/test-vxml-mmi-http.cpp) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-arabica-xpath LABEL general/test-arabica-xpath FILES src/test-arabica-xpath.cpp) + USCXML_TEST_COMPILE(NAME test-mmi LABEL general/test-mmi FILES src/test-mmi.cpp) + USCXML_TEST_COMPILE(NAME test-trie LABEL general/test-trie FILES src/test-trie.cpp) + USCXML_TEST_COMPILE(NAME test-arabica-namespaces LABEL general/test-arabica-namespaces FILES src/test-arabica-namespaces.cpp) + USCXML_TEST_COMPILE(NAME test-arabica-events LABEL general/test-arabica-events FILES src/test-arabica-events.cpp + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/uscxml/arabica/test-arabica-events.xml) + USCXML_TEST_COMPILE(NAME test-arabica-parsing LABEL general/test-arabica-parsing FILES src/test-arabica-parsing.cpp) endif() -add_test(test-execution ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-execution.scxml) -add_test(test-communication ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser -t5493 ${CMAKE_SOURCE_DIR}/test/uscxml/test-communication.scxml) -add_test(test-done-data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-donedata.scxml) - -if (SWI_FOUND) - add_test(test-prolog-swi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser -t2345 ${CMAKE_SOURCE_DIR}/test/uscxml/test-prolog.scxml) +if (APPLE) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-dirmon LABEL general/test-dirmon FILES src/test-dirmon.cpp) endif() -# if (FFMPEG_FOUND) -# add_executable(test-ffmpeg src/test-ffmpeg.cpp) -# target_link_libraries(test-ffmpeg uscxml) -# add_test(test-ffmpeg ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ffmpeg) -# set_target_properties(test-ffmpeg PROPERTIES FOLDER "Tests") -# endif() +USCXML_TEST_COMPILE(BUILD_ONLY NAME test-stress LABEL general/test-stress FILES src/test-stress.cpp) +USCXML_TEST_COMPILE(BUILD_ONLY NAME test-sockets LABEL general/test-sockets FILES src/test-sockets.cpp) -if (V8_FOUND) - add_test(test-ecmascript ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-ecmascript.scxml) -endif() +USCXML_TEST_COMPILE(NAME test-url LABEL general/test-url FILES src/test-url.cpp) +USCXML_TEST_COMPILE(NAME test-promela-parser LABEL general/test-promela-parser FILES src/test-promela-parser.cpp) +USCXML_TEST_COMPILE(NAME test-base64 LABEL general/test-base64 FILES src/test-base64.cpp) +USCXML_TEST_COMPILE(NAME test-eventdelay LABEL general/test-eventdelay FILES src/test-eventdelay.cpp) +USCXML_TEST_COMPILE(NAME test-flat-stateid LABEL general/test-flat-stateid FILES src/test-flat-stateid.cpp) +USCXML_TEST_COMPILE(NAME test-lifecycle LABEL general/test-lifecycle FILES src/test-lifecycle.cpp) +USCXML_TEST_COMPILE(NAME test-issue-reporting LABEL general/test-issue-reporting FILES src/test-issue-reporting.cpp) +USCXML_TEST_COMPILE(NAME test-cmdline-parsing LABEL general/test-cmdline-parsing FILES src/test-cmdline-parsing.cpp) +USCXML_TEST_COMPILE(NAME test-datamodel LABEL general/test-datamodel FILES src/test-datamodel.cpp) -if (OPENSCENEGRAPH_FOUND AND OFF) - add_executable(test-osg src/test-osg.cpp) - target_link_libraries(test-osg uscxml) - set_target_properties(test-osg PROPERTIES FOLDER "Tests") -endif() -add_executable(test-base64 src/test-base64.cpp) -target_link_libraries(test-base64 uscxml) -add_test(test-base64 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-base64) -set_target_properties(test-base64 PROPERTIES FOLDER "Tests") - -add_executable(test-eventdelay src/test-eventdelay.cpp) -target_link_libraries(test-eventdelay uscxml) -add_test(test-eventdelay ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-eventdelay) -set_target_properties(test-eventdelay PROPERTIES FOLDER "Tests") - -add_executable(test-flat-stateid src/test-flat-stateid.cpp) -add_test(test-flat-stateid ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-flat-stateid) -set_target_properties(test-flat-stateid PROPERTIES FOLDER "Tests") - -if (OFF) - add_executable(test-dirmon src/test-dirmon.cpp) - target_link_libraries(test-dirmon uscxml) - add_test(test-dirmon ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dirmon) - set_target_properties(test-dirmon PROPERTIES FOLDER "Tests") +if (EXPECT_FOUND AND TCL_FOUND) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-expect LABEL general/test-expect FILES src/test-expect.cpp) endif() -add_executable(test-lifecycle src/test-lifecycle.cpp) -target_link_libraries(test-lifecycle uscxml) -add_test(test-lifecycle ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-lifecycle) -set_target_properties(test-lifecycle PROPERTIES FOLDER "Tests") - -add_executable(test-issue-reporting src/test-issue-reporting.cpp) -target_link_libraries(test-issue-reporting uscxml) -add_test(test-issue-reporting ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-issue-reporting) -set_target_properties(test-issue-reporting PROPERTIES FOLDER "Tests") - -if (NOT WIN32) - add_executable(test-vxml-mmi-socket src/test-vxml-mmi-socket.cpp) - target_link_libraries(test-vxml-mmi-socket uscxml) - # add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) - set_target_properties(test-vxml-mmi-socket PROPERTIES FOLDER "Tests") - - add_executable(test-vxml-mmi-http src/test-vxml-mmi-http.cpp) - target_link_libraries(test-vxml-mmi-http uscxml) - # add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) - set_target_properties(test-vxml-mmi-http PROPERTIES FOLDER "Tests") - - add_executable(test-trie src/test-trie.cpp) - target_link_libraries(test-trie uscxml) - add_test(test-trie ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-trie) - set_target_properties(test-trie PROPERTIES FOLDER "Tests") - - add_executable(test-arabica-namespaces src/test-arabica-namespaces.cpp) - target_link_libraries(test-arabica-namespaces uscxml) - add_test(test-arabica-namespaces ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-namespaces ${CMAKE_SOURCE_DIR}/test) - set_target_properties(test-arabica-namespaces PROPERTIES FOLDER "Tests") - - add_executable(test-arabica-events src/test-arabica-events.cpp) - target_link_libraries(test-arabica-events uscxml) - add_test(test-arabica-events ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-events ${CMAKE_SOURCE_DIR}/test/uscxml/arabica/test-arabica-events.xml) - set_target_properties(test-arabica-events PROPERTIES FOLDER "Tests") - - add_executable(test-arabica-xpath src/test-arabica-xpath.cpp) - target_link_libraries(test-arabica-xpath uscxml) - add_test(test-arabica-xpath ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-xpath) - set_target_properties(test-arabica-xpath PROPERTIES FOLDER "Tests") - - add_executable(test-arabica-parsing src/test-arabica-parsing.cpp) - target_link_libraries(test-arabica-parsing uscxml) - add_test(test-arabica-xpath ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-parsing) - set_target_properties(test-arabica-parsing PROPERTIES FOLDER "Tests") - - if (NOT BUILD_MINIMAL) - - add_executable(test-stress src/test-stress.cpp) - if (BUILD_AS_PLUGINS) - target_link_libraries(test-stress uscxml invoker_dirmon) - else() - target_link_libraries(test-stress uscxml) - endif() - # add_test(test-stress ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-stress ${CMAKE_SOURCE_DIR}/test/w3c) - set_target_properties(test-stress PROPERTIES FOLDER "Tests") - - # if (LIBPURPLE_FOUND) - # add_executable(test-instant-messaging src/test-instant-messaging.cpp) - # target_link_libraries(test-instant-messaging uscxml ${LIBPURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${ICONV_LIBRARIES}) - # add_test(test-instant-messaging ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-instant-messaging) - # set_target_properties(test-instant-messaging PROPERTIES FOLDER "Tests") - # endif() - - add_executable(test-promela-parser src/test-promela-parser.cpp) - target_link_libraries(test-promela-parser uscxml) - if (BUILD_AS_PLUGINS) - target_link_libraries(test-promela-parser datamodel_promela) - endif() - add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-promela-parser) - set_target_properties(test-promela-parser PROPERTIES FOLDER "Tests") - endif() - +if (LIBPURPLE_FOUND) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-instant-messaging LABEL general/test-instant-messaging FILES src/test-instant-messaging.cpp) endif() -add_executable(test-url src/test-url.cpp) -target_link_libraries(test-url uscxml) -add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-url) -set_target_properties(test-url PROPERTIES FOLDER "Tests") - -add_executable(test-cmdline-parsing src/test-cmdline-parsing.cpp) -target_link_libraries(test-cmdline-parsing uscxml) -# add_test(test-cmdline-parsing ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-cmdline-parsing) -set_target_properties(test-cmdline-parsing PROPERTIES FOLDER "Tests") - -# add_executable(test-initial-config src/test-initial-config.cpp) -# target_link_libraries(test-initial-config uscxml) -# add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-initial-config ${CMAKE_SOURCE_DIR}/test/uscxml/test-initial-config.scxml) -# set_target_properties(test-initial-config PROPERTIES FOLDER "Tests") - -add_executable(test-datamodel src/test-datamodel.cpp) -target_link_libraries(test-datamodel uscxml) -add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-datamodel) -set_target_properties(test-datamodel PROPERTIES FOLDER "Tests") - -add_executable(test-sockets src/test-sockets.cpp) -target_link_libraries(test-sockets uscxml) -# add_test(test-datamodel ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-sockets) -set_target_properties(test-sockets PROPERTIES FOLDER "Tests") +if (FFMPEG_FOUND) + USCXML_TEST_COMPILE(BUILD_ONLY NAME test-ffmpeg LABEL general/test-ffmpeg FILES src/test-ffmpeg.cpp) +endif() +if (SWI_FOUND) + add_test(test-prolog-swi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser -t2345 ${CMAKE_SOURCE_DIR}/test/uscxml/test-prolog.scxml) +endif() -if (NOT WIN32) - add_executable(test-mmi src/test-mmi.cpp) - target_link_libraries(test-mmi uscxml) - add_test(test-mmi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-mmi) - set_target_properties(test-mmi PROPERTIES FOLDER "Tests") +if (ECMA_FOUND) + add_test(test-ecmascript ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-ecmascript.scxml) endif() -# add_executable(test-curl-multi-api src/test-curl-multi-api.cpp) -# target_link_libraries(test-curl-multi-api uscxml) -# add_test(test-curl-multi-api ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-completion) -# set_target_properties(test-curl-multi-api PROPERTIES FOLDER "Tests") +add_test(test-execution ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-execution.scxml) +add_test(test-communication ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser -t5493 ${CMAKE_SOURCE_DIR}/test/uscxml/test-communication.scxml) +add_test(test-done-data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-browser ${CMAKE_SOURCE_DIR}/test/uscxml/test-donedata.scxml) -if (EXPECT_FOUND AND TCL_FOUND) - add_executable(test-expect - src/test-expect.cpp) - target_link_libraries(test-expect uscxml ${EXPECT_LIBRARY} ${TCL_LIBRARY}) - set_target_properties(test-expect PROPERTIES FOLDER "Tests") -endif() if (NOT BUILD_MINIMAL) add_executable(test-w3c src/test-w3c.cpp) @@ -197,7 +90,7 @@ if (NOT BUILD_MINIMAL) set_tests_properties(${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "entering final state, invocation was not cancelled") elseif (TEST_NAME STREQUAL "ecma/test307.scxml") - set_tests_properties(${TEST_NAME} PROPERTIES + set_tests_properties(${TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION "error in state") endif() endif() diff --git a/test/src/test-apache-commons.cpp b/test/src/test-apache-commons.cpp deleted file mode 100644 index 9ac4442..0000000 --- a/test/src/test-apache-commons.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "uscxml/Interpreter.h" -#include - -using namespace uscxml; -using namespace Arabica::DOM; -using namespace Arabica::XPath; - -static std::string path; - -bool testEvents1() { - LOG(INFO) << "---- testEvent1 "; - Interpreter* interpreter = Interpreter::fromURI(path + "/eventdata-01.xml"); - interpreter->start(); - interpreter->waitForStabilization(); - assert(interpreter->getConfiguration().size() == 1); - assert(Interpreter::isMember(interpreter->getState("state1"), interpreter->getConfiguration())); - - Event eventFoo; - eventFoo.name = "event.foo"; - eventFoo.atom = "3"; - interpreter->receive(eventFoo); - interpreter->waitForStabilization(); - assert(interpreter->getConfiguration().size() == 1); - assert(Interpreter::isMember(interpreter->getState("state3"), interpreter->getConfiguration())); - - Event eventBar; - eventBar.name = "event.bar"; - eventBar.atom = "6"; - interpreter->receive(eventBar); - interpreter->waitForStabilization(); - assert(interpreter->getConfiguration().size() == 1); - assert(Interpreter::isMember(interpreter->getState("state6"), interpreter->getConfiguration())); - - Event eventBaz; - eventBaz.name = "event.baz"; - eventBaz.atom = "7"; - interpreter->receive(eventBaz); - - delete interpreter; - return true; -} - -bool testEvents2() { - LOG(INFO) << "---- testEvent2 "; - Interpreter* interpreter = Interpreter::fromURI(path + "/eventdata-02.xml"); - interpreter->start(); - interpreter->waitForStabilization(); - assert(interpreter->getConfiguration().size() == 1); - assert(Interpreter::isMember(interpreter->getState("state0"), interpreter->getConfiguration())); - - Event eventConnAlert; - eventConnAlert.name = "connection.alerting"; - eventConnAlert.atom = "'line2'"; - interpreter->receive(eventConnAlert); - interpreter->waitForStabilization(); - assert(interpreter->getConfiguration().size() == 1); - assert(Interpreter::isMember(interpreter->getState("state2"), interpreter->getConfiguration())); - - Event eventConnAlert2; - eventConnAlert2.name = "connection.alerting"; - eventConnAlert2.compound["line"] = Data(std::string("4")); - interpreter->receive(eventConnAlert2); - - delete interpreter; - return true; -} - -//bool testEvents3() { -// LOG(INFO) << "---- testEvent3 "; -// Interpreter* Interpreter = new Interpreter(path + "/eventdata-03.xml"); -// interpreter->start(); -// interpreter->waitForStabilization(); -// Thread::sleepMs(200); -// assert(interpreter->getConfiguration().size() == 1); -// assert(Interpreter::isMember(interpreter->getState("state0"), interpreter->getConfiguration())); -// -// Event eventConnAlert; -// eventConnAlert.name = "connection.alerting"; -// eventConnAlert.atom = "'line2'"; -// interpreter->receive(eventConnAlert); -// Thread::sleepMs(200); -// assert(interpreter->getConfiguration().size() == 1); -// assert(Interpreter::isMember(interpreter->getState("state2"), interpreter->getConfiguration())); -// -// Event eventConnAlert2; -// eventConnAlert2.name = "connection.alerting"; -// eventConnAlert2.compound["line"] = Data(std::string("4")); -// interpreter->receive(eventConnAlert2); -// Thread::sleepMs(200); -// assert(interpreter->getConfiguration().size() == 1); -// assert(Interpreter::isMember(interpreter->getState("state4"), interpreter->getConfiguration())); -// -// delete Interpreter; -// return true; -//} - - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to scxml file from apache commons distribution" << std::endl; - exit(EXIT_FAILURE); - } - - path = "file://"; - path += argv[1]; - - if (!testEvents1()) - return EXIT_FAILURE; - if (!testEvents2()) - return EXIT_FAILURE; -// if (!testEvents3()) -// return EXIT_FAILURE; - -// -// Interpreter* scxmlInterpreter = new Interpreter(path + "/tie-breaker-01.xml"); -// SCXMLRunner* scxmlRun = new SCXMLRunner(scxmlInterpreter); -// scxmlRun->start(); -// -// Thread::sleepMs(100); -// assert(Interpreter::isMember(scxmlinterpreter->getState("ten"), scxmlinterpreter->getConfiguration())); -// -// boost::shared_ptr event = boost::shared_ptr(new Event()); -// event->name = "ten.done"; -// scxmlinterpreter->receive(event); -// scxmlRun->join(); -// scxmlinterpreter->receive(event); - -} \ No newline at end of file diff --git a/test/src/test-arabica-namespaces.cpp b/test/src/test-arabica-namespaces.cpp index 32feacd..3214d9f 100644 --- a/test/src/test-arabica-namespaces.cpp +++ b/test/src/test-arabica-namespaces.cpp @@ -33,7 +33,6 @@ assert(InterpreterImpl::filterChildElements(origNS.xmlNSPrefix + "baz", origDoc. Test DOM manipulations and document cloning with different namespace scenarios */ -static std::string testPath; static Arabica::XPath::XPath _xpath; std::pair, NameSpaceInfo> parse(const std::string xmlString) { @@ -159,12 +158,6 @@ static void validateRootFooBarBaz(std::pair, NameSpaceInfo int main(int argc, char** argv) { - if (argc < 2) { - std::cerr << "Expected path to the tests as first argument"; - exit(EXIT_FAILURE); - } - testPath = argv[1]; - // No namespaces at all { std::stringstream xmlSS; diff --git a/test/src/test-arabica-xpath.cpp b/test/src/test-arabica-xpath.cpp index ce389fa..998f4aa 100644 --- a/test/src/test-arabica-xpath.cpp +++ b/test/src/test-arabica-xpath.cpp @@ -194,7 +194,7 @@ int main(int argc, char** argv) { assert(SA::construct_from_utf8("root") == result.asString()); } // testLocalNameFn1 - { + if (0) { using namespace Arabica::XPath; Arabica::DOM::DocumentFragment frag = document_.createDocumentFragment(); frag.appendChild(document_.createElement("foo")); @@ -205,7 +205,7 @@ int main(int argc, char** argv) { svr.setVariable("fruit", ns); parser.setVariableResolver(svr); - XPathValue result = parser.evaluate(SA::construct_from_utf8("local-name($fruit/foo) = 'foo'"), document_); + XPathValue result = parser.evaluate(SA::construct_from_utf8("local-name($fruit/foo) == 'foo'"), document_); std::cout << result.asBool() << std::endl; } diff --git a/test/src/test-cmdline-parsing.cpp b/test/src/test-cmdline-parsing.cpp index 6fa0c57..edf90bc 100644 --- a/test/src/test-cmdline-parsing.cpp +++ b/test/src/test-cmdline-parsing.cpp @@ -8,7 +8,7 @@ int main(int argc, char** argv) { using namespace uscxml; if (true) { - int testArgc = 11; + int testArgc = 10; const char* testArgv[] = { "test-cmdline-parsing", "--verbose", diff --git a/test/src/test-curl-multi-api.cpp b/test/src/test-curl-multi-api.cpp deleted file mode 100644 index 67735d2..0000000 --- a/test/src/test-curl-multi-api.cpp +++ /dev/null @@ -1,404 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uscxml/concurrency/tinythread.h" - -// use arabica URL parser -#include - -class URL; - -class URLMonitor { -public: - virtual void downloadStarted(const URL& url) {}; - virtual void downloadCompleted(const URL& url) {}; - virtual void downloadFailed(const URL& url, int errorCode) {}; - virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {}; - virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {}; -}; - -class URLImpl : public boost::enable_shared_from_this { -public: - URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false) { - _handle = curl_easy_init(); - if (_handle != NULL) { - CURLcode curlError; - curlError = curl_easy_setopt(_handle, CURLOPT_URL, _uri.as_string().c_str()); - if (curlError != CURLE_OK) - LOG(ERROR) << "Cannot set url to " << _uri.as_string() << ": " << curl_easy_strerror(curlError); - - curlError = curl_easy_setopt(_handle, CURLOPT_WRITEDATA, this); - if (curlError != CURLE_OK) - LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError); - - curlError = curl_easy_setopt(_handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler); - if (curlError != CURLE_OK) - LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError); - - curlError = curl_easy_setopt(_handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler); - if (curlError != CURLE_OK) - LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError); - - curlError = curl_easy_setopt(_handle, CURLOPT_HEADERDATA, this); - if (curlError != CURLE_OK) - LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError); - } else { - LOG(ERROR) << "curl_easy_init returned NULL, this is bad!"; - } - } - - ~URLImpl() { - if (_handle != NULL) - curl_easy_cleanup(_handle); - } - - static size_t writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata) { - URLImpl* url = (URLImpl*)userdata; - url->_content.write((char*)ptr, size * nmemb); - return size * nmemb; - } - - static size_t headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata) { - URLImpl* url = (URLImpl*)userdata; - url->_header.write((char*)ptr, size * nmemb); - return size * nmemb; - } - - void addMonitor(URLMonitor* monitor) { - _monitors.insert(monitor); - } - void removeMonitor(URLMonitor* monitor) { - _monitors.erase(monitor); - } - - const bool isAbsolute() const { - return _uri.is_absolute(); - } - const std::string scheme() const { - return _uri.scheme(); - } - const std::string host() const { - return _uri.host(); - } - const std::string port() const { - return _uri.port(); - } - const std::string path() const { - return _uri.path(); - } - const std::string asString() const { - return _uri.as_string(); - } - - void downloadStarted() { - std::cout << "Starting download of " << asString() << std::endl; - _content.str(""); - _content.clear(); - _header.str(""); - _header.clear(); - monIter_t monIter = _monitors.begin(); - while(monIter != _monitors.end()) { -// (*monIter)->downloadStarted(URL(shared_from_this())); - monIter++; - } - } - - void downloadCompleted() { - std::cout << "Finished loading " << asString() << " with " << _content.str().size() << " bytes" << std::endl; - _isDownloaded = true; - } - - void downloadFailed(int errorCode) { - std::cout << "FAILED!" << strerror(errorCode) << std::endl; - } - - std::string getHeader(bool forceReload = false) { - return _header.str(); - } - - std::string getContent(bool forceReload = false) { - return _content.str(); - } - - std::stringstream _content; - std::stringstream _header; - CURL* _handle; - Arabica::io::URI _uri; - bool _isDownloaded; - - std::set _monitors; - typedef std::set::iterator monIter_t; -}; - -class URL { -public: - URL() : _impl() {} - URL(const std::string url) : _impl(new URLImpl(url)) {} - URL(boost::shared_ptr const impl) : _impl(impl) { } - URL(const URL& other) : _impl(other._impl) { } - virtual ~URL() {}; - - operator bool() const { - return _impl; - } - bool operator< (const URL& other) const { - return _impl < other._impl; - } - bool operator==(const URL& other) const { - return _impl == other._impl; - } - bool operator!=(const URL& other) const { - return _impl != other._impl; - } - URL& operator= (const URL& other) { - _impl = other._impl; - return *this; - } - - std::string getHeader() { - return _impl->getHeader(); - } - std::string getContent() { - return _impl->getContent(); - } - - const bool toAbsoluteCwd() { - return _impl->toAbsoluteCwd(); - } - const bool toAbsolute(const std::string& baseUrl) { - return _impl->toAbsolute(baseUrl); - } - const bool toAbsolute(const URL& baseUrl) { - return _impl->toAbsolute(baseUrl.asString()); - } - const std::string asLocalFile(const std::string& suffix, bool reload = false) { - return _impl->asLocalFile(suffix, reload); - } - - void addMonitor(URLMonitor* monitor) { - _impl->addMonitor(monitor); - } - void removeMonitor(URLMonitor* monitor) { - _impl->removeMonitor(monitor); - } - - const bool isAbsolute() const { - return _impl->isAbsolute(); - } - const std::string scheme() const { - return _impl->scheme(); - } - const std::string host() const { - return _impl->host(); - } - const std::string port() const { - return _impl->port(); - } - const std::string path() const { - return _impl->path(); - } - const std::string asString() const { - return _impl->asString(); - } - - friend class URLFetcher; - friend std::ostream & operator<<(std::ostream &stream, const URL& p); - -protected: - void downloadStarted() { - return _impl->downloadStarted(); - } - void downloadCompleted() { - return _impl->downloadCompleted(); - } - void downloadFailed(int errorCode) { - return _impl->downloadFailed(errorCode); - } - - boost::shared_ptr _impl; -}; - -class URLFetcher { -public: - URLFetcher() { - _multiHandle = curl_multi_init(); - start(); - } - - ~URLFetcher() { - curl_multi_cleanup(_multiHandle); - stop(); - } - - void fetchURL(URL& url) { - tthread::lock_guard lock(_mutex); - url.downloadStarted(); - _handlesToURLs[url._impl->_handle] = url; - curl_multi_add_handle(_multiHandle, url._impl->_handle); - _condVar.notify_all(); - } - - void breakURL(URL& url) { - tthread::lock_guard lock(_mutex); - if (_handlesToURLs.find(url._impl->_handle) != _handlesToURLs.end()) { - url.downloadFailed(0); - curl_multi_remove_handle(_multiHandle, url._impl->_handle); - _handlesToURLs.erase(url._impl->_handle); - } - } - - void start() { - tthread::lock_guard lock(_mutex); - if (!_isStarted) { - _isStarted = true; - _thread = new tthread::thread(URLFetcher::run, this); - } - } - - void stop() { - tthread::lock_guard lock(_mutex); - if (_isStarted) { - _isStarted = false; - _thread->join(); - delete _thread; - } - } - - static void run(void* instance) { - URLFetcher* THIS = (URLFetcher*)instance; - THIS->_mutex.lock(); - while(THIS->_isStarted) { - if(THIS->_handlesToURLs.size() > 0) { - THIS->_mutex.unlock(); - THIS->perform(); - THIS->_mutex.lock(); - } - THIS->_condVar.wait(THIS->_mutex); - } - THIS->_mutex.unlock(); - } - - void perform() { - - CURLMsg *msg; /* for picking up messages with the transfer status */ - int msgsLeft; /* how many messages are left */ - int stillRunning; - - { - tthread::lock_guard lock(_mutex); - curl_multi_perform(_multiHandle, &stillRunning); - } - - do { - struct timeval timeout; - int rc; /* select() return code */ - - fd_set fdread, fdwrite, fdexcep; - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcep); - - int maxfd = -1; - long curlTimeOut = -1; - - /* set a suitable timeout to play around with */ - timeout.tv_sec = 1; - timeout.tv_usec = 0; - - { - tthread::lock_guard lock(_mutex); - curl_multi_timeout(_multiHandle, &curlTimeOut); - } - - if(curlTimeOut >= 0) { - timeout.tv_sec = curlTimeOut / 1000; - if(timeout.tv_sec > 1) - timeout.tv_sec = 1; - else - timeout.tv_usec = (curlTimeOut % 1000) * 1000; - } - - /* get file descriptors from the transfers */ - { - tthread::lock_guard lock(_mutex); - curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd); - } - - rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); - - switch(rc) { - case -1: - /* select error */ - break; - case 0: /* timeout */ - default: { /* action */ - tthread::lock_guard lock(_mutex); - curl_multi_perform(_multiHandle, &stillRunning); - } - break; - } - - { - tthread::lock_guard lock(_mutex); - while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) { - if (msg->msg == CURLMSG_DONE) { - _handlesToURLs[msg->easy_handle].downloadCompleted(); - curl_multi_remove_handle(_multiHandle, msg->easy_handle); - _handlesToURLs.erase(msg->easy_handle); - } else { - switch (msg->data.result) { - case CURLM_OK: - break; - case CURLM_BAD_HANDLE: - case CURLM_BAD_EASY_HANDLE: - case CURLM_OUT_OF_MEMORY: - case CURLM_INTERNAL_ERROR: - case CURLM_BAD_SOCKET: - case CURLM_UNKNOWN_OPTION: - case CURLM_LAST: - _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result); - curl_multi_remove_handle(_multiHandle, msg->easy_handle); - _handlesToURLs.erase(msg->easy_handle); - default: - break; - } - } - } - } - } while(stillRunning && _isStarted); - - } - - tthread::condition_variable _condVar; - tthread::thread* _thread; - tthread::recursive_mutex _mutex; - bool _isStarted; - - std::map _handlesToURLs; - CURLM* _multiHandle; -}; - - -int main(int argc, char** argv) { - URLFetcher fetcher; - URL heise("http://www.heise.de"); - URL localFile("file:///Users/sradomski/Desktop/scxml.xsd"); - URL slashdot("http://slashdot.org"); - URL asdf("daf://localhost:234"); - URL bahn("http://www.bahn.de"); - - fetcher.fetchURL(heise); - fetcher.fetchURL(localFile); - fetcher.fetchURL(asdf); - fetcher.fetchURL(slashdot); - fetcher.fetchURL(bahn); - - while(1) {} -} \ No newline at end of file diff --git a/test/src/test-ecmascript-v8.cpp.old b/test/src/test-ecmascript-v8.cpp.old deleted file mode 100644 index 9ce39d9..0000000 --- a/test/src/test-ecmascript-v8.cpp.old +++ /dev/null @@ -1,24 +0,0 @@ -#include "uscxml/Interpreter.h" -#include "uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h" - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to test-ecmascript.scxml" << std::endl; - exit(EXIT_FAILURE); - } - - using namespace uscxml; - using namespace Arabica::DOM; - using namespace Arabica::XPath; - - Interpreter* scxml = Interpreter::fromURI(argv[1]); - scxml->start(); - scxml->waitForStabilization(); - - Event event1; - event1.name = "event1"; - scxml->receive(event1); - scxml->join(); - tthread::this_thread::sleep_for(tthread::chrono::milliseconds(500)); - -} \ No newline at end of file diff --git a/test/src/test-execution.cpp.old b/test/src/test-execution.cpp.old deleted file mode 100644 index 272ce41..0000000 --- a/test/src/test-execution.cpp.old +++ /dev/null @@ -1,16 +0,0 @@ -#include "uscxml/Interpreter.h" - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to test-execution.scxml" << std::endl; - exit(EXIT_FAILURE); - } - - using namespace uscxml; - using namespace Arabica::DOM; - using namespace Arabica::XPath; - - Interpreter* interpreter = Interpreter::fromURI(argv[1]); - interpreter->dump(); - interpreter->interpret(); -} \ No newline at end of file diff --git a/test/src/test-initial-config.cpp b/test/src/test-initial-config.cpp deleted file mode 100644 index dcba84d..0000000 --- a/test/src/test-initial-config.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "uscxml/Message.h" -#include "uscxml/Interpreter.h" -#include -#include -#include - -using namespace uscxml; -using namespace boost; - - -int main(int argc, char** argv) { -#ifdef _WIN32 - WSADATA wsaData; - WSAStartup(MAKEWORD(2, 2), &wsaData); -#endif - - if (argc != 2) { - std::cerr << "Expected path to test-initial-config.scxml" << std::endl; - exit(EXIT_FAILURE); - } - - std::string test = argv[1]; - - { - Interpreter interpreter = Interpreter::fromURI(test); - std::vector states; - states.push_back("finish_shortcut"); - states.push_back("ADMINISTRATIVE_NON-HR-MANAGEMENT"); - states.push_back("HR-MANAGER_MANAGE-HR"); - states.push_back("SYSTEM_1.1_BEGIN"); - states.push_back("COORDINATOR_1"); - interpreter.setConfiguration(states); - interpreter.interpret(); - } - -} \ No newline at end of file diff --git a/test/src/test-instant-messaging.cpp b/test/src/test-instant-messaging.cpp index a63df34..4375e94 100644 --- a/test/src/test-instant-messaging.cpp +++ b/test/src/test-instant-messaging.cpp @@ -268,7 +268,7 @@ int main(int argc, char *argv[]) { account = purple_account_new("uscxml@localhost", "prpl-jabber"); /* Get the password for the account */ - purple_account_set_password(account, "password", NULL, NULL); + purple_account_set_password(account, "password"); /* It's necessary to enable the account first. */ purple_account_set_enabled(account, UI_ID, TRUE); diff --git a/test/src/test-osg.cpp b/test/src/test-osg.cpp deleted file mode 100644 index a3fcdc6..0000000 --- a/test/src/test-osg.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -#include "uscxml/concurrency/tinythread.h" - -tthread::thread* thread; -osgViewer::Viewer viewer; - -void run(void* instance) { - osg::ref_ptr loadedModel = osgDB::readNodeFile("/Users/sradomski/Documents/TK/Projects/SmartVortex/Code/FE-Design/data/sv_processed/HARD_MP_VAL_000.wrl.osgb"); - viewer.setSceneData(loadedModel.get()); - -// viewer.startThreading(); - viewer.run(); -} - - -int main(int argc, char** argv) { - viewer.setThreadingModel(osgViewer::ViewerBase::SingleThreaded); - viewer.realize(); - thread = new tthread::thread(run, NULL); - while(true) { - tthread::this_thread::sleep_for(tthread::chrono::microseconds(1000)); -// viewer.eventTraversal(); - } -} \ No newline at end of file diff --git a/test/src/test-prolog-swi.cpp.old b/test/src/test-prolog-swi.cpp.old deleted file mode 100644 index 9e44f12..0000000 --- a/test/src/test-prolog-swi.cpp.old +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include -#include -#include "uscxml/config.h" - -using namespace std; - -int main(void) { - const char* swibin = getenv("SWI_BINARY"); - if (swibin == NULL) - swibin = SWI_BINARY; - - static char * av[] = { - (char*)swibin, -// "--quiet", -// "-s", -// "/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl", - NULL - }; - if( ! PL_initialise(1,av)) { - cout<<"error initializing"< 0) { -// std::cout << "Yes!" << std::endl; -// } else { -// std::cout << "No!" << std::endl; -// } - -// std::cout << compound.name() << std::endl; -// PlTermv filename("/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl"); -// PlQuery loadFiles("system", "load_files", filename); - -// predicate_t loadFiles = PL_predicate("load_files",1,"system"); -// term_t h0 = PL_new_term_refs(1); - -// int rval; -// const char * expression = "/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl"; -// PL_put_atom_chars(h0,expression); -// rval = PL_call_predicate(NULL, PL_Q_NORMAL, loadFiles, h0); - -// PL_halt( rval ? 0 : 1 ); - -// PL_close_foreign_frame(fid); - return 0; -} diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp index 4bd27b1..31ab9b9 100644 --- a/test/src/test-w3c.cpp +++ b/test/src/test-w3c.cpp @@ -95,6 +95,8 @@ void customTerminate() { abort(); } +int retCode = EXIT_FAILURE; + class W3CStatusMonitor : public uscxml::InterpreterMonitor { void beforeTakingTransition(uscxml::Interpreter interpreter, const Arabica::DOM::Element& transition, bool moreComing) { @@ -147,17 +149,16 @@ class W3CStatusMonitor : public uscxml::InterpreterMonitor { std::cout << ATTR_CAST(config[0], "id") << std::endl; if (boost::starts_with(ATTR_CAST(config[0], "id"), "active:{pass")) { std::cout << "TEST SUCCEEDED" << std::endl; - exit(EXIT_SUCCESS); + retCode = EXIT_SUCCESS; } } else { if (boost::iequals(ATTR_CAST(config[0], "id"), "pass")) { std::cout << "TEST SUCCEEDED" << std::endl; - exit(EXIT_SUCCESS); + retCode = EXIT_SUCCESS; } } } std::cout << "TEST FAILED" << std::endl; - exit(EXIT_FAILURE); } Arabica::XPath::NodeSet exitingStates; @@ -224,5 +225,5 @@ int main(int argc, char** argv) { while(interpreter.runOnMainThread(25)); } - return EXIT_SUCCESS; + return retCode; } \ No newline at end of file diff --git a/test/uscxml/test-initial-config.scxml b/test/uscxml/test-initial-config.scxml deleted file mode 100644 index cac0b8a..0000000 --- a/test/uscxml/test-initial-config.scxml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v0.12