Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJuergen Haug2019-06-25 11:25:22 -0400
committerHenrik Rentz-Reichert2019-08-09 09:18:06 -0400
commit39770a85b966fb491193f45da4d743724b248c71 (patch)
treea300c2c1f2c374de44d8f8048111cb1bb8f35ced /tests
parent733680d60939f3ae14c23d01a7e91a4343106517 (diff)
downloadorg.eclipse.etrice-39770a85b966fb491193f45da4d743724b248c71.tar.gz
org.eclipse.etrice-39770a85b966fb491193f45da4d743724b248c71.tar.xz
org.eclipse.etrice-39770a85b966fb491193f45da4d743724b248c71.zip
Bug 541775 - [generator.fsm] State machine without initial transition
causes null pointer exception in generator * added test * fixed NPE * added validation on genmodel level Change-Id: Ib4f66e88ad995a7a1178312e5a39873bfaf37544
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room2
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java28
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/build.gradle2
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room24
4 files changed, 41 insertions, 15 deletions
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room b/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
index 33cae1ad3..12c179f65 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
@@ -9,7 +9,6 @@ RoomModel Reachability {
ActorRef testee2: Testee_ac
LogicalThread dflt_thread
}
-
ActorClass Testee_Super_ac {
Structure {
Port p: ReachabilityProtocol
@@ -173,6 +172,7 @@ RoomModel Reachability {
<in2: p>
}
}
+ Transition init: initial -> state0_1
ChoicePoint cp0_1
EntryPoint tp0_1
ExitPoint tp1_1
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
index 83d3da384..22af53082 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
@@ -63,19 +63,21 @@ public class TestReachability extends TestBase {
}
List<AbstractValidationDiagnostic> diagnostics = getIssueCode2diagnostic().get(ReachabilityValidator.DIAG_CODE_UNREACHABLE);
- for (AbstractValidationDiagnostic d : diagnostics) {
- if (d instanceof FeatureBasedDiagnostic) {
- FeatureBasedDiagnostic dx = (FeatureBasedDiagnostic) d;
- StateGraph graph = (StateGraph) dx.getSourceEObject();
- Object feature = graph.eGet(dx.getFeature());
- if (feature instanceof EList) {
- EList<?> list = (EList<?>) feature;
- Object source = list.get(dx.getIndex());
- if (source instanceof StateGraphItem) {
- checkUnreachable((StateGraphItem) source);
- items.remove(source);
- } else
- Assert.fail("unexpected test item:" + source);
+ if (diagnostics!=null) {
+ for (AbstractValidationDiagnostic d : diagnostics) {
+ if (d instanceof FeatureBasedDiagnostic) {
+ FeatureBasedDiagnostic dx = (FeatureBasedDiagnostic) d;
+ StateGraph graph = (StateGraph) dx.getSourceEObject();
+ Object feature = graph.eGet(dx.getFeature());
+ if (feature instanceof EList) {
+ EList<?> list = (EList<?>) feature;
+ Object source = list.get(dx.getIndex());
+ if (source instanceof StateGraphItem) {
+ checkUnreachable((StateGraphItem) source);
+ items.remove(source);
+ } else
+ Assert.fail("unexpected test item:" + source);
+ }
}
}
}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/build.gradle b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
index 8996edebe..69e2ae560 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/build.gradle
+++ b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
@@ -24,7 +24,7 @@ def tests = [
choicePointTestExtended: ['models/ChoicePointTestExtended.room', genericPhysical],
dataDrivenTest: ['models/DataDrivenTest.room', genericPhysical],
/* enumTest: ['models/EnumTest.room', genericPhysical], not supported in c++ */
- compileTest: ['models/CompileTest.room', genericPhysical, 'models/StatemachineInterfaceTest.room', 'models/StatemachineInterfaceInheritedTest.room', 'models/StatemachineInterfaceTest.room', 'models/ContinuationTransitionTest.room'],
+ compileTest: ['models/CompileTest.room', genericPhysical, 'models/StatemachineInterfaceTest.room', 'models/StatemachineInterfaceInheritedTest.room', 'models/StatemachineInterfaceTest.room', 'models/ContinuationTransitionTest.room', 'models/Bug541775_NoInitialTransition.room'],
handlerTest: ['models/HandlerTest.room', genericPhysical],
operationInheritanceTest: ['models/OperationInheritanceTest.room', genericPhysical],
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room b/tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room
new file mode 100644
index 000000000..cdeb83a8d
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/Bug541775_NoInitialTransition.room
@@ -0,0 +1,24 @@
+RoomModel Bug541775_NoInitialTransition {
+
+ ProtocolClass PDummy {
+ incoming {
+ Message in1
+ }
+ }
+
+ abstract ActorClass ANoInitialTransition {
+ Structure {
+ Port p1: PDummy
+ }
+ Behavior {
+ StateMachine {
+ handler TransitionPoint tr0
+ Transition tr1: my tr0 -> my tr0 {
+ triggers {
+ <in1: p1>
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file

Back to the top