diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 51 | ||||
-rw-r--r-- | test/ctest/CTestCustom.ctest.in | 9 | ||||
-rw-r--r-- | test/src/test-w3c.cpp | 76 | ||||
-rwxr-xr-x | test/w3c/analyze_tests.pl | 33 | ||||
-rw-r--r-- | test/w3c/run_minimized_flat_test.cmake | 21 | ||||
-rw-r--r-- | test/w3c/run_minimized_test.cmake | 16 | ||||
-rw-r--r-- | test/w3c/run_promela_test.cmake | 14 |
7 files changed, 146 insertions, 74 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dd86ac9..3ea960c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -78,6 +78,30 @@ if (NOT BUILD_MINIMAL) target_link_libraries(test-w3c uscxml uscxml_transform) set_target_properties(test-w3c PROPERTIES FOLDER "Tests") + # copy resources + file(GLOB_RECURSE W3C_RESOURCES + w3c/*.txt + w3c/*sub*.scxml + ) + + foreach(W3C_RESOURCE ${W3C_RESOURCES} ) + # we abuse this as head and tail + get_filename_component(W3C_RESOURCE_PATH ${W3C_RESOURCE} PATH) + get_filename_component(W3C_TEST_TYPE ${W3C_RESOURCE_PATH} NAME) + + if (BUILD_TESTS_W3C_ECMA AND W3C_TEST_TYPE STREQUAL "ecma") + file(COPY ${W3C_RESOURCE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ecma) + elseif (BUILD_TESTS_W3C_XPATH AND W3C_TEST_TYPE STREQUAL "xpath") + file(COPY ${W3C_RESOURCE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/xpath) + elseif (BUILD_TESTS_W3C_LUA AND W3C_TEST_TYPE STREQUAL "lua") + file(COPY ${W3C_RESOURCE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/lua) + elseif (BUILD_TESTS_W3C_PROMELA AND W3C_TEST_TYPE STREQUAL "promela") + file(COPY ${W3C_RESOURCE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/lua) + endif() + + endforeach() + + # prepare tests file(GLOB_RECURSE W3C_TESTS w3c/*.scxml ) @@ -102,6 +126,31 @@ if (NOT BUILD_MINIMAL) if (BUILD_TESTS_FSM_ECMA AND TEST_NAME MATCHES "^ecma\\/.*") add_test("fsm/${TEST_NAME}" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-w3c -f ${W3C_TEST}) set_property(TEST "fsm/${TEST_NAME}" PROPERTY LABELS "fsm/${TEST_NAME}") + + add_test(NAME "minimized/${TEST_NAME}" + COMMAND ${CMAKE_COMMAND} + -DOUTDIR:FILEPATH=${CMAKE_CURRENT_BINARY_DIR}/ecma + -DTESTFILE:FILEPATH=${W3C_TEST} + -DUSCXML_TRANSFORM_BIN:FILEPATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-transform + -DUSCXML_W3C_TEST_BIN:FILEPATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-w3c + -P ${CMAKE_CURRENT_SOURCE_DIR}/w3c/run_minimized_test.cmake) + set_property(TEST "minimized/${TEST_NAME}" PROPERTY LABELS "minimized/${TEST_NAME}") + + set_tests_properties(${TEST_NAME} PROPERTIES DEPENDS uscxml-transform) + set_tests_properties(${TEST_NAME} PROPERTIES DEPENDS test-w3c) + + add_test(NAME "fsm/minimized/${TEST_NAME}" + COMMAND ${CMAKE_COMMAND} + -DOUTDIR:FILEPATH=${CMAKE_CURRENT_BINARY_DIR}/ecma + -DTESTFILE:FILEPATH=${W3C_TEST} + -DUSCXML_TRANSFORM_BIN:FILEPATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-transform + -DUSCXML_W3C_TEST_BIN:FILEPATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-w3c + -P ${CMAKE_CURRENT_SOURCE_DIR}/w3c/run_minimized_flat_test.cmake) + set_property(TEST "fsm/minimized/${TEST_NAME}" PROPERTY LABELS "fsm/minimized/${TEST_NAME}") + + set_tests_properties(${TEST_NAME} PROPERTIES DEPENDS uscxml-transform) + set_tests_properties(${TEST_NAME} PROPERTIES DEPENDS test-w3c) + endif() if (BUILD_TESTS_W3C_XPATH AND TEST_NAME MATCHES "^xpath\\/.*") @@ -131,7 +180,7 @@ if (NOT BUILD_MINIMAL) add_test(NAME "spin/${TEST_NAME}" COMMAND ${CMAKE_COMMAND} - -DOUTDIR:FILEPATH=${CMAKE_CURRENT_BINARY_DIR} + -DOUTDIR:FILEPATH=${CMAKE_CURRENT_BINARY_DIR}/promela -DTESTFILE:FILEPATH=${W3C_TEST} -DUSCXML_TRANSFORM_BIN:FILEPATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/uscxml-transform -DSPIN_BIN:FILEPATH=${SPIN} diff --git a/test/ctest/CTestCustom.ctest.in b/test/ctest/CTestCustom.ctest.in index c4fc9c9..3af297e 100644 --- a/test/ctest/CTestCustom.ctest.in +++ b/test/ctest/CTestCustom.ctest.in @@ -28,6 +28,15 @@ set(CTEST_CUSTOM_TESTS_IGNORE "fsm/ecma/test415.scxml" # manual test # "fsm/ecma/test513.txt" # manual test + ### Ignore for flattened, minimized ECMAScript datamodel + "fsm/minimized/ecma/test178.scxml" # manual test + "fsm/minimized/ecma/test230.scxml" # manual test + "fsm/minimized/ecma/test250.scxml" # manual test + "fsm/minimized/ecma/test301.scxml" # manual test + "fsm/minimized/ecma/test307.scxml" # manual test + "fsm/minimized/ecma/test415.scxml" # manual test + # "fsm/ecma/test513.txt" # manual test + ### Just ignore the XPath datamodel tests that hang, most of the rest fails as well "xpath/test388.scxml" # hangs "xpath/test580.scxml" # hangs diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp index e2efa59..c7f136d 100644 --- a/test/src/test-w3c.cpp +++ b/test/src/test-w3c.cpp @@ -24,74 +24,16 @@ static std::string documentURI; int retCode = EXIT_FAILURE; -class W3CStatusMonitor : public uscxml::InterpreterMonitor { +class W3CStatusMonitor : public uscxml::StateTransitionMonitor { - void beforeTakingTransition(uscxml::Interpreter interpreter, const Arabica::DOM::Element<std::string>& transition, bool moreComing) { - std::cout << "Transition: " << uscxml::DOMUtils::xPathForNode(transition) << std::endl; +void beforeCompletion(uscxml::Interpreter interpreter) { + if (interpreter.getConfiguration().size() == 1 && interpreter.isInState("pass")) { + std::cout << "TEST SUCCEEDED" << std::endl; + retCode = EXIT_SUCCESS; + return; } - - void onStableConfiguration(uscxml::Interpreter interpreter) { - std::cout << "Config: {"; - printNodeSet(interpreter.getConfiguration()); - std::cout << "}" << std::endl; - } - - void beforeProcessingEvent(uscxml::Interpreter interpreter, const uscxml::Event& event) { - std::cout << "Event: " << event.name << std::endl; - } - - void beforeExitingState(uscxml::Interpreter interpreter, const Arabica::DOM::Element<std::string>& state, bool moreComing) { - exitingStates.push_back(state); - if (!moreComing) { - std::cout << "Exiting: {"; - printNodeSet(exitingStates); - std::cout << "}" << std::endl; - exitingStates = Arabica::XPath::NodeSet<std::string>(); - } - } - - void beforeEnteringState(uscxml::Interpreter interpreter, const Arabica::DOM::Element<std::string>& state, bool moreComing) { - enteringStates.push_back(state); - if (!moreComing) { - std::cout << "Entering: {"; - printNodeSet(enteringStates); - std::cout << "}" << std::endl; - enteringStates = Arabica::XPath::NodeSet<std::string>(); - } - - } - - void printNodeSet(const Arabica::XPath::NodeSet<std::string>& config) { - std::string seperator; - for (int i = 0; i < config.size(); i++) { - std::cout << seperator << ATTR_CAST(config[i], "id"); - seperator = ", "; - } - } - - void beforeCompletion(uscxml::Interpreter interpreter) { - Arabica::XPath::NodeSet<std::string> config = interpreter.getConfiguration(); - if (config.size() == 1) { - if (withFlattening) { - 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; - retCode = EXIT_SUCCESS; - return; - } - } else { - if (boost::iequals(ATTR_CAST(config[0], "id"), "pass")) { - std::cout << "TEST SUCCEEDED" << std::endl; - retCode = EXIT_SUCCESS; - return; - } - } - } - std::cout << "TEST FAILED" << std::endl; - } - - Arabica::XPath::NodeSet<std::string> exitingStates; - Arabica::XPath::NodeSet<std::string> enteringStates; + std::cout << "TEST FAILED" << std::endl; +} }; int main(int argc, char** argv) { @@ -143,7 +85,7 @@ int main(int argc, char** argv) { } else { interpreter = Interpreter::fromURL(documentURI); } - + if (delayFactor != 1) { Arabica::DOM::Document<std::string> document = interpreter.getDocument(); Arabica::DOM::Element<std::string> root = document.getDocumentElement(); diff --git a/test/w3c/analyze_tests.pl b/test/w3c/analyze_tests.pl index 2525008..111db5a 100755 --- a/test/w3c/analyze_tests.pl +++ b/test/w3c/analyze_tests.pl @@ -42,7 +42,7 @@ $/ = '-' x 58 . "\n"; while ($block = <FILE>) { chomp($block); - + # Test Preambel ======== if ($block =~ / @@ -83,6 +83,37 @@ while ($block = <FILE>) { # next; - no next as this is part of the actual test output we need to scan below } + # Minimization ======== + # print $block; + + if ($block =~ + / + Number\sof\selements\sbefore\sreduction:\s(\d+) + /x ) { + $test->{$currTest}->{'min'}->{'before'} = $1; + if ($block =~ + / + Number\sof\selements\safter\sreduction:\s(\d+) + /x ) { + $test->{$currTest}->{'min'}->{'after'} = $1; + } + } + + # Flattening ======== + + if ($block =~ + / + Number\sof\selements\sbefore\sflattening:\s(\d+) + /x ) { + $test->{$currTest}->{'flat'}->{'before'} = $1; + if ($block =~ + / + Number\sof\selements\safter\sflattening:\s(\d+) + /x ) { + $test->{$currTest}->{'flat'}->{'after'} = $1; + } + } + # Promela Test ======== if ($block =~ / diff --git a/test/w3c/run_minimized_flat_test.cmake b/test/w3c/run_minimized_flat_test.cmake new file mode 100644 index 0000000..81f9114 --- /dev/null +++ b/test/w3c/run_minimized_flat_test.cmake @@ -0,0 +1,21 @@ +# minimize SCXML document and run + +get_filename_component(TEST_FILE_NAME ${TESTFILE} NAME) + +set(ENV{USCXML_MINIMIZE_WAIT_FOR_COMPLETION} "TRUE") +set(ENV{USCXML_MINIMIZE_RETAIN_AS_COMMENTS} "TRUE") + +execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -tflat -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.flat.scxml RESULT_VARIABLE CMD_RESULT) +if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}") +endif() + +execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -tmin -i ${OUTDIR}/${TEST_FILE_NAME}.flat.scxml -o ${OUTDIR}/${TEST_FILE_NAME}.flat.min.scxml RESULT_VARIABLE CMD_RESULT) +if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}") +endif() + +execute_process(COMMAND ${USCXML_W3C_TEST_BIN} ${OUTDIR}/${TEST_FILE_NAME}.flat.min.scxml RESULT_VARIABLE CMD_RESULT) +if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_W3C_TEST_BIN}") +endif() diff --git a/test/w3c/run_minimized_test.cmake b/test/w3c/run_minimized_test.cmake new file mode 100644 index 0000000..481c0e9 --- /dev/null +++ b/test/w3c/run_minimized_test.cmake @@ -0,0 +1,16 @@ +# minimize SCXML document and run + +get_filename_component(TEST_FILE_NAME ${TESTFILE} NAME) + +set(ENV{USCXML_MINIMIZE_WAIT_FOR_COMPLETION} "TRUE") +set(ENV{USCXML_MINIMIZE_RETAIN_AS_COMMENTS} "TRUE") + +execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -tmin -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.min.scxml RESULT_VARIABLE CMD_RESULT) +if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}") +endif() + +execute_process(COMMAND ${USCXML_W3C_TEST_BIN} ${OUTDIR}/${TEST_FILE_NAME}.min.scxml RESULT_VARIABLE CMD_RESULT) +if(CMD_RESULT) + message(FATAL_ERROR "Error running ${USCXML_W3C_TEST_BIN}") +endif() diff --git a/test/w3c/run_promela_test.cmake b/test/w3c/run_promela_test.cmake index 179cd68..e19148f 100644 --- a/test/w3c/run_promela_test.cmake +++ b/test/w3c/run_promela_test.cmake @@ -1,23 +1,27 @@ # convert given file to promela and run spin get_filename_component(TEST_FILE_NAME ${TESTFILE} NAME) +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTDIR}) execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.pml RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}: ${CMD_RESULT}") endif() -execute_process(COMMAND ${SPIN_BIN} -a ${OUTDIR}/${TEST_FILE_NAME}.pml RESULT_VARIABLE CMD_RESULT) +execute_process(COMMAND ${SPIN_BIN} -a ${OUTDIR}/${TEST_FILE_NAME}.pml WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) - message(FATAL_ERROR "Error running ${SPIN_BIN}: ${CMD_RESULT}") + message(FATAL_ERROR "Error running spin ${SPIN_BIN}: ${CMD_RESULT}") endif() -execute_process(COMMAND ${GCC_BIN} -DMEMLIM=1024 -DVECTORSZ=2048 -O2 -DXUSAFE -w -o ${OUTDIR}/pan ${OUTDIR}/pan.c RESULT_VARIABLE CMD_RESULT) +execute_process(COMMAND ${GCC_BIN} -DMEMLIM=1024 -DVECTORSZ=8192 -O2 -DXUSAFE -w -o ${OUTDIR}/pan ${OUTDIR}/pan.c WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) - message(FATAL_ERROR "Error running ${GCC_BIN}: ${CMD_RESULT}") + message(FATAL_ERROR "Error running gcc ${GCC_BIN}: ${CMD_RESULT}") endif() -execute_process(COMMAND ${OUTDIR}/pan -m10000 -a RESULT_VARIABLE CMD_RESULT) +execute_process(COMMAND ${OUTDIR}/pan -m10000 -a WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) message(FATAL_ERROR "Error running pan: ${CMD_RESULT}") endif() +# +# message(STATUS "${TEST_OUT}") +# file(WRITE ${OUTDIR}/${TEST_FILE_NAME}.pml.out ${TEST_OUT})
\ No newline at end of file |