summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-12-19 08:27:30 (EST)
committer Juergen Haug2012-12-19 08:27:30 (EST)
commit46ed5e424ec9adb3b915e421894970db0ac93046 (patch)
treeb090c557bf94c962f98642697f3e6a1ab89bec8b
parent5ea296dc49f44f20c97bf396b9939f77d735f5e0 (diff)
downloadorg.eclipse.etrice-46ed5e424ec9adb3b915e421894970db0ac93046.zip
org.eclipse.etrice-46ed5e424ec9adb3b915e421894970db0ac93046.tar.gz
org.eclipse.etrice-46ed5e424ec9adb3b915e421894970db0ac93046.tar.bz2
[abstractexec] added reachability testsrefs/changes/02/9302/1
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java201
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java3
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room302
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/org.eclipse.etrice.abstractexec.behavior.tests.launch2
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestBase.java62
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java102
6 files changed, 552 insertions, 120 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java
index 4a1e452..4e282a5 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityCheck.java
@@ -11,133 +11,124 @@
*
*******************************************************************************/
-
package org.eclipse.etrice.abstractexec.behavior;
import java.util.*;
-
import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.genmodel.etricegen.ActiveTrigger;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.room.*;
import org.eclipse.etrice.core.room.util.RoomHelpers;
-import org.eclipse.etrice.generator.base.DefaultTranslationProvider;
-import org.eclipse.etrice.generator.base.DetailCodeTranslator;
-
public class ReachabilityCheck {
-Queue<StateGraphNode> queue;
-public Set<StateGraphItem> visited;
-private ExpandedActorClass xpAct;
-private Set<StateGraphItem> exitUsed;
-public ReachabilityCheck (ExpandedActorClass xpac) {
- queue= new LinkedList<StateGraphNode>();
- xpAct = xpac;
- visited = new HashSet<StateGraphItem>();
- exitUsed = new HashSet<StateGraphItem>();
-}
-public void computeReachability() {
- StateGraph graph = xpAct.getStateMachine();
- addStartingPoints(graph, true);
- doTraversal();
-}
+ Queue<StateGraphNode> queue;
+ public Set<StateGraphItem> visited;
+ private ExpandedActorClass xpAct;
+ private Set<StateGraphItem> exitUsed;
-private void addStartingPoints(StateGraph graph, boolean add_initial)
-{
-
- EList<Transition> transitions = graph.getTransitions();
- EList<TrPoint> trPoint = graph.getTrPoints();
- if(add_initial)
- for(Transition trans : transitions)
- if(trans instanceof InitialTransition)
- {
- visited.add(trans);
- StateGraphNode cur = xpAct.getNode(trans.getTo());
- if(!visited.contains(cur)) queue.add(cur);
- break;
- }
- for(TrPoint tp : trPoint)
- {
- if(tp instanceof TransitionPoint && !visited.contains(tp) ) {
- queue.add(tp);
- }
+ public ReachabilityCheck(ExpandedActorClass xpac) {
+ queue = new LinkedList<StateGraphNode>();
+ xpAct = xpac;
+ visited = new HashSet<StateGraphItem>();
+ exitUsed = new HashSet<StateGraphItem>();
}
-
- //add transition points
-}
-private void doTraversal() {
- while(!queue.isEmpty())
- {
- StateGraphNode node = queue.poll();
- Visit(node);
- //System.out.println("Visited node : " + node.getName());
+
+ public void computeReachability() {
+ StateGraph graph = xpAct.getStateMachine();
+ addStartingPoints(graph, true);
+ doTraversal();
}
-}
-public boolean isExitUsed(StateGraphItem item)
-{
- return exitUsed.contains(item);
-}
-public boolean isReachable(StateGraphItem item)
-{
-
- return visited.contains(item);
-}
-private void Visit(StateGraphNode node)
-{
- visited.add(node);
- if(node instanceof State)
- {
- State st = (State) node;
- if(RoomHelpers.hasDirectSubStructure(st))
- {
- addStartingPoints(st.getSubgraph(),true);
- }
- else
- {
- for(ActiveTrigger trigger : xpAct.getActiveTriggers(st))
- {
- for(Transition trans : trigger.getTransitions())
- {
+
+ private void addStartingPoints(StateGraph graph, boolean add_initial) {
+
+ EList<Transition> transitions = graph.getTransitions();
+ EList<TrPoint> trPoint = graph.getTrPoints();
+ if (add_initial)
+ for (Transition trans : transitions)
+ if (trans instanceof InitialTransition) {
visited.add(trans);
- StateGraphNode target = xpAct.getNode(trans.getTo());
- if(!visited.contains(target)) {
- queue.add(target);
- StateGraph triggerContext = (StateGraph) trans.eContainer();
- State exitCalled = st;
- while(true)
- {
- exitUsed.add(exitCalled);
- if(exitCalled.eContainer()==triggerContext) break;
- exitCalled = (State) exitCalled.eContainer().eContainer();
- }
- }
+ StateGraphNode cur = xpAct.getNode(trans.getTo());
+ if (!visited.contains(cur))
+ queue.add(cur);
+ break;
}
+ for (TrPoint tp : trPoint) {
+ if (tp instanceof TransitionPoint && !visited.contains(tp)) {
+ queue.add(tp);
}
}
+
+ // add transition points
}
- else {
- if(node instanceof EntryPoint)
- {
- State container = (State) node.eContainer().eContainer();
- visited.add(container);
+
+ private void doTraversal() {
+ while (!queue.isEmpty()) {
+ StateGraphNode node = queue.poll();
+ if (!visited.contains(node))
+ Visit(node);
+ // System.out.println("Visited node : " + node.getName());
}
- for(Transition trans : xpAct.getOutgoingTransitions(node))
- {
- visited.add(trans);
- StateGraphNode target = xpAct.getNode(trans.getTo());
- if(!visited.contains(target))
- {
- queue.add(target);
-
+ }
+
+ public boolean isExitUsed(StateGraphItem item) {
+ return exitUsed.contains(item);
+ }
+
+ public boolean isReachable(StateGraphItem item) {
+
+ return visited.contains(item);
+ }
+
+ private void Visit(StateGraphNode node) {
+ visited.add(node);
+ if (node instanceof State) {
+ State st = (State) node;
+ if (RoomHelpers.hasDirectSubStructure(st)) {
+ addStartingPoints(st.getSubgraph(), true);
+ } else {
+ for (ActiveTrigger trigger : xpAct.getActiveTriggers(st)) {
+ for (Transition trans : trigger.getTransitions()) {
+ visited.add(trans);
+ StateGraphNode target = xpAct.getNode(trans.getTo());
+ if (!visited.contains(target)) {
+ queue.add(target);
+ StateGraph triggerContext = (StateGraph) trans
+ .eContainer();
+ State exitCalled = st;
+ while (true) {
+ exitUsed.add(exitCalled);
+ if (exitCalled.eContainer() == triggerContext)
+ break;
+ exitCalled = (State) exitCalled.eContainer()
+ .eContainer();
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (node instanceof EntryPoint) {
+ // if container has no initial transition then mark it visited
+ boolean markVisited = true;
+ State container = (State) node.eContainer().eContainer();
+ StateGraph parentGraph = container.getSubgraph();
+ for (Transition tr : parentGraph.getTransitions())
+ if (tr instanceof InitialTransition)
+ markVisited = false;
+ if (markVisited)
+ visited.add(container);
+ }
+ for (Transition trans : xpAct.getOutgoingTransitions(node)) {
+ visited.add(trans);
+ StateGraphNode target = xpAct.getNode(trans.getTo());
+ if (!visited.contains(target)) {
+ queue.add(target);
+
+ }
}
}
- }
-
-}
+ }
}
-
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java
index 406ecf6..c4774b5 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java
@@ -29,6 +29,7 @@ import org.eclipse.xtext.validation.ValidationMessageAcceptor;
public class ReachabilityValidator implements IRoomValidator {
+ public static String DIAG_CODE_UNREACHABLE = "etrice.unreachable";
@Override
public void validate(EObject object, ValidationMessageAcceptor messageAcceptor) {
@@ -63,7 +64,7 @@ public class ReachabilityValidator implements IRoomValidator {
messageAcceptor.acceptWarning(
"Unreachable state/point of graph",
xpac.getOrig(toCheck).eContainer(), xpac.getOrig(toCheck).eContainingFeature(), idx,
- "UNREACHABLE", toCheck.getName());
+ DIAG_CODE_UNREACHABLE, toCheck.getName());
}
}
}
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room b/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
new file mode 100644
index 0000000..59ef73c
--- /dev/null
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/models/reachability.room
@@ -0,0 +1,302 @@
+RoomModel Reachability {
+
+ LogicalSystem System_Reachability {
+ SubSystemRef subSystem: SubSystem
+ }
+
+ SubSystemClass SubSystem {
+ ActorRef testee1: Testee_Super_ac
+ ActorRef testee2: Testee_ac
+ LogicalThread dflt_thread
+ }
+
+ ActorClass Testee_Super_ac {
+ Structure {
+ Port p: ReachabilityProtocol
+ }
+ Behavior {
+ StateMachine {
+ Transition tr0_1: state01_1 -> tp0_1 of state0_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr2_1: state02_1 -> tp1_1 of state0_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr3_0: state03_0 -> tp2_0 of state0_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr0_0: tp7_0 of state0_1 -> state04_0
+ Transition tr01_1: tp3_1 of state0_1 -> state07_1
+ Transition tr02_1: tp5_1 of state0_1 -> state08_1
+ Transition tr03_1: tp4_1 of state0_1 -> state09_1
+ Transition init: initial -> state_1 { }
+ Transition tr_1: state_1 -> stateA_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr0a_1: stateA_1 -> state01_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr0b_1: stateA_1 -> state02_1 {
+ triggers {
+ <in2: p>
+ }
+ }
+ Transition tr11_1: state_1 -> state1_1 {
+ triggers {
+ <in2: p>
+ }
+ }
+ Transition trC_0: state_0 -> state2_0 {
+ triggers {
+ <in2: p>
+ }
+ }
+ Transition tr20_1: state_1 -> tp0_1 of state2_0 {
+ triggers {
+ <in3: p>
+ }
+ }
+ Transition tr20_0: tp0_0 of state2_0 -> state20_0
+ Transition tr21_0: state2_0 -> state21_0 {
+ triggers {
+ <in3: p>
+ }
+ }
+ Transition tr22_1: tp1_1 of state2_0 -> state21_1
+ Transition trx_0: state_0 -> state03_0 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr5_0: tp8_0 of state0_1 -> state04_0
+ Transition tr6_0: tp6_0 of state0_1 -> state04_0
+ Transition tr30_1: state_1 -> state3_1 {
+ triggers {
+ <in4: p>
+ }
+ }
+ Transition tr31_0: state_0 -> tp0_0 of state3_1 {
+ triggers {
+ <in3: p>
+ }
+ }
+ Transition tr31_1: state3_1 -> state1_1 {
+ triggers {
+ <in4: p>
+ }
+ }
+ State state0_1 {
+ subgraph {
+ Transition tr0_1: my tp0_1 -> state00_1
+ Transition tr1_1: my tp1_1 -> state01_1
+ Transition tr2_0: my tp2_0 -> state03_0
+ Transition tr6_1: state00_1 -> my tp3_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr3_0: state03_0 -> my tp6_0 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr4zzz_0: state02_0 -> my tp7_0 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr5_0: state02_0 -> my tp5_1 {
+ triggers {
+ <in2: p>
+ }
+ }
+ Transition tr4_1: tp0_1 of state01_1 -> my tp4_1
+ Transition tr2_1: state01_1 -> my tp5_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr8_0: state01_1 -> my tp8_0 {
+ triggers {
+ <in2: p>
+ }
+ }
+ EntryPoint tp0_1
+ EntryPoint tp1_1
+ EntryPoint tp2_0
+ ExitPoint tp3_1
+ ExitPoint tp4_1
+ ExitPoint tp5_1
+ ExitPoint tp6_0
+ ExitPoint tp7_0
+ ExitPoint tp8_0
+ State state00_1 {
+ subgraph {
+ Transition init: initial -> state0_1 { }
+ State state0_1
+ }
+ }
+ State state01_1 {
+ subgraph {
+ Transition init: initial -> tp0_1 of state0_1 { }
+ Transition tr0_1: tp1_1 of state0_1 -> my tp0_1
+ Transition tr2_1: state0_1 -> state0_1 {
+ triggers {
+ <in2: p>
+ }
+ }
+ ExitPoint tp0_1
+ State state0_1 {
+ subgraph {
+ Transition tr0_1: my tp0_1 -> cp cp0_1
+ Transition tr3_1: cp cp0_1 -> state0_1
+ Transition tr4_1: cp cp0_1 -> state1_1 {
+ cond {
+ "true"
+ }
+ }
+ Transition tr2_1: state1_1 -> my tp1_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ Transition tr1_1: state0_1 -> my tp1_1 {
+ triggers {
+ <in2: p>
+ }
+ }
+ ChoicePoint cp0_1
+ EntryPoint tp0_1
+ ExitPoint tp1_1
+ State state0_1
+ State state1_1
+ }
+ }
+ }
+ }
+ State state03_0
+ State state02_0
+ }
+ }
+ State state01_1
+ State state02_1
+ State state03_0
+ State state04_0
+ State state07_1
+ State state08_1
+ State state09_1
+ State state_1
+ State stateA_1
+ State state1_1
+ State state_0
+ State state2_0 {
+ subgraph {
+ Transition init: initial -> state0_0 { }
+ Transition tr0_1: my tp0_1 -> state0_1
+ Transition tr1_1: state0_1 -> my tp1_1 {
+ triggers {
+ <in3: p>
+ }
+ }
+ Transition tr1_0: state0_0 -> my tp0_0 {
+ triggers {
+ <in1: p>
+ }
+ }
+ ExitPoint tp0_0
+ EntryPoint tp0_1
+ ExitPoint tp1_1
+ State state0_0
+ State state0_1
+ }
+ }
+ State state20_0
+ State state21_0
+ State state21_1
+ State state3_1 {
+ subgraph {
+ Transition init: initial -> state30_1 { }
+ Transition tr30_0: my tp0_0 -> state32_0
+ Transition tr0_1: state31_1 -> state31_1 {
+ triggers {
+ <in2: p>
+ }
+ }
+ Transition tr1_1: state30_1 -> state30_1 {
+ triggers {
+ <in4: p>
+ }
+ }
+ Transition tr2_1: state30_1 -> tp0_1 of state31_1 {
+ triggers {
+ <in1: p>
+ }
+ }
+ EntryPoint tp0_0
+ State state30_1
+ State state31_1 {
+ subgraph {
+ Transition tr0_1: my tp0_1 -> state300_1
+ Transition init: initial -> state301_1 { }
+ EntryPoint tp0_1
+ State state300_1
+ State state301_1
+ }
+ }
+ State state32_0
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass Testee_ac extends Testee_Super_ac {
+ Structure { }
+ Behavior {
+ StateMachine {
+ RefinedTransition tr4zzz_0 {
+ action {
+ ""
+ }
+ }
+ Transition tr_new_0: state_new1_0 -> state_new2_0 {
+ triggers {
+ <in1: p>
+ }
+ }
+ State state_new1_0
+ State state_new2_0
+ RefinedState state0_1 {
+ subgraph {
+ State state0_new_0
+ }
+ }
+ }
+ }
+ }
+
+ ProtocolClass ReachabilityProtocol {
+ incoming {
+ Message in1()
+ Message in2()
+ Message in3()
+ Message in4()
+ }
+ outgoing {
+ Message out1()
+ Message out2()
+ Message out3()
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/org.eclipse.etrice.abstractexec.behavior.tests.launch b/tests/org.eclipse.etrice.abstractexec.behavior.tests/org.eclipse.etrice.abstractexec.behavior.tests.launch
index 7acc659..56c6e25 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/org.eclipse.etrice.abstractexec.behavior.tests.launch
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/org.eclipse.etrice.abstractexec.behavior.tests.launch
@@ -11,6 +11,7 @@
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.etrice.abstractexec.behavior,org.eclipse.etrice.abstractexec.behavior.tests,org.eclipse.etrice.core.config,org.eclipse.etrice.core.config.tests,org.eclipse.etrice.core.config.ui,org.eclipse.etrice.core.etmap,org.eclipse.etrice.core.etmap.tests,org.eclipse.etrice.core.etmap.ui,org.eclipse.etrice.core.etphys,org.eclipse.etrice.core.etphys.tests,org.eclipse.etrice.core.etphys.ui,org.eclipse.etrice.core.genmodel,org.eclipse.etrice.core.genmodel.tests,org.eclipse.etrice.core.room,org.eclipse.etrice.core.room.tests,org.eclipse.etrice.core.room.ui,org.eclipse.etrice.doc,org.eclipse.etrice.etunit.converter,org.eclipse.etrice.etunit.converter.tests,org.eclipse.etrice.generator,org.eclipse.etrice.generator.c,org.eclipse.etrice.generator.config,org.eclipse.etrice.generator.cpp,org.eclipse.etrice.generator.doc,org.eclipse.etrice.generator.fsmtest,org.eclipse.etrice.generator.fsmtest.tests,org.eclipse.etrice.generator.fsmtest.ui,org.eclipse.etrice.generator.java,org.eclipse.etrice.generator.launch,org.eclipse.etrice.generator.launch.c,org.eclipse.etrice.generator.launch.cpp,org.eclipse.etrice.generator.launch.java,org.eclipse.etrice.generator.tests,org.eclipse.etrice.logging,org.eclipse.etrice.ui.behavior,org.eclipse.etrice.ui.behavior.tests,org.eclipse.etrice.ui.commands,org.eclipse.etrice.ui.common,org.eclipse.etrice.ui.runtime,org.eclipse.etrice.ui.structure,org.eclipse.etrice.ui.structure.tests,org.eclipse.etrice.ui.tests.base"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
@@ -34,6 +35,7 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
+<stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.google.inject@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.antlr.runtime@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.cli@default:default,org.apache.commons.lang@default:default,org.apache.commons.logging*1.1.1.v201101211721@default:default,org.apache.log4j@default:default,org.apache.lucene.analysis@default:default,org.apache.lucene.core@default:default,org.apache.lucene@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.compare@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.debug.core@default:default,org.eclipse.debug.ui@default:default,org.eclipse.draw2d@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.codegen.ecore@default:default,org.eclipse.emf.codegen@default:default,org.eclipse.emf.common.ui@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.edit@default:default,org.eclipse.emf.ecore.editor@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.emf.edit.ui@default:default,org.eclipse.emf.edit@default:default,org.eclipse.emf.mwe.core@default:default,org.eclipse.emf.mwe.utils@default:default,org.eclipse.emf.mwe2.language@default:default,org.eclipse.emf.mwe2.launch@default:default,org.eclipse.emf.mwe2.lib@default:default,org.eclipse.emf.mwe2.runtime@default:default,org.eclipse.emf.transaction@default:default,org.eclipse.emf.validation@default:default,org.eclipse.emf.workspace@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.publisher.eclipse@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security.win32.x86_64@default:false,org.eclipse.equinox.security@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.util@default:default,org.eclipse.gef@default:default,org.eclipse.graphiti.mm@default:default,org.eclipse.graphiti.ui@default:default,org.eclipse.graphiti@default:default,org.eclipse.help.base@default:default,org.eclipse.help.ui@default:default,org.eclipse.help@default:default,org.eclipse.jdt.annotation@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.jdt.core@default:default,org.eclipse.jdt.debug.ui@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.jdt.junit.core@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.jetty.continuation@default:default,org.eclipse.jetty.http@default:default,org.eclipse.jetty.io@default:default,org.eclipse.jetty.security@default:default,org.eclipse.jetty.server@default:default,org.eclipse.jetty.servlet@default:default,org.eclipse.jetty.util@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.pde.build@default:default,org.eclipse.pde.core@default:default,org.eclipse.pde.junit.runtime@default:default,org.eclipse.platform@default:default,org.eclipse.search@default:default,org.eclipse.swt.win32.win32.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.team.ui@default:default,org.eclipse.text@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.ui.console@default:default,org.eclipse.ui.editors@default:default,org.eclipse.ui.forms@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.intro@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.ui.trace@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.ui.views@default:default,org.eclipse.ui.win32@default:false,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.eclipse.update.configurator@3:true,org.eclipse.xpand@default:default,org.eclipse.xtend.lib@default:default,org.eclipse.xtend.typesystem.emf@default:default,org.eclipse.xtend@default:default,org.eclipse.xtext.builder@default:default,org.eclipse.xtext.common.types.edit@default:default,org.eclipse.xtext.common.types.ui@default:default,org.eclipse.xtext.common.types@default:default,org.eclipse.xtext.ecore@default:default,org.eclipse.xtext.generator@default:default,org.eclipse.xtext.junit4@default:default,org.eclipse.xtext.junit@default:default,org.eclipse.xtext.logging@default:false,org.eclipse.xtext.smap@default:default,org.eclipse.xtext.ui.codetemplates.ui@default:default,org.eclipse.xtext.ui.codetemplates@default:default,org.eclipse.xtext.ui.junit@default:default,org.eclipse.xtext.ui.shared@default:default,org.eclipse.xtext.ui@default:default,org.eclipse.xtext.util@default:default,org.eclipse.xtext.xbase.junit@default:default,org.eclipse.xtext.xbase.lib@default:default,org.eclipse.xtext.xbase@default:default,org.eclipse.xtext@default:default,org.hamcrest.core@default:default,org.junit*3.8.2.v3_8_2_v20100427-1100@default:default,org.junit*4.10.0.v4_10_0_v20120426-0900@default:default,org.junit4@default:default,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil*1.0.1.v200903091627@default:default,org.w3c.dom.svg@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/>
<booleanAttribute key="tracing" value="false"/>
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestBase.java b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestBase.java
index 8fca941..da9f89b 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestBase.java
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestBase.java
@@ -14,7 +14,9 @@ package org.eclipse.etrice.abstractexec.behavior.tests;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.FileLocator;
@@ -23,9 +25,11 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.validation.AbstractValidationDiagnostic;
import org.eclipse.xtext.validation.CancelableDiagnostician;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.impl.ConcreteSyntaxEValidator;
@@ -34,9 +38,9 @@ import com.google.common.collect.Maps;
/**
* Base class for tests helps with getting diagnostics from a model.
- *
+ *
* @author Henrik Rentz-Reichert initial contribution and API
- *
+ *
*/
public class TestBase {
@@ -45,22 +49,28 @@ public class TestBase {
private HashMap<String, Diagnostic> infoMsg2diagnostic = new HashMap<String, Diagnostic>();
private HashMap<String, Diagnostic> warnMsg2diagnostic = new HashMap<String, Diagnostic>();
private HashMap<String, Diagnostic> errorMsg2diagnostic = new HashMap<String, Diagnostic>();
+ private HashMap<String, List<AbstractValidationDiagnostic>> issueCode2diagnostic = new HashMap<String, List<AbstractValidationDiagnostic>>();
protected void prepare(String modelFile) {
try {
- URL modelsDir = Activator.getInstance().getBundle().getEntry("models");
+ URL modelsDir = Activator.getInstance().getBundle()
+ .getEntry("models");
URL fileURL = FileLocator.toFileURL(modelsDir);
basePath = fileURL.getFile();
} catch (IOException e) {
e.printStackTrace();
}
-
+
resource = getResource(modelFile);
Diagnostic diag = getDiag(resource.getContents().get(0));
createMappedDiagnostics(diag);
}
+ protected RoomModel getRoomModel() {
+ return (RoomModel) resource.getContents().get(0);
+ }
+
/**
* @return a map from message text to Diagnostic object
*/
@@ -82,6 +92,14 @@ public class TestBase {
return errorMsg2diagnostic;
}
+ /**
+ *
+ * @return a map from issueCode to Diagnostic object
+ */
+ protected HashMap<String, List<AbstractValidationDiagnostic>> getIssueCode2diagnostic() {
+ return issueCode2diagnostic;
+ }
+
protected Resource getResource(String modelName) {
XtextResourceSet rs = new XtextResourceSet();
rs.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
@@ -93,13 +111,20 @@ public class TestBase {
protected Diagnostic getDiag(EObject ele) {
Map<Object, Object> options = Maps.newHashMap();
options.put(CheckMode.KEY, CheckMode.ALL);
- options.put(CancelableDiagnostician.CANCEL_INDICATOR, CancelIndicator.NullImpl);
- // disable concrete syntax validation, since a semantic model that has been parsed
- // from the concrete syntax always complies with it - otherwise there are parse errors.
- options.put(ConcreteSyntaxEValidator.DISABLE_CONCRETE_SYNTAX_EVALIDATOR, Boolean.TRUE);
+ options.put(CancelableDiagnostician.CANCEL_INDICATOR,
+ CancelIndicator.NullImpl);
+ // disable concrete syntax validation, since a semantic model that has
+ // been parsed
+ // from the concrete syntax always complies with it - otherwise there
+ // are parse errors.
+ options.put(
+ ConcreteSyntaxEValidator.DISABLE_CONCRETE_SYNTAX_EVALIDATOR,
+ Boolean.TRUE);
// see EObjectValidator.getRootEValidator(Map<Object, Object>)
- options.put(EValidator.class, Activator.getInstance().getDiagnostician());
- return Activator.getInstance().getDiagnostician().validate(ele, options);
+ options.put(EValidator.class, Activator.getInstance()
+ .getDiagnostician());
+ return Activator.getInstance().getDiagnostician()
+ .validate(ele, options);
}
/**
@@ -110,13 +135,22 @@ public class TestBase {
for (Diagnostic d : diag.getChildren()) {
if ((d.getSeverity() & Diagnostic.INFO) != 0) {
infoMsg2diagnostic.put(d.getMessage(), d);
- }
- else if ((d.getSeverity() & Diagnostic.WARNING) != 0) {
+ } else if ((d.getSeverity() & Diagnostic.WARNING) != 0) {
warnMsg2diagnostic.put(d.getMessage(), d);
- }
- else if ((d.getSeverity() & Diagnostic.ERROR) != 0) {
+ } else if ((d.getSeverity() & Diagnostic.ERROR) != 0) {
errorMsg2diagnostic.put(d.getMessage(), d);
}
+ if (d instanceof AbstractValidationDiagnostic) {
+ AbstractValidationDiagnostic dx = (AbstractValidationDiagnostic) d;
+ List<AbstractValidationDiagnostic> list = issueCode2diagnostic
+ .get(dx.getIssueCode());
+ if (list == null) {
+ list = new ArrayList<AbstractValidationDiagnostic>();
+ issueCode2diagnostic.put(dx.getIssueCode(), list);
+ }
+ list.add(dx);
+ }
+
}
for (Diagnostic d : diag.getChildren()) {
if (!d.getChildren().isEmpty())
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
new file mode 100644
index 0000000..9490ec0
--- /dev/null
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestReachability.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.abstractexec.behavior.tests;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InitialTransition;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.StateGraphItem;
+import org.eclipse.xtext.validation.AbstractValidationDiagnostic;
+import org.eclipse.xtext.validation.FeatureBasedDiagnostic;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestReachability extends TestBase {
+
+ public static String DIAG_CODE_UNREACHABLE = "etrice.unreachable";
+
+ private RoomModel model = null;
+
+ @Before
+ public void setUp() {
+ prepare("reachability.room");
+ model = getRoomModel();
+ }
+
+ @Test
+ public void test() {
+ if (model == null)
+ Assert.fail("could not find model");
+
+ Set<StateGraphItem> items = new HashSet<StateGraphItem>();
+ for (ActorClass ac : model.getActorClasses()) {
+ if(ac.getStateMachine() == null)
+ continue;
+ TreeIterator<EObject> iter = ac.getStateMachine().eAllContents();
+ while(iter.hasNext()){
+ EObject obj = iter.next();
+ if(obj instanceof StateGraphItem)
+ items.add((StateGraphItem)obj);
+ }
+ }
+
+ for (AbstractValidationDiagnostic d : getIssueCode2diagnostic().get(
+ DIAG_CODE_UNREACHABLE)) {
+ 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);
+ }
+ }
+ }
+
+ for (StateGraphItem item : items) {
+ if (item instanceof InitialTransition) {
+ if(item.eContainer().eContainer() instanceof ActorClass)
+ continue;
+ State container = (State) item.eContainer().eContainer();
+ Assert.assertTrue(item + " is NOT marked Unreachable (or name doesn't end with '_1' ?)",
+ container.getName().endsWith("_1"));
+ } else
+ Assert.assertTrue(item + " is NOT marked Unreachable (or name doesn't end with '_1' ?)", item
+ .getName().endsWith("_1"));
+ }
+ }
+
+ private void checkUnreachable(StateGraphItem item) {
+ if (item instanceof InitialTransition) {
+ State container = (State) item.eContainer().eContainer();
+ Assert.assertTrue(item + " is incorrectly marked UNreachable (or name doesn't end with '_0' ?)",
+ container.getName().endsWith("_0"));
+ } else
+ Assert.assertTrue(item + " is incorrectly marked UNreachable (or name doesn't end with '_0' ?)", item
+ .getName().endsWith("_0"));
+ }
+}