diff options
author | Stefan Radomski <sradomski@mintwerk.de> | 2015-07-05 23:15:31 (GMT) |
---|---|---|
committer | Stefan Radomski <sradomski@mintwerk.de> | 2015-07-05 23:15:31 (GMT) |
commit | f02d7e5919f16d8396839fcff1e0588d6ccf3004 (patch) | |
tree | ae16a349655763856d1286c017c5f29c916d6cd5 /test | |
parent | 1bc525a7992f560735bb7e0de6981e8e6f616246 (diff) | |
download | uscxml-f02d7e5919f16d8396839fcff1e0588d6ccf3004.zip uscxml-f02d7e5919f16d8396839fcff1e0588d6ccf3004.tar.gz uscxml-f02d7e5919f16d8396839fcff1e0588d6ccf3004.tar.bz2 |
Various extensions and bug-fixes
Diffstat (limited to 'test')
-rw-r--r-- | test/src/test-issue-reporting.cpp | 231 | ||||
-rwxr-xr-x | test/w3c/analyze_tests.pl | 53 | ||||
-rw-r--r-- | test/w3c/run_promela_test.cmake | 18 |
3 files changed, 282 insertions, 20 deletions
diff --git a/test/src/test-issue-reporting.cpp b/test/src/test-issue-reporting.cpp index 98c2a21..e93ba58 100644 --- a/test/src/test-issue-reporting.cpp +++ b/test/src/test-issue-reporting.cpp @@ -6,7 +6,12 @@ using namespace uscxml; std::set<std::string> issueLocationsForXML(const std::string xml) { Interpreter interpreter = Interpreter::fromXML(xml, ""); - std::list<InterpreterIssue> issues = interpreter.validate(); + + // common xmlns and version requirement on scxml attribute + interpreter.getDocument().getDocumentElement().setAttribute("xmlns", "http://www.w3.org/2005/07/scxml"); + interpreter.getDocument().getDocumentElement().setAttribute("version", "1.0"); + + std::list<InterpreterIssue> issues = interpreter.validate(); std::set<std::string> issueLocations; @@ -61,7 +66,7 @@ int main(int argc, char** argv) { } if (1) { - // Unreachable states + // Unreachable states 1 const char* xml = "<scxml datamodel=\"ecmascript\">" @@ -82,7 +87,6 @@ int main(int argc, char** argv) { if (1) { // Invalid parents - const char* xml = "<scxml datamodel=\"ecmascript\">" " <onentry>" @@ -97,6 +101,7 @@ int main(int argc, char** argv) { if (1) { // State has no 'id' attribute + // *** This is not actually an error! *** const char* xml = "<scxml datamodel=\"ecmascript\">" " <state>" @@ -137,7 +142,108 @@ int main(int argc, char** argv) { assert(issueLocations.size() == 1); } - + if (1) { + // Useless history 1 + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"bar\">" + " <history id=\"bar\" />" + " <state id=\"baz\" />" + " <transition event=\"e.foo\" target=\"done\" />" + " <transition event=\"e.bar\" target=\"baz\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//history[@id=\"bar\"]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // Useless history 2 + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"bar\">" + " <history id=\"bar\">" + " <transition target=\"foo\" />" + " </history>" + " <transition target=\"done\" />" + " <state id=\"foo\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//history[@id=\"bar\"]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // No legal completion + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"foo bar\">" + " <state id=\"foo\" />" + " <state id=\"bar\" />" + " <transition target=\"foo bar\" />" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); + assert(issueLocations.find("//state[@id=\"start\"]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 2); + } + + if (1) { + // attribute constraints + + { + // initial attribute and <initial> child + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"foo\">" + " <initial></initial>" + " <state id=\"foo\" />" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + { + // initial attribute with atomic state + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + { + // initial child with atomic state + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial />" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); + assert(issueLocations.size() == 1); + + } + } + + if (1) { // Transition can never be optimally enabled (conditionless, eventless) @@ -185,21 +291,120 @@ int main(int argc, char** argv) { assert(issueLocations.size() == 1); } - if (1) { - // Invoke with unknown type + if (1) { + // Initial attribute with target outside of children + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"foo done\">" + " <state id=\"foo\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // Initial transition with target outside of children + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial>" + " <transition target=\"foo done\" />" + " </initial>" + " <state id=\"foo\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // Initial history transition with target outside of children + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"bar\">" + " <history id=\"bar\">" + " <transition target=\"foo done\" />" + " </history>" + " <state id=\"foo\">" + " <transition target=\"baz\" />" + " </state>" + " <state id=\"baz\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // Initial transition with target outside of children + + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial>" + " <transition target=\"foo done\" />" + " </initial>" + " <state id=\"foo\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } - const char* xml = - "<scxml datamodel=\"ecmascript\">" - " <state id=\"start\">" - " <invoke type=\"non-existant\" />" - " </state>" - "</scxml>"; + if (1) { + // Initial transition with event + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial>" + " <transition event=\"e.foo\" target=\"foo\" />" + " </initial>" + " <state id=\"foo\" />" + " <transition event=\"e.bar\" target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; std::set<std::string> issueLocations = issueLocationsForXML(xml); - assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end()); + assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end()); assert(issueLocations.size() == 1); } + if (1) { + // Initial transition with condition + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial>" + " <transition cond=\"true\" target=\"foo\" />" + " </initial>" + " <state id=\"foo\" />" + " <transition event=\"e.bar\" target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/initial[1]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + if (1) { // Send to unknown IO Processor diff --git a/test/w3c/analyze_tests.pl b/test/w3c/analyze_tests.pl index a14c129..b891066 100755 --- a/test/w3c/analyze_tests.pl +++ b/test/w3c/analyze_tests.pl @@ -30,6 +30,8 @@ if (!$testResultFile) { $testResultFile = File::Spec->catfile($toBaseDir, "../../build/cli/Testing/Temporary/LastTest.log"); } +print STDERR "Using log file from:\n\t$testResultFile\n"; + open(FILE, $testResultFile) or die $!; mkdir($outDir) or die($!) if (! -d $outDir); @@ -78,8 +80,8 @@ while ($block = <FILE>) { \<end\sof\soutput\>\n Test\stime\s\=\s+([\d\.]+)\s(\w+) /x ) { - $test->{$currTest}->{'duration'} = $1; - $test->{$currTest}->{'durationUnit'} = $2; + $test->{$currTest}->{'duration'}->{'total'} = $1; + $test->{$currTest}->{'duration'}->{'totalUnit'} = $2; # next; - no next as this is part of the actual test output we need to scan below } @@ -174,6 +176,53 @@ while ($block = <FILE>) { $test->{$currTest}->{'pml'}->{'memory'}->{'total'} = $7; } + if ($block =~ + / + pan:\selapsed\stime\s(.*)\sseconds\n + /x ) { + $test->{$currTest}->{'pml'}->{'duration'} = $1; + } + + if ($block =~ + / + real\s+([\d\.]+)\n + user\s+([\d\.]+)\n + sys\s+([\d\.]+)\n + --\stime\sfor\stransforming\sto\spromela\n + /x ) { + $test->{$currTest}->{'duration'}->{'toPML'} = $1; + } + + if ($block =~ + / + real\s+([\d\.]+)\n + user\s+([\d\.]+)\n + sys\s+([\d\.]+)\n + --\stime\sfor\stransforming\sto\sc\n + /x ) { + $test->{$currTest}->{'duration'}->{'toC'} = $1; + } + + if ($block =~ + / + real\s+([\d\.]+)\n + user\s+([\d\.]+)\n + sys\s+([\d\.]+)\n + --\stime\sfor\stransforming\sto\sbinary\n + /x ) { + $test->{$currTest}->{'duration'}->{'toBin'} = $1; + } + + if ($block =~ + / + real\s+([\d\.]+)\n + user\s+([\d\.]+)\n + sys\s+([\d\.]+)\n + --\stime\sfor\sverification\n + /x ) { + $test->{$currTest}->{'duration'}->{'toVerif'} = $1; + } + next; } diff --git a/test/w3c/run_promela_test.cmake b/test/w3c/run_promela_test.cmake index e6d2418..b403b7a 100644 --- a/test/w3c/run_promela_test.cmake +++ b/test/w3c/run_promela_test.cmake @@ -6,25 +6,33 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTDIR}) set(ENV{USCXML_PROMELA_TRANSITION_TRACE} "TRUE") set(ENV{USCXML_PROMELA_TRANSITION_DEBUG} "TRUE") -execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -tpml -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.pml RESULT_VARIABLE CMD_RESULT) +message(STATUS "${USCXML_TRANSFORM_BIN} -tpml -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.pml") +execute_process(COMMAND time -p ${USCXML_TRANSFORM_BIN} -tpml -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() +message(STATUS "time for transforming to promela") -execute_process(COMMAND ${SPIN_BIN} -a ${OUTDIR}/${TEST_FILE_NAME}.pml WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) +message(STATUS "${SPIN_BIN} -a ${OUTDIR}/${TEST_FILE_NAME}.pml") +execute_process(COMMAND time -p ${SPIN_BIN} -a ${OUTDIR}/${TEST_FILE_NAME}.pml WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) message(FATAL_ERROR "Error running spin ${SPIN_BIN}: ${CMD_RESULT}") endif() +message(STATUS "time for transforming to c") -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) +message(STATUS "${GCC_BIN} -DMEMLIM=1024 -DVECTORSZ=8192 -O2 -DXUSAFE -w -o ${OUTDIR}/pan ${OUTDIR}/pan.c") +execute_process(COMMAND time -p ${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 ${GCC_BIN}: ${CMD_RESULT}") endif() +message(STATUS "time for transforming to binary") -execute_process(COMMAND ${OUTDIR}/pan -m10000 -a WORKING_DIRECTORY ${OUTDIR} RESULT_VARIABLE CMD_RESULT) +message(STATUS "${OUTDIR}/pan -m10000 -a") +execute_process(COMMAND time -p ${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 "time for verification") + # message(STATUS "${TEST_OUT}") # file(WRITE ${OUTDIR}/${TEST_FILE_NAME}.pml.out ${TEST_OUT})
\ No newline at end of file |