From d85fe44f44d5d09c2bfc58fc126bcbc71af3a72d Mon Sep 17 00:00:00 2001 From: Lutz Wrage Date: Fri, 18 Sep 2026 12:09:43 -0400 Subject: [PATCH 1/2] Add regression test for issue #2807 Exercise repair and recover event initiators through external AADL models. Require one diagnostic for each invalid mode or subcomponent reference, and accept ports, internal events, mode transitions, and absent when clauses. Before the fix, repair events report no initiator errors and recover events report each error twice. The valid model passes validation without unrelated issues. --- .../models/issue2807/.gitignore | 2 + .../models/issue2807/.project | 18 ++++ .../models/issue2807/InvalidRecover.aadl | 47 ++++++++++ .../models/issue2807/Issue2807.aadl | 47 ++++++++++ .../models/issue2807/ValidInitiators.aadl | 56 ++++++++++++ .../tests/issues/Issue2807Test.java | 87 +++++++++++++++++++ 6 files changed, 257 insertions(+) create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.gitignore create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.project create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2807/InvalidRecover.aadl create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2807/Issue2807.aadl create mode 100644 emv2/org.osate.aadl2.errormodel.tests/models/issue2807/ValidInitiators.aadl create mode 100644 emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2807Test.java diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.gitignore b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.gitignore new file mode 100644 index 00000000000..afce51184c6 --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.gitignore @@ -0,0 +1,2 @@ +/.aadlbin-gen/ +/instances/ diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.project b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.project new file mode 100644 index 00000000000..b716eb1b8d3 --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/.project @@ -0,0 +1,18 @@ + + + issue2807 + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.osate.core.aadlnature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/InvalidRecover.aadl b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/InvalidRecover.aadl new file mode 100644 index 00000000000..dd942b831ce --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/InvalidRecover.aadl @@ -0,0 +1,47 @@ +-- +-- Copyright (c) 2004-2026 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 InvalidRecover +public + system s + features + ep1: in out event port; + modes + m1: initial mode; + m2: mode; + mt1: m1 -[ep1]-> m2; + end s; + + system implementation s.i + subcomponents + child: system; + internal features + es1: event; + annex EMV2 {** + component error behavior + events + invalid_event: recover event when ep1, m1, child; + end component; + **}; + end s.i; +end InvalidRecover; diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/Issue2807.aadl b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/Issue2807.aadl new file mode 100644 index 00000000000..9bb3c5efcf9 --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/Issue2807.aadl @@ -0,0 +1,47 @@ +-- +-- Copyright (c) 2004-2026 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 Issue2807 +public + system s + features + ep1: in out event port; + modes + m1: initial mode; + m2: mode; + mt1: m1 -[ep1]-> m2; + end s; + + system implementation s.i + subcomponents + child: system; + internal features + es1: event; + annex EMV2 {** + component error behavior + events + invalid_event: repair event when ep1, m1, child; + end component; + **}; + end s.i; +end Issue2807; diff --git a/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/ValidInitiators.aadl b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/ValidInitiators.aadl new file mode 100644 index 00000000000..bb2a28b8410 --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/models/issue2807/ValidInitiators.aadl @@ -0,0 +1,56 @@ +-- +-- Copyright (c) 2004-2026 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 ValidInitiators +public + system s + features + ep1: in out event port; + modes + m1: initial mode; + m2: mode; + mt1: m1 -[ep1]-> m2; + end s; + + system implementation s.i + subcomponents + child: system; + internal features + es1: event; + annex EMV2 {** + component error behavior + events + repair1: repair event; + repair2: repair event when ep1; + repair3: repair event when mt1; + repair4: repair event when es1; + repair5: repair event when ep1, mt1, es1; + recover1: recover event; + recover2: recover event when ep1; + recover3: recover event when mt1; + recover4: recover event when es1; + recover5: recover event when ep1, mt1, es1; + end component; + **}; + end s.i; +end ValidInitiators; diff --git a/emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2807Test.java b/emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2807Test.java new file mode 100644 index 00000000000..f41d1c0dedc --- /dev/null +++ b/emv2/org.osate.aadl2.errormodel.tests/src/org/osate/aadl2/errormodel/tests/issues/Issue2807Test.java @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2004-2026 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.aadl2.errormodel.tests.issues; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.validation.ValidationTestHelper; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.osate.aadl2.AadlPackage; +import org.osate.aadl2.DefaultAnnexSubclause; +import org.osate.aadl2.errormodel.tests.ErrorModelInjectorProvider; +import org.osate.testsupport.AssertHelper; +import org.osate.testsupport.TestHelper; +import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause; + +import com.google.inject.Inject; +import com.itemis.xtext.testing.FluentIssueCollection; +import com.itemis.xtext.testing.XtextTest; + +@RunWith(XtextRunner.class) +@InjectWith(ErrorModelInjectorProvider.class) +public class Issue2807Test extends XtextTest { + private static final String PATH = "org.osate.aadl2.errormodel.tests/models/issue2807/"; + + @Inject + private TestHelper testHelper; + + @Inject + private ValidationTestHelper validationHelper; + + @Test + public void repairEventRejectsInvalidInitiators() throws Exception { + assertInvalidInitiators("Issue2807.aadl", "Repair"); + } + + @Test + public void recoverEventReportsEachInvalidInitiatorOnce() throws Exception { + assertInvalidInitiators("InvalidRecover.aadl", "Recover"); + } + + @Test + public void validInitiatorsAndAbsentWhenClausesAreAccepted() { + var pkg = testHelper.parseFile(PATH + "ValidInitiators.aadl"); + validationHelper.assertNoIssues(pkg); + } + + private void assertInvalidInitiators(String fileName, String eventKind) throws Exception { + var result = issues = testHelper.testFile(PATH + fileName); + var expected = new FluentIssueCollection(result.getResource(), new ArrayList<>(), new ArrayList<>()); + var pkg = (AadlPackage) result.getResource().getContents().getFirst(); + var implementation = pkg.getPublicSection().getOwnedClassifiers().get(1); + var annex = (ErrorModelSubclause) ((DefaultAnnexSubclause) implementation.getOwnedAnnexSubclauses() + .getFirst()).getParsedAnnexSubclause(); + AssertHelper.assertError(annex.getEvents().getFirst(), result.getIssues(), expected, + eventKind + " event trigger reference 'm1' is not a port, component internal self event, or mode transition.", + eventKind + " event trigger reference 'child' is not a port, component internal self event, or mode transition."); + assertEquals("Each invalid initiator must produce exactly one diagnostic", 2, result.getIssues().size()); + expected.sizeIs(result.getIssues().size()); + assertConstraints(expected); + } +} From e8379d9b8f86487c2bfefffbe1247d0f6f49ae0d Mon Sep 17 00:00:00 2001 From: Lutz Wrage Date: Fri, 18 Sep 2026 12:11:40 -0400 Subject: [PATCH 2/2] Validate repair event initiator types Register the repair-event check for RepairEvent instead of RecoverEvent and share trigger type validation between both event kinds. This rejects invalid repair initiators and eliminates duplicate recover diagnostics while preserving the accepted initiator types. Fixes #2807. The three focused regression tests and all 296 EMV2 tests pass. --- .../errormodel/validation/ErrorModelValidator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java b/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java index 821454b3d5c..880e4965b0c 100644 --- a/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java +++ b/emv2/org.osate.xtext.aadl2.errormodel/src/org/osate/xtext/aadl2/errormodel/validation/ErrorModelValidator.java @@ -89,6 +89,7 @@ import org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath; import org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint; import org.osate.xtext.aadl2.errormodel.errorModel.RecoverEvent; +import org.osate.xtext.aadl2.errormodel.errorModel.RepairEvent; import org.osate.xtext.aadl2.errormodel.errorModel.ReportingPortReference; import org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement; import org.osate.xtext.aadl2.errormodel.errorModel.TransitionBranch; @@ -284,12 +285,12 @@ public void caseTypeToken(TypeToken tt) { @Check(CheckType.FAST) public void caseRecoverEvent(RecoverEvent recoverEvent) { - checkRecoverEventTriggerType(recoverEvent); + checkEventTriggerType(recoverEvent, recoverEvent.getEventInitiator(), "Recover"); } @Check(CheckType.FAST) - public void caseRepairEvent(RecoverEvent recoverEvent) { - checkRecoverEventTriggerType(recoverEvent); + public void caseRepairEvent(RepairEvent repairEvent) { + checkEventTriggerType(repairEvent, repairEvent.getEventInitiator(), "Repair"); } @Check(CheckType.FAST) @@ -422,12 +423,11 @@ public void caseConnection(Connection conn) { checkConnectionErrorTypes(conn); } - private void checkRecoverEventTriggerType(RecoverEvent recoverEvent) { - EList cl = recoverEvent.getEventInitiator(); - for (NamedElement namedElement : cl) { + private void checkEventTriggerType(ErrorBehaviorEvent event, List eventInitiators, String eventKind) { + for (NamedElement namedElement : eventInitiators) { if (!(namedElement instanceof ModeTransition || namedElement instanceof Port || namedElement instanceof InternalFeature)) { - error(recoverEvent, "Recover event trigger reference '" + namedElement.getName() + error(event, eventKind + " event trigger reference '" + namedElement.getName() + "' is not a port, component internal self event, or mode transition."); } }