diff options
author | Stefan Radomski <sradomski@mintwerk.de> | 2016-01-18 14:07:16 (GMT) |
---|---|---|
committer | Stefan Radomski <sradomski@mintwerk.de> | 2016-01-18 14:07:16 (GMT) |
commit | 6e96eafb9bf087c35cfe8e60196d0a2a1698d22b (patch) | |
tree | 9b1fe7e7abcae365d11d24d7494d1a00f40b9eaa /test | |
parent | 575c2711df910f0b8ecce277bf7333077e235855 (diff) | |
download | uscxml-6e96eafb9bf087c35cfe8e60196d0a2a1698d22b.zip uscxml-6e96eafb9bf087c35cfe8e60196d0a2a1698d22b.tar.gz uscxml-6e96eafb9bf087c35cfe8e60196d0a2a1698d22b.tar.bz2 |
Fixed a memory leak in transformed C scaffolding
Diffstat (limited to 'test')
-rw-r--r-- | test/src/test-c-machine.cpp | 20 | ||||
-rwxr-xr-x | test/w3c/check-tests.pl | 23 |
2 files changed, 32 insertions, 11 deletions
diff --git a/test/src/test-c-machine.cpp b/test/src/test-c-machine.cpp index 35f06a4..33c149a 100644 --- a/test/src/test-c-machine.cpp +++ b/test/src/test-c-machine.cpp @@ -127,7 +127,7 @@ int matches(const char* desc, const char* event) { int exec_content_raise(const scxml_ctx* ctx, const char* event) { Event* e = new Event(); - e->name = strdup(event); + e->name = event; if (boost::starts_with(e->name, "error.")) { e->eventType = Event::PLATFORM; @@ -216,8 +216,10 @@ int raise_done_event(const scxml_ctx* ctx, const scxml_state* state, const scxml void delayedSend(void* ctx, std::string eventName) { tthread::lock_guard<tthread::mutex> lock(USER_DATA(ctx)->mutex); - SendRequest* e = USER_DATA(ctx)->sendIds[eventName]; - if (e->target == "#_internal") { + SendRequest* sr = USER_DATA(ctx)->sendIds[eventName]; + Event* e = new Event(*sr); + + if (sr->target == "#_internal") { e->eventType = Event::INTERNAL; #ifdef SCXML_VERBOSE printf("Pushing Internal Event: %s\n", e->name.c_str()); @@ -231,6 +233,7 @@ void delayedSend(void* ctx, std::string eventName) { USER_DATA(ctx)->eq.push_back(e); } USER_DATA(ctx)->monitor.notify_all(); + delete sr; } int exec_content_cancel(const scxml_ctx* ctx, const char* sendid, const char* sendidexpr) { @@ -300,8 +303,9 @@ int exec_content_send(const scxml_ctx* ctx, const scxml_elem_send* send) { } else { e->type = "http://www.w3.org/TR/scxml/#SCXMLEventProcessor"; } - } catch (Event e) { - exec_content_raise(ctx, e.name.c_str()); + } catch (Event exc) { + exec_content_raise(ctx, exc.name.c_str()); + delete e; return SCXML_ERR_EXEC_CONTENT; } @@ -317,7 +321,7 @@ int exec_content_send(const scxml_ctx* ctx, const scxml_elem_send* send) { if (send->eventexpr != NULL) { e->name = USER_DATA(ctx)->datamodel.evalAsString(send->eventexpr); } else { - e->name = strdup(send->event); + e->name = send->event; } try { @@ -367,12 +371,12 @@ int exec_content_send(const scxml_ctx* ctx, const scxml_elem_send* send) { } } - const char* sendid = NULL; + std::string sendid; if (send->id != NULL) { sendid = send->id; e->sendid = sendid; } else { - sendid = strdup(UUID::getUUID().c_str()); + sendid = UUID::getUUID(); if (send->idlocation != NULL) { USER_DATA(ctx)->datamodel.assign(send->idlocation, Data(sendid, Data::VERBATIM)); } else { diff --git a/test/w3c/check-tests.pl b/test/w3c/check-tests.pl index 7299947..71218f4 100755 --- a/test/w3c/check-tests.pl +++ b/test/w3c/check-tests.pl @@ -4,6 +4,13 @@ use strict; use Data::Dumper; use XML::Simple; +my @failed; +# failing for C transformation +# @failed = qw/ +# 187 191 192 207 215 216 220 223 224 225 226 228 229 230 232 233 234 235 +# 236 237 239 240 241 242 243 244 245 247 250 252 253 276 338 347 422 530 +# 554 201 496 500 501 509 510 518 519 520 521 522 531 532 534 567 569 577 +# 301 307 446 552 557 558 561/; my $manifest = XMLin("./manifest.xml"); # print Dumper($manifest->{'assert'}); @@ -17,7 +24,7 @@ my @agnosticTests; my @nullTests; my @manualTests; -for my $testNr (keys $manifest->{'assert'}) { +TESTS: for my $testNr (keys $manifest->{'assert'}) { my @tests; my $thisTest = $manifest->{'assert'}->{$testNr}; if (ref($thisTest->{'test'}->{'start'}) eq "ARRAY") { @@ -25,7 +32,17 @@ for my $testNr (keys $manifest->{'assert'}) { } else { push (@tests, $thisTest->{'test'}->{'start'}); } + for my $t (@tests) { + if ($t->{'uri'} =~ /\/test(.*)\.[txml|txt]/) { + next TESTS if ( grep /^$1$/, @failed ); + $perSpecId->{$thisTest->{'specnum'}.':'.$thisTest->{'specid'}}->{'tests'} .= $1." "; + } else { + die(Dumper($t)); + } + } + $perSpecId->{$thisTest->{'specnum'}.':'.$thisTest->{'specid'}}->{'total'} += @tests; + if ($thisTest->{'test'}->{'manual'} eq "true") { $perSpecId->{$thisTest->{'specnum'}.':'.$thisTest->{'specid'}}->{'manual'} += @tests; push @manualTests, @tests; @@ -43,7 +60,7 @@ for my $testNr (keys $manifest->{'assert'}) { if ($thisTest->{'specid'} eq "#xpath-profile" || $thisTest->{'specid'} !~ /profile$/) { push @xpathTests, @tests; } - + push (@allTests, @tests); push @agnosticTests, @tests if ($thisTest->{'specid'} !~ /profile$/); } @@ -81,7 +98,7 @@ for my $datamodel (keys %datamodels) { } } -# print Dumper(@manualTests); +print Dumper($perSpecId); print "NULL : ".@nullTests."\n"; print "ECMA : ".@ecmaTests."\n"; |