From 64cc2ce105cf57fcba637b309664b4bc74ae7d82 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Mon, 17 Sep 2012 01:20:57 +0200 Subject: Fixed all tests --- src/uscxml/Interpreter.h | 3 ++- test/CMakeLists.txt | 6 +++--- test/src/test-communication.cpp | 10 +++++++--- test/src/test-communication.scxml | 2 +- test/src/test-ecmascript-v8.cpp | 5 ++--- test/src/test-eventdelay.cpp | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index cad8ee8..4a948dc 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -39,7 +39,8 @@ namespace uscxml { void start(); static void run(void*); - + void join() { if (_thread != NULL) _thread->join(); }; + void interpret(); bool validate(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0abcafa..1fdaaee 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,15 +20,15 @@ set_target_properties(test-ecmascript-v8 PROPERTIES FOLDER "Tests") add_executable(test-communication src/test-communication.cpp) target_link_libraries(test-communication uscxml) -add_test(test-communication test-communication) +add_test(test-communication ${CURRENT_BINARY_DIR}/test-communication ${CMAKE_SOURCE_DIR}/test/src/test-communication.scxml) set_target_properties(test-communication PROPERTIES FOLDER "Tests") add_executable(test-eventdelay src/test-eventdelay.cpp) target_link_libraries(test-eventdelay uscxml) -add_test(test-eventdelay test-eventdelay) +add_test(test-eventdelay ${CURRENT_BINARY_DIR}/test-eventdelay) set_target_properties(test-eventdelay PROPERTIES FOLDER "Tests") add_executable(test-completion src/test-completion.cpp) target_link_libraries(test-completion uscxml) -add_test(test-completion ${CMAKE_SOURCE_DIR}/test/src/test-donedata.scxml) +add_test(test-completion ${CURRENT_BINARY_DIR}/test-completion ${CMAKE_SOURCE_DIR}/test/src/test-donedata.scxml) set_target_properties(test-completion PROPERTIES FOLDER "Tests") diff --git a/test/src/test-communication.cpp b/test/src/test-communication.cpp index a3c2428..ac0fa6c 100644 --- a/test/src/test-communication.cpp +++ b/test/src/test-communication.cpp @@ -16,12 +16,16 @@ int main(int argc, char** argv) { // e.compound["foo2"] = Data("bar2", Data::VERBATIM); // std::cout << e.toDocument() << std::endl; - for (int i = 0; i < 1; i++) { + int nrInterpreters = 1; + for (int i = 0; i < nrInterpreters; i++) { _interpreters.push_back(Interpreter::fromURI(argv[1])); _interpreters.back()->start(); } - while(true) - tthread::this_thread::sleep_for(tthread::chrono::milliseconds(1000000)); + std::list::iterator interIter = _interpreters.begin(); + while(interIter != _interpreters.end()) { + (*interIter)->join(); + interIter++; + } } \ No newline at end of file diff --git a/test/src/test-communication.scxml b/test/src/test-communication.scxml index c1c1f65..610f8cc 100644 --- a/test/src/test-communication.scxml +++ b/test/src/test-communication.scxml @@ -43,7 +43,7 @@ This is some content you got there dude! - + diff --git a/test/src/test-ecmascript-v8.cpp b/test/src/test-ecmascript-v8.cpp index d11fc61..9e7635b 100644 --- a/test/src/test-ecmascript-v8.cpp +++ b/test/src/test-ecmascript-v8.cpp @@ -18,8 +18,7 @@ int main(int argc, char** argv) { Event event1; event1.name = "event1"; scxml->receive(event1); - scxml->waitForStabilization(); - while(true) - tthread::this_thread::sleep_for(tthread::chrono::milliseconds(200)); + scxml->join(); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(500)); } \ No newline at end of file diff --git a/test/src/test-eventdelay.cpp b/test/src/test-eventdelay.cpp index 6a28e44..45a14b7 100644 --- a/test/src/test-eventdelay.cpp +++ b/test/src/test-eventdelay.cpp @@ -26,7 +26,7 @@ int main(int argc, char** argv) { // eq->addEvent("bar", callback, 300, (void*)"event bar"); // eq->addEvent("baz", callback, 400, (void*)"event baz"); - for (unsigned int i = 0; i <= 5000; i += 500) { + for (unsigned int i = 0; i <= 2000; i += 200) { // eq->stop(); std::stringstream ss; ss << i; @@ -34,6 +34,6 @@ int main(int argc, char** argv) { std::cout << "Added " << i << std::endl; // eq->start(); } - tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20000)); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(2000)); } \ No newline at end of file -- cgit v0.12