From 0152cefa57ab67b4b5b83d47b31293c56bb03a93 Mon Sep 17 00:00:00 2001 From: aarong Date: Thu, 16 Jan 2020 14:23:37 -0500 Subject: [PATCH 1/5] Initial attempt at fixing 2161. Tests in 2032 fail. --- .../instantiation/CreateConnectionsSwitch.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java index 0043c124981..9703b7d9afd 100644 --- a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java +++ b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java @@ -654,7 +654,7 @@ private void appendSegment(ConnectionInfo connInfo, final Connection newSegment, /* * Issue 2032: Get the connections internal to the destination component that connect * to the feature. Two cases here. (1) If the component is final (thread/device/processor), - * we only follow access features inside, (2) otherwise we follow all the internal connections + * we only follow access features not connected to an internal subprogram inside, (2) otherwise we follow all the internal connections * except for the parameter connections. We keep track of whether any internal connections were * ignored so we know if we should create a connection instance that stops at the component itself. */ @@ -662,7 +662,18 @@ private void appendSegment(ConnectionInfo connInfo, final Connection newSegment, List conns = AadlUtil.getIngoingConnections(toImpl, toFeature, c -> { if (c instanceof AccessConnection) { - return true; // never ignore access connections + /* + * Bug 2161: Ignore internal access connections if they go to a subprogram. NB. access + * connection can be written in either direction, so the subprogram could be the source + * or destination context. + */ + if (c.getAllSourceContext() instanceof SubprogramSubcomponent + || c.getAllDestinationContext() instanceof SubprogramSubcomponent) { + hasIgnoredConnection.set(true); + return false; + } else { + return true; + } } else if (c instanceof ParameterConnection) { // always ignore parameter connections hasIgnoredConnection.set(true); From bde24212aa9f11511ac3775251e19b820dc4c964 Mon Sep 17 00:00:00 2001 From: aarong Date: Thu, 23 Jan 2020 15:28:42 -0500 Subject: [PATCH 2/5] ROlled back previous change. Added Unit test project --- .../CreateConnectionsSwitch.java | 15 +--- .../models/Issue2161/.gitignore | 1 + .../models/Issue2161/.project | 18 ++++ .../Issue2161/DataAccessConnectionTest.aadl | 62 +++++++++++++ .../SharedData_to_Data_Nested_in_Data.aadl | 65 ++++++++++++++ .../SharedData_to_Data_Nested_in_Thread.aadl | 88 +++++++++++++++++++ .../Issue2161/SharedData_to_Data_Peers.aadl | 34 +++++++ ...aredData_to_Subprogram_Nested_in_Data.aadl | 65 ++++++++++++++ ...edData_to_Subprogram_Nested_in_Thread.aadl | 88 +++++++++++++++++++ .../SharedData_to_Subprogram_Peer.aadl | 34 +++++++ ...edSubprogram_to_Data_Nested_in_Thread.aadl | 88 +++++++++++++++++++ .../SharedSubprogram_to_Data_Peers.aadl | 34 +++++++ .../SharedSubprogram_to_Data_inData.aadl | 65 ++++++++++++++ ...bprogram_to_Subprogram_Nested_in_Data.aadl | 65 ++++++++++++++ ...rogram_to_Subprogram_Nested_in_Thread.aadl | 88 +++++++++++++++++++ .../SharedSubprogram_to_Subprogram_Peers.aadl | 34 +++++++ 16 files changed, 831 insertions(+), 13 deletions(-) create mode 100644 core/org.osate.core.tests/models/Issue2161/.gitignore create mode 100644 core/org.osate.core.tests/models/Issue2161/.project create mode 100644 core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Data.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Thread.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Peers.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Data.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Thread.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peer.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Nested_in_Thread.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Peers.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_inData.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Data.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Thread.aadl create mode 100644 core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Peers.aadl diff --git a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java index 63ca64b7723..a1c4e98496c 100644 --- a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java +++ b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java @@ -642,7 +642,7 @@ private void appendSegment(ConnectionInfo connInfo, final Connection newSegment, /* * Issue 2032: Get the connections internal to the destination component that connect * to the feature. Two cases here. (1) If the component is final (thread/device/processor), - * we only follow access features not connected to an internal subprogram inside, (2) otherwise we follow all the internal connections + * we only follow access features inside, (2) otherwise we follow all the internal connections * except for the parameter connections. We keep track of whether any internal connections were * ignored so we know if we should create a connection instance that stops at the component itself. */ @@ -650,18 +650,7 @@ private void appendSegment(ConnectionInfo connInfo, final Connection newSegment, List conns = AadlUtil.getIngoingConnections(toImpl, toFeature, c -> { if (c instanceof AccessConnection) { - /* - * Bug 2161: Ignore internal access connections if they go to a subprogram. NB. access - * connection can be written in either direction, so the subprogram could be the source - * or destination context. - */ - if (c.getAllSourceContext() instanceof SubprogramSubcomponent - || c.getAllDestinationContext() instanceof SubprogramSubcomponent) { - hasIgnoredConnection.set(true); - return false; - } else { - return true; - } + return true; // never ignore access connections } else if (c instanceof ParameterConnection) { // always ignore parameter connections hasIgnoredConnection.set(true); diff --git a/core/org.osate.core.tests/models/Issue2161/.gitignore b/core/org.osate.core.tests/models/Issue2161/.gitignore new file mode 100644 index 00000000000..11d04b41d15 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/.gitignore @@ -0,0 +1 @@ +/.aadlbin-gen/ diff --git a/core/org.osate.core.tests/models/Issue2161/.project b/core/org.osate.core.tests/models/Issue2161/.project new file mode 100644 index 00000000000..ed590b6b07e --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/.project @@ -0,0 +1,18 @@ + + + Issue2161 + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.osate.core.aadlnature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl b/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl new file mode 100644 index 00000000000..e03b0088450 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl @@ -0,0 +1,62 @@ +package DataAccessConnectionTest +public + data Shared + end Shared; + + data implementation Shared.impl + end Shared.impl; + + subprogram RequiresData + features + shared: requires data access Shared; + end RequiresData; + + subprogram implementation RequiresData.impl + end RequiresData.impl; + + thread ThreadRequiresData + features + shared: requires data access Shared; + end ThreadRequiresData; + + thread implementation ThreadRequiresData.impl + subcomponents + sp: subprogram RequiresData.impl; + calls main: { + s1 : subprogram sp; + }; + connections + dc: data access shared <-> sp.shared; + end ThreadRequiresData.impl; + + process Proc + features + externalData: requires data access; + end Proc; + + process implementation Proc.impl + subcomponents + shared: data Shared.impl; + t1: thread ThreadRequiresData.impl; + connections + s1: data access shared <-> t1.shared; + end Proc.impl; + + processor P + end P; + + processor implementation P.impl + end P.impl; + + system DACT + end DACT; + + system implementation DACT.impl + subcomponents + proc: processor P.impl; + app: process Proc.impl; + properties + Actual_Processor_Binding => (reference (proc)) applies to app; + end DACT.impl; + +end DataAccessConnectionTest; diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Data.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Data.aadl new file mode 100644 index 00000000000..d973da13358 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Data.aadl @@ -0,0 +1,65 @@ +package SharedData_to_Data_Nested_in_Data +public + data ShareMe + end ShareMe; + + data InnerD + features + daf1: requires data access ShareMe; + end InnerD; + + data OuterD + features + daf2: requires data access ShareMe; + end OuterD; + + data implementation OuterD.generic + subcomponents + inner: data InnerD; + end OuterD.generic; + + data implementation OuterD.bidirectional extends OuterD.generic + connections + dac1: data access daf2 <-> inner.daf1; + end OuterD.bidirectional; + + data implementation OuterD.fromSharedComponent extends OuterD.generic + connections + dac1: data access daf2 -> inner.daf1; + end OuterD.fromSharedComponent; + + data implementation OuterD.toSharedComponent extends OuterD.generic + connections + dac1: data access inner.daf1 -> daf2; + end OuterD.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: data ShareMe; + outer: data OuterD.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + outer: refined to data OuterD.bidirectional; + connections + dac2: data access shareMe <-> outer.daf2; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.fromSharedComponent; + connections + dac2: data access shareMe -> outer.daf2; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.toSharedComponent; + connections + dac2: data access outer.daf2 -> shareMe; + end Root.toSharedComponent; +end SharedData_to_Data_Nested_in_Data; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Thread.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Thread.aadl new file mode 100644 index 00000000000..b8950ae4aef --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Nested_in_Thread.aadl @@ -0,0 +1,88 @@ +package SharedData_to_Data_Nested_in_Thread +public + data ShareMe + end ShareMe; + + data InnerD + features + daf1: requires data access ShareMe; + end InnerD; + + thread OuterT + features + daf2: requires data access ShareMe; + end OuterT; + + thread implementation OuterT.generic + subcomponents + inner: data InnerD; + end OuterT.generic; + + thread implementation OuterT.bidirectional extends OuterT.generic + connections + dac1: data access daf2 <-> inner.daf1; + end OuterT.bidirectional; + + thread implementation OuterT.fromSharedComponent extends OuterT.generic + connections + dac1: data access daf2 -> inner.daf1; + end OuterT.fromSharedComponent; + + thread implementation OuterT.toSharedComponent extends OuterT.generic + connections + dac1: data access inner.daf1 -> daf2; + end OuterT.toSharedComponent; + + process P + end P; + + process implementation P.generic + subcomponents + shareMe: data ShareMe; + outer: thread OuterT.generic; + end P.generic; + + process implementation P.bidirectional extends P.generic + subcomponents + outer: refined to thread OuterT.bidirectional; + connections + dac2: data access shareMe <-> outer.daf2; + end P.bidirectional; + + process implementation P.fromSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.fromSharedComponent; + connections + dac2: data access shareMe -> outer.daf2; + end P.fromSharedComponent; + + process implementation P.toSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.toSharedComponent; + connections + dac2: data access outer.daf2 -> shareMe; + end P.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + myProcess: process P.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + myProcess: refined to process P.bidirectional; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.fromSharedComponent; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.toSharedComponent; + end Root.toSharedComponent; +end SharedData_to_Data_Nested_in_Thread; diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Peers.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Peers.aadl new file mode 100644 index 00000000000..4fd42382fed --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Data_Peers.aadl @@ -0,0 +1,34 @@ +package SharedData_to_Data_Peers +public + data ShareMe + end ShareMe; + + data D + features + daf: requires data access ShareMe; + end D; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: data ShareMe; + d: data D; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + connections + dac: data access shareMe <-> d.daf; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + connections + dac: data access shareMe -> d.daf; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + connections + dac: data access d.daf -> shareMe; + end Root.toSharedComponent; +end SharedData_to_Data_Peers; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Data.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Data.aadl new file mode 100644 index 00000000000..57b536382d3 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Data.aadl @@ -0,0 +1,65 @@ +package SharedData_to_Subprogram_Nested_in_Data +public + data ShareMe + end ShareMe; + + subprogram InnerS + features + daf1: requires data access ShareMe; + end InnerS; + + data OuterD + features + daf2: requires data access ShareMe; + end OuterD; + + data implementation OuterD.generic + subcomponents + inner: subprogram InnerS; + end OuterD.generic; + + data implementation OuterD.bidirectional extends OuterD.generic + connections + dac1: data access daf2 <-> inner.daf1; + end OuterD.bidirectional; + + data implementation OuterD.fromSharedComponent extends OuterD.generic + connections + dac1: data access daf2 -> inner.daf1; + end OuterD.fromSharedComponent; + + data implementation OuterD.toSharedComponent extends OuterD.generic + connections + dac1: data access inner.daf1 -> daf2; + end OuterD.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: data ShareMe; + outer: data OuterD.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + outer: refined to data OuterD.bidirectional; + connections + dac2: data access shareMe <-> outer.daf2; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.fromSharedComponent; + connections + dac2: data access shareMe -> outer.daf2; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.toSharedComponent; + connections + dac2: data access outer.daf2 -> shareMe; + end Root.toSharedComponent; +end SharedData_to_Subprogram_Nested_in_Data; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Thread.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Thread.aadl new file mode 100644 index 00000000000..80594d5a425 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Nested_in_Thread.aadl @@ -0,0 +1,88 @@ +package SharedData_to_Subprogram_Nested_in_Thread +public + data ShareMe + end ShareMe; + + subprogram InnerS + features + daf1: requires data access ShareMe; + end InnerS; + + thread OuterT + features + daf2: requires data access ShareMe; + end OuterT; + + thread implementation OuterT.generic + subcomponents + inner: subprogram InnerS; + end OuterT.generic; + + thread implementation OuterT.bidirectional extends OuterT.generic + connections + dac1: data access daf2 <-> inner.daf1; + end OuterT.bidirectional; + + thread implementation OuterT.fromSharedComponent extends OuterT.generic + connections + dac1: data access daf2 -> inner.daf1; + end OuterT.fromSharedComponent; + + thread implementation OuterT.toSharedComponent extends OuterT.generic + connections + dac1: data access inner.daf1 -> daf2; + end OuterT.toSharedComponent; + + process P + end P; + + process implementation P.generic + subcomponents + shareMe: data ShareMe; + outer: thread OuterT.generic; + end P.generic; + + process implementation P.bidirectional extends P.generic + subcomponents + outer: refined to thread OuterT.bidirectional; + connections + dac2: data access shareMe <-> outer.daf2; + end P.bidirectional; + + process implementation P.fromSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.fromSharedComponent; + connections + dac2: data access shareMe -> outer.daf2; + end P.fromSharedComponent; + + process implementation P.toSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.toSharedComponent; + connections + dac2: data access outer.daf2 -> shareMe; + end P.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + myProcess: process P.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + myProcess: refined to process P.bidirectional; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.fromSharedComponent; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.toSharedComponent; + end Root.toSharedComponent; +end SharedData_to_Subprogram_Nested_in_Thread; diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peer.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peer.aadl new file mode 100644 index 00000000000..1a835b45b25 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peer.aadl @@ -0,0 +1,34 @@ +package SharedData_to_Subprogram_Peers +public + data ShareMe + end ShareMe; + + subprogram S + features + daf: requires data access ShareMe; + end S; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: data ShareMe; + s: subprogram S; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + connections + dac: data access shareMe <-> s.daf; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + connections + dac: data access shareMe -> s.daf; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + connections + dac: data access s.daf -> shareMe; + end Root.toSharedComponent; +end SharedData_to_Subprogram_Peers; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Nested_in_Thread.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Nested_in_Thread.aadl new file mode 100644 index 00000000000..ef74bd3afcd --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Nested_in_Thread.aadl @@ -0,0 +1,88 @@ +package SharedSubprogram_to_Data_Nested_in_Thread +public + subprogram ShareMe + end ShareMe; + + data InnerD + features + saf1: requires subprogram access ShareMe; + end InnerD; + + thread OuterT + features + saf2: requires subprogram access ShareMe; + end OuterT; + + thread implementation OuterT.generic + subcomponents + inner: data InnerD; + end OuterT.generic; + + thread implementation OuterT.bidirectional extends OuterT.generic + connections + sac1: subprogram access saf2 <-> inner.saf1; + end OuterT.bidirectional; + + thread implementation OuterT.fromSharedComponent extends OuterT.generic + connections + sac1: subprogram access saf2 -> inner.saf1; + end OuterT.fromSharedComponent; + + thread implementation OuterT.toSharedComponent extends OuterT.generic + connections + sac1: subprogram access inner.saf1 -> saf2; + end OuterT.toSharedComponent; + + process P + end P; + + process implementation P.generic + subcomponents + shareMe: subprogram ShareMe; + outer: thread OuterT.generic; + end P.generic; + + process implementation P.bidirectional extends P.generic + subcomponents + outer: refined to thread OuterT.bidirectional; + connections + sac2: subprogram access shareMe <-> outer.saf2; + end P.bidirectional; + + process implementation P.fromSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.fromSharedComponent; + connections + sac2: subprogram access shareMe -> outer.saf2; + end P.fromSharedComponent; + + process implementation P.toSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.toSharedComponent; + connections + sac2: subprogram access outer.saf2 -> shareMe; + end P.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + myProcess: process P.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + myProcess: refined to process P.bidirectional; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.fromSharedComponent; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.toSharedComponent; + end Root.toSharedComponent; +end SharedSubprogram_to_Data_Nested_in_Thread; diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Peers.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Peers.aadl new file mode 100644 index 00000000000..6495a8ec236 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Peers.aadl @@ -0,0 +1,34 @@ +package SharedSubprogram_to_Data_Peers +public + subprogram ShareMe + end ShareMe; + + data D + features + saf: requires subprogram access ShareMe; + end D; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: subprogram ShareMe; + d: data D; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + connections + sac: subprogram access shareMe <-> d.saf; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + connections + sac: subprogram access shareMe -> d.saf; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + connections + sac: subprogram access d.saf -> shareMe; + end Root.toSharedComponent; +end SharedSubprogram_to_Data_Peers; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_inData.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_inData.aadl new file mode 100644 index 00000000000..71d1165af54 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_inData.aadl @@ -0,0 +1,65 @@ +package SharedSubprogram_to_Data_inData +public + subprogram ShareMe + end ShareMe; + + data InnerD + features + saf1: requires subprogram access ShareMe; + end InnerD; + + data OuterD + features + saf2: requires subprogram access ShareMe; + end OuterD; + + data implementation OuterD.generic + subcomponents + inner: data InnerD; + end OuterD.generic; + + data implementation OuterD.bidirectional extends OuterD.generic + connections + sac1: subprogram access saf2 <-> inner.saf1; + end OuterD.bidirectional; + + data implementation OuterD.fromSharedComponent extends OuterD.generic + connections + sac1: subprogram access saf2 -> inner.saf1; + end OuterD.fromSharedComponent; + + data implementation OuterD.toSharedComponent extends OuterD.generic + connections + sac1: subprogram access inner.saf1 -> saf2; + end OuterD.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: subprogram ShareMe; + outer: data OuterD.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + outer: refined to data OuterD.bidirectional; + connections + sac2: subprogram access shareMe <-> outer.saf2; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.fromSharedComponent; + connections + sac2: subprogram access shareMe -> outer.saf2; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.toSharedComponent; + connections + sac2: subprogram access outer.saf2 -> shareMe; + end Root.toSharedComponent; +end SharedSubprogram_to_Data_inData; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Data.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Data.aadl new file mode 100644 index 00000000000..74b110b2682 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Data.aadl @@ -0,0 +1,65 @@ +package SharedSubprogram_to_Subprogram_Nested_in_Data +public + subprogram ShareMe + end ShareMe; + + subprogram InnerS + features + saf1: requires subprogram access ShareMe; + end InnerS; + + data OuterD + features + saf2: requires subprogram access ShareMe; + end OuterD; + + data implementation OuterD.generic + subcomponents + inner: subprogram InnerS; + end OuterD.generic; + + data implementation OuterD.bidirectional extends OuterD.generic + connections + sac1: subprogram access saf2 <-> inner.saf1; + end OuterD.bidirectional; + + data implementation OuterD.fromSharedComponent extends OuterD.generic + connections + sac1: subprogram access saf2 -> inner.saf1; + end OuterD.fromSharedComponent; + + data implementation OuterD.toSharedComponent extends OuterD.generic + connections + sac1: subprogram access inner.saf1 -> saf2; + end OuterD.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: subprogram ShareMe; + outer: data OuterD.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + outer: refined to data OuterD.bidirectional; + connections + sac2: subprogram access shareMe <-> outer.saf2; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.fromSharedComponent; + connections + sac2: subprogram access shareMe -> outer.saf2; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + outer: refined to data OuterD.toSharedComponent; + connections + sac2: subprogram access outer.saf2 -> shareMe; + end Root.toSharedComponent; +end SharedSubprogram_to_Subprogram_Nested_in_Data; \ No newline at end of file diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Thread.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Thread.aadl new file mode 100644 index 00000000000..dc0ee33b9b8 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Nested_in_Thread.aadl @@ -0,0 +1,88 @@ +package SharedSubprogram_to_Subprogram_Nested_in_Thread +public + subprogram ShareMe + end ShareMe; + + subprogram InnerS + features + saf1: requires subprogram access ShareMe; + end InnerS; + + thread OuterT + features + saf2: requires subprogram access ShareMe; + end OuterT; + + thread implementation OuterT.generic + subcomponents + inner: subprogram InnerS; + end OuterT.generic; + + thread implementation OuterT.bidirectional extends OuterT.generic + connections + sac1: subprogram access saf2 <-> inner.saf1; + end OuterT.bidirectional; + + thread implementation OuterT.fromSharedComponent extends OuterT.generic + connections + sac1: subprogram access saf2 -> inner.saf1; + end OuterT.fromSharedComponent; + + thread implementation OuterT.toSharedComponent extends OuterT.generic + connections + sac1: subprogram access inner.saf1 -> saf2; + end OuterT.toSharedComponent; + + process P + end P; + + process implementation P.generic + subcomponents + shareMe: subprogram ShareMe; + outer: thread OuterT.generic; + end P.generic; + + process implementation P.bidirectional extends P.generic + subcomponents + outer: refined to thread OuterT.bidirectional; + connections + sac2: subprogram access shareMe <-> outer.saf2; + end P.bidirectional; + + process implementation P.fromSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.fromSharedComponent; + connections + sac2: subprogram access shareMe -> outer.saf2; + end P.fromSharedComponent; + + process implementation P.toSharedComponent extends P.generic + subcomponents + outer: refined to thread OuterT.toSharedComponent; + connections + sac2: subprogram access outer.saf2 -> shareMe; + end P.toSharedComponent; + + system Root + end Root; + + system implementation Root.generic + subcomponents + myProcess: process P.generic; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + subcomponents + myProcess: refined to process P.bidirectional; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.fromSharedComponent; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + subcomponents + myProcess: refined to process P.toSharedComponent; + end Root.toSharedComponent; +end SharedSubprogram_to_Subprogram_Nested_in_Thread; diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Peers.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Peers.aadl new file mode 100644 index 00000000000..572b026356e --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Subprogram_Peers.aadl @@ -0,0 +1,34 @@ +package SharedSubprogram_to_Subprogram_Peers +public + subprogram ShareMe + end ShareMe; + + subprogram S + features + saf: requires subprogram access ShareMe; + end S; + + system Root + end Root; + + system implementation Root.generic + subcomponents + shareMe: subprogram ShareMe; + s: subprogram S; + end Root.generic; + + system implementation Root.bidirectional extends Root.generic + connections + sac: subprogram access shareMe <-> s.saf; + end Root.bidirectional; + + system implementation Root.fromSharedComponent extends Root.generic + connections + sac: subprogram access shareMe -> s.saf; + end Root.fromSharedComponent; + + system implementation Root.toSharedComponent extends Root.generic + connections + sac: subprogram access s.saf -> shareMe; + end Root.toSharedComponent; +end SharedSubprogram_to_Subprogram_Peers; \ No newline at end of file From 4abf318934c8630f0deecfe8ca12ba2c5dc5109c Mon Sep 17 00:00:00 2001 From: aarong Date: Fri, 24 Jan 2020 11:15:52 -0500 Subject: [PATCH 3/5] Fixed issue 2162 by undoing the fix that was added for issue 222. Updated unit tests for 2032. Need to add tests for this issue still. --- .../CreateConnectionsSwitch.java | 19 +++++-------------- .../models/Issue2161/.gitignore | 1 + .../Issue2161/DataAccessConnectionTest.aadl | 2 +- .../core/tests/issues/Issue2032Test.xtend | 18 +----------------- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java index a1c4e98496c..2aaf92cbc29 100644 --- a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java +++ b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -81,7 +81,6 @@ import org.osate.aadl2.PropertyExpression; import org.osate.aadl2.Subcomponent; import org.osate.aadl2.SubprogramSubcomponent; -import org.osate.aadl2.SubprogramType; import org.osate.aadl2.TriggerPort; import org.osate.aadl2.impl.ParameterImpl; import org.osate.aadl2.instance.ComponentInstance; @@ -390,14 +389,6 @@ private void appendSegment(ConnectionInfo connInfo, final Connection newSegment, return; } - /* - * Fix JD bug #222 - */ - if ((toEnd instanceof DataAccess) && (toEnd.getContainingClassifier() != null) - && (toEnd.getContainingClassifier() instanceof SubprogramType)) { - return; - } - if (toCtx instanceof Subcomponent && toCi == null) { if (!(toCtx instanceof SubprogramSubcomponent)) { error(ci, "Instantiation error: no component instance for subcomponent " + toCtx.getName()); diff --git a/core/org.osate.core.tests/models/Issue2161/.gitignore b/core/org.osate.core.tests/models/Issue2161/.gitignore index 11d04b41d15..afce51184c6 100644 --- a/core/org.osate.core.tests/models/Issue2161/.gitignore +++ b/core/org.osate.core.tests/models/Issue2161/.gitignore @@ -1 +1,2 @@ /.aadlbin-gen/ +/instances/ diff --git a/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl b/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl index e03b0088450..dc6181a829b 100644 --- a/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl +++ b/core/org.osate.core.tests/models/Issue2161/DataAccessConnectionTest.aadl @@ -26,7 +26,7 @@ public s1 : subprogram sp; }; connections - dc: data access shared <-> sp.shared; + dc: data access shared -> sp.shared; end ThreadRequiresData.impl; process Proc diff --git a/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2032Test.xtend b/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2032Test.xtend index 4d62ad24b33..8957d1bbd72 100644 --- a/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2032Test.xtend +++ b/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2032Test.xtend @@ -114,7 +114,7 @@ class Issue2032Test { @Test def void testJustData_Subprogram() { - test0("JustData_subprogram.aadl") + test3("JustData_subprogram.aadl") } @Test @@ -428,22 +428,6 @@ class Issue2032Test { assertEquals(connRefs3.get(1).connection, connRefs2.get(0).connection) } - private def void test0(String aadlFile) { - val pkg = testHelper.parseFile(PROJECT_LOCATION + aadlFile) - - val cls = pkg.ownedPublicSection.ownedClassifiers - assertTrue('System implementation "' + ROOT_IMPL + '" not found', cls.exists[name == ROOT_IMPL]) - - // Instantiate system - val sysImpl = cls.findFirst[name == ROOT_IMPL] as SystemImplementation - val instance = InstantiateModel.instantiate(sysImpl) - assertEquals(ROOT_INSTANCE, instance.name) - - // There should be exactly 0 connection instances - val myP = instance.componentInstances.get(0) - assertEquals(0, myP.connectionInstances.size) - } - private def void test1(String aadlFile) { val pkg = testHelper.parseFile(PROJECT_LOCATION + aadlFile) From e89ca922ea85e3ad25404f93e7afe98e8a3a9123 Mon Sep 17 00:00:00 2001 From: aarong Date: Fri, 24 Jan 2020 13:53:38 -0500 Subject: [PATCH 4/5] Added testfile from Issue #222 to the test project. Reinserted a modified version of the check for 222 to remove connections to subprogram CALLS. --- .../CreateConnectionsSwitch.java | 10 +++++ .../models/Issue2161/test2.aadl | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 core/org.osate.core.tests/models/Issue2161/test2.aadl diff --git a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java index 2aaf92cbc29..fa93ca629a2 100644 --- a/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java +++ b/core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateConnectionsSwitch.java @@ -80,6 +80,7 @@ import org.osate.aadl2.Property; import org.osate.aadl2.PropertyExpression; import org.osate.aadl2.Subcomponent; +import org.osate.aadl2.SubprogramCall; import org.osate.aadl2.SubprogramSubcomponent; import org.osate.aadl2.TriggerPort; import org.osate.aadl2.impl.ParameterImpl; @@ -389,6 +390,15 @@ private void appendSegment(ConnectionInfo connInfo, final Connection newSegment, return; } + /* + * Fix JD bug #222. + * Tweaked again for Issue #2162: changed to check if the context is a subprogram call + * rather than just checking if the feature is contained in a subprogram. + */ + if ((toEnd instanceof DataAccess) && (toCtx instanceof SubprogramCall)) { + return; + } + if (toCtx instanceof Subcomponent && toCi == null) { if (!(toCtx instanceof SubprogramSubcomponent)) { error(ci, "Instantiation error: no component instance for subcomponent " + toCtx.getName()); diff --git a/core/org.osate.core.tests/models/Issue2161/test2.aadl b/core/org.osate.core.tests/models/Issue2161/test2.aadl new file mode 100644 index 00000000000..c95a86c6083 --- /dev/null +++ b/core/org.osate.core.tests/models/Issue2161/test2.aadl @@ -0,0 +1,38 @@ +package test2 +public + with Base_Types; + with Data_Model; + + subprogram job + features + param : requires data access Base_Types::Integer; + end job; + + thread th end th; + + thread implementation th.impl + subcomponents + constantValue: data Base_Types::Integer + { + Data_Model::Initial_Value => ("3"); + }; + calls + seq: { call1: subprogram job; }; + connections + dac: data access constantValue -> call1.param; + end th.impl; + + process proc end proc; + + process implementation proc.impl + subcomponents + th: thread th.impl; + end proc.impl; + + system root end root; + + system implementation root.impl + subcomponents + proc: process proc.impl; + end root.impl; +end test2; \ No newline at end of file From 660f8a268aea19f84015982c9b62eb549a86cfb5 Mon Sep 17 00:00:00 2001 From: aarong Date: Fri, 24 Jan 2020 16:10:06 -0500 Subject: [PATCH 5/5] Added unit tests --- ...dl => SharedData_to_Subprogram_Peers.aadl} | 0 ...redSubprogram_to_Data_Nested_in_Data.aadl} | 0 .../core/tests/issues/Issue2161Test.xtend | 345 ++++++++++++++++++ 3 files changed, 345 insertions(+) rename core/org.osate.core.tests/models/Issue2161/{SharedData_to_Subprogram_Peer.aadl => SharedData_to_Subprogram_Peers.aadl} (100%) rename core/org.osate.core.tests/models/Issue2161/{SharedSubprogram_to_Data_inData.aadl => SharedSubprogram_to_Data_Nested_in_Data.aadl} (100%) create mode 100644 core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2161Test.xtend diff --git a/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peer.aadl b/core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peers.aadl similarity index 100% rename from core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peer.aadl rename to core/org.osate.core.tests/models/Issue2161/SharedData_to_Subprogram_Peers.aadl diff --git a/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_inData.aadl b/core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Nested_in_Data.aadl similarity index 100% rename from core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_inData.aadl rename to core/org.osate.core.tests/models/Issue2161/SharedSubprogram_to_Data_Nested_in_Data.aadl diff --git a/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2161Test.xtend b/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2161Test.xtend new file mode 100644 index 00000000000..55b4c11b1c2 --- /dev/null +++ b/core/org.osate.core.tests/src/org/osate/core/tests/issues/Issue2161Test.xtend @@ -0,0 +1,345 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.core.tests.issues + +import com.google.inject.Inject +import org.eclipse.emf.common.util.EList +import org.eclipse.xtext.testing.InjectWith +import org.eclipse.xtext.testing.XtextRunner +import org.junit.Test +import org.junit.runner.RunWith +import org.osate.aadl2.AadlPackage +import org.osate.aadl2.Classifier +import org.osate.aadl2.SystemImplementation +import org.osate.aadl2.instantiation.InstantiateModel +import org.osate.testsupport.Aadl2InjectorProvider +import org.osate.testsupport.TestHelper + +import static org.junit.Assert.* +import org.osate.aadl2.instance.ConnectionReference +import java.util.List +import org.osate.aadl2.instance.ComponentInstance + +@RunWith(XtextRunner) +@InjectWith(Aadl2InjectorProvider) +class Issue2161Test { + val static PROJECT_LOCATION = "org.osate.core.tests/models/Issue2161/" + + val static ROOT_IMPL = "root.impl" + + val static ROOT_BIDIRECTIONAL = "Root.bidirectional" + val static ROOT_FROM_SHARED = "Root.fromSharedComponent" + val static ROOT_TO_SHARED = "Root.toSharedComponent" + + val static ROOT_BIDIRECTIONAL_INSTANCE = "Root_bidirectional_Instance" + val static ROOT_FROM_SHARED_INSTANCE = "Root_fromSharedComponent_Instance" + val static ROOT_TO_SHARED_INSTANCE = "Root_toSharedComponent_Instance" + + @Inject + TestHelper testHelper + + @Test + def void testIssue222() { + val pkg = testHelper.parseFile(PROJECT_LOCATION + "test2.aadl") + + val cls = pkg.ownedPublicSection.ownedClassifiers + assertTrue('System implementation "' + ROOT_IMPL + '" not found', cls.exists[name == ROOT_IMPL]) + + val sysImpl = cls.findFirst[name == ROOT_IMPL] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + + // There should be no connection instances + assertEquals(0, instance.connectionInstances.size) + } + + @Test + def void testSharedData_toData_asPeers() { + testAsPeers("SharedData_to_Data_Peers.aadl") + } + + @Test + def void testSharedData_toSubprogram_asPeers() { + testAsPeers("SharedData_to_Subprogram_Peers.aadl") + } + + @Test + def void testSharedSubprogram_toData_asPeers() { + testAsPeers("SharedSubprogram_to_Data_Peers.aadl") + } + + @Test + def void testSharedSubprogram_toSubprogram_asPeers() { + testAsPeers("SharedSubprogram_to_Subprogram_Peers.aadl") + } + + def void testAsPeers(String aadlFile) { + val pkg = testHelper.parseFile(PROJECT_LOCATION + aadlFile) + + val cls = pkg.ownedPublicSection.ownedClassifiers + intantiateBidirectionalPeers(cls) + val connRefs1 = instantiateFromSharedPeers(cls) + val connRefs2 = instantiateToSharedPeers(cls) + + // The two connection instances from "to shared" and "from shared" should follow opposite paths + assertEquals(connRefs1.get(0).connection.name, connRefs2.get(0).connection.name) + } + + protected def void intantiateBidirectionalPeers(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_BIDIRECTIONAL] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_BIDIRECTIONAL_INSTANCE, instance.name) + + // There should be exactly 2 connection instances + assertEquals(2, instance.connectionInstances.size) + + val ci1 = instance.connectionInstances.get(0) + val ci2 = instance.connectionInstances.get(1) + + // Each connection instance should have 1 connection reference + val connRefs1 = ci1.connectionReferences + val connRefs2 = ci2.connectionReferences + assertEquals(1, connRefs1.size) + assertEquals(1, connRefs2.size) + + // The two connection instances should follow opposite paths + assertEquals(connRefs1.get(0).connection, connRefs2.get(0).connection) + } + + protected def List instantiateFromSharedPeers(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_FROM_SHARED] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_FROM_SHARED_INSTANCE, instance.name) + + // There should be exactly 1 connection instances + assertEquals(1, instance.connectionInstances.size) + + val ci = instance.connectionInstances.get(0) + + // Each connection instance should have 1 connection reference + val connRefs = ci.connectionReferences + assertEquals(1, connRefs.size) + + return connRefs + } + + protected def List instantiateToSharedPeers(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_TO_SHARED] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_TO_SHARED_INSTANCE, instance.name) + + // There should be exactly 1 connection instances + assertEquals(1, instance.connectionInstances.size) + + val ci = instance.connectionInstances.get(0) + + // Each connection instance should have 1 connection reference + val connRefs = ci.connectionReferences + assertEquals(1, connRefs.size) + + return connRefs + } + + + @Test + def void testSharedData_toData_inData() { + testInData("SharedData_to_Data_Nested_in_Data.aadl") + } + + @Test + def void testSharedData_toSubprogram_inData() { + testInData("SharedData_to_Subprogram_Nested_in_Data.aadl") + } + + @Test + def void testSharedSubprogram_toData_inData() { + testInData("SharedSubprogram_to_Data_Nested_in_Data.aadl") + } + + @Test + def void testSharedSubprogram_toSubprogram_inData() { + testInData("SharedSubprogram_to_Subprogram_Nested_in_Data.aadl") + } + + def void testInData(String aadlFile) { + val pkg = testHelper.parseFile(PROJECT_LOCATION + aadlFile) + + val cls = pkg.ownedPublicSection.ownedClassifiers + intantiateBidirectionalInData(cls) + val connRefs1 = instantiateFromSharedInData(cls) + val connRefs2 = instantiateToSharedInData(cls) + + // The connection instances from "to shared" and "from shared" should follow opposite paths + assertEquals(connRefs1.get(0).connection.name, connRefs2.get(1).connection.name) + assertEquals(connRefs1.get(1).connection.name, connRefs2.get(0).connection.name) + } + + protected def void intantiateBidirectionalInData(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_BIDIRECTIONAL] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_BIDIRECTIONAL_INSTANCE, instance.name) + + // There should be exactly 2 connection instances + assertEquals(2, instance.connectionInstances.size) + + val ci1 = instance.connectionInstances.get(0) + val ci2 = instance.connectionInstances.get(1) + + // Each connection instance should have 2 connection reference + val connRefs1 = ci1.connectionReferences + val connRefs2 = ci2.connectionReferences + assertEquals(2, connRefs1.size) + assertEquals(2, connRefs2.size) + + // The two connection instances should follow opposite paths + assertEquals(connRefs1.get(0).connection, connRefs2.get(1).connection) + assertEquals(connRefs1.get(1).connection, connRefs2.get(0).connection) + } + + protected def List instantiateFromSharedInData(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_FROM_SHARED] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_FROM_SHARED_INSTANCE, instance.name) + + // There should be exactly 1 connection instances + assertEquals(1, instance.connectionInstances.size) + + val ci = instance.connectionInstances.get(0) + + // Each connection instance should have 2 connection reference + val connRefs = ci.connectionReferences + assertEquals(2, connRefs.size) + + return connRefs + } + + protected def List instantiateToSharedInData(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_TO_SHARED] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_TO_SHARED_INSTANCE, instance.name) + + // There should be exactly 1 connection instances + assertEquals(1, instance.connectionInstances.size) + + val ci = instance.connectionInstances.get(0) + + // Each connection instance should have 1 connection reference + val connRefs = ci.connectionReferences + assertEquals(2, connRefs.size) + + return connRefs + } + + + @Test + def void testSharedData_toData_inThread() { + testInThread("SharedData_to_Data_Nested_in_Thread.aadl") + } + + @Test + def void testSharedData_toSubprogram_inThread() { + testInThread("SharedData_to_Subprogram_Nested_in_Thread.aadl") + } + + @Test + def void testSharedSubprogram_toData_inThread() { + testInThread("SharedSubprogram_to_Data_Nested_in_Thread.aadl") + } + + @Test + def void testSharedSubprogram_toSubprogram_inThread() { + testInThread("SharedSubprogram_to_Subprogram_Nested_in_Thread.aadl") + } + + def void testInThread(String aadlFile) { + val pkg = testHelper.parseFile(PROJECT_LOCATION + aadlFile) + + val cls = pkg.ownedPublicSection.ownedClassifiers + intantiateBidirectionalInThread(cls) + val connRefs1 = instantiateFromSharedInThread(cls) + val connRefs2 = instantiateToSharedInThread(cls) + + // The connection instances from "to shared" and "from shared" should follow opposite paths + assertEquals(connRefs1.get(0).connection.name, connRefs2.get(1).connection.name) + assertEquals(connRefs1.get(1).connection.name, connRefs2.get(0).connection.name) + } + + protected def void intantiateBidirectionalInThread(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_BIDIRECTIONAL] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_BIDIRECTIONAL_INSTANCE, instance.name) + val process = instance.componentInstances.get(0) as ComponentInstance + + // There should be exactly 2 connection instances + assertEquals(2, process.connectionInstances.size) + + val ci1 = process.connectionInstances.get(0) + val ci2 = process.connectionInstances.get(1) + + // Each connection instance should have 2 connection reference + val connRefs1 = ci1.connectionReferences + val connRefs2 = ci2.connectionReferences + assertEquals(2, connRefs1.size) + assertEquals(2, connRefs2.size) + + // The two connection instances should follow opposite paths + assertEquals(connRefs1.get(0).connection, connRefs2.get(1).connection) + assertEquals(connRefs1.get(1).connection, connRefs2.get(0).connection) + } + + protected def List instantiateFromSharedInThread(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_FROM_SHARED] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_FROM_SHARED_INSTANCE, instance.name) + val process = instance.componentInstances.get(0) as ComponentInstance + + // There should be exactly 1 connection instances + assertEquals(1, process.connectionInstances.size) + + val ci = process.connectionInstances.get(0) + + // Each connection instance should have 2 connection reference + val connRefs = ci.connectionReferences + assertEquals(2, connRefs.size) + + return connRefs + } + + protected def List instantiateToSharedInThread(EList cls) { + val sysImpl = cls.findFirst[name == ROOT_TO_SHARED] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + assertEquals(ROOT_TO_SHARED_INSTANCE, instance.name) + val process = instance.componentInstances.get(0) as ComponentInstance + + // There should be exactly 1 connection instances + assertEquals(1, process.connectionInstances.size) + + val ci = process.connectionInstances.get(0) + + // Each connection instance should have 1 connection reference + val connRefs = ci.connectionReferences + assertEquals(2, connRefs.size) + + return connRefs + } +}