Skip to content

Commit eaa0d46

Browse files
Sindhu1143Sivasindhura Mule
authored andcommitted
RIC-866: New test case trigger_guard (#66)
* TestCase for trigger gurads code generation * TestCase for trigger gurads code generation * improved testcase * improved testcase * Addressed PR comments * Addressed PR comments * Added MRT model for capsule trigger guard * Added testcase in testcode workspace --------- Co-authored-by: Sivasindhura Mule <sivasindhura.mule@prod.hclpnp.com>
1 parent 844e9a2 commit eaa0d46

9 files changed

Lines changed: 512 additions & 2 deletions

File tree

art-comp-test/art-comp-test.code-workspace

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
},
4141
{
4242
"path": "tests/capsule_with_purevirtualfunction"
43-
},
43+
},
44+
{
45+
"path": "tests/capsule_trigger_guard"
46+
},
4447
{
4548
"path": "tests/choice_and_junction"
4649
},
@@ -214,7 +217,7 @@
214217
},
215218
{
216219
"path": "tests/transition_inheritance"
217-
},
220+
},
218221
{
219222
"path": "tests/type_descriptor_inheritance"
220223
},
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
protocol P {
2+
/* In Events */
3+
/* Out Events */
4+
out outEvent1(`int`);
5+
out outEvent2(`int`);
6+
};
7+
8+
capsule Top {
9+
/* Ports */
10+
behavior port p : P;
11+
/* Parts */
12+
part c : Cap;
13+
/* Connectors */
14+
connect p with c.p;
15+
/* State Machine */
16+
statemachine {
17+
state S1;
18+
initial -> S1
19+
`
20+
p.outEvent2(2).send();
21+
p.outEvent1(1).send();
22+
`;
23+
};
24+
};
25+
26+
capsule Cap {
27+
[[rt::impl_preface]]
28+
`
29+
#include "testlib.art.h"
30+
`
31+
[[rt::decl]]
32+
`
33+
private: bool check = false;
34+
`
35+
36+
/* Ports */
37+
behavior service port p~ : P;
38+
/* Parts */
39+
/* Connectors */
40+
/* State Machine */
41+
statemachine {
42+
state S1, S2, Done, Error;
43+
initial -> S1;
44+
t1: S1 -> S2 on p.outEvent1[`*rtdata == 1`], p.outEvent2[`*rtdata == 2`] when `!check`
45+
`
46+
std::cout << "transition S1 --> S2" << std::endl;
47+
check = true;
48+
`;
49+
onError: S1 -> Error on p.outEvent1[`*rtdata == 3`]
50+
`
51+
FAIL("onError should not be triggered");
52+
`;
53+
t2: S2 -> Done on p.* [`check`]
54+
`
55+
std::cout << "transition S2->Done" << std::endl;
56+
ASSERT(RTMemoryUtil::strcmp(getMsg()->getSignalName(), "outEvent1") == 0, "Expected outEvent1");
57+
PASS();
58+
`;
59+
};
60+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
group: cpp_code_generation
3+
---
4+
In addition to a transition guard, each trigger of a transition can also have a guard. The transition function is only called if the transition guard and the guard of the matching trigger are both fulfilled.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let tc = TCF.define(TCF.CPP_TRANSFORM);
2+
tc.topCapsule = 'Top';
3+
tc.prerequisites = ["../../TestUtils/testlib.tcjs"];
4+
tc.targetFolder = 'capsule_trigger_guard_target';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>capsule_trigger_guard</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.ibm.xtools.umldt.core.internal.builders.UMLDevelopmentBuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
</buildSpec>
15+
<natures>
16+
<nature>com.ibm.xtools.umldt.core.internal.natures.MDDProjectNature</nature>
17+
</natures>
18+
</projectDescription>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
active.config=Top.tcjs
2+
eclipse.preferences.version=1
3+
top.level.only=true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

art-comp-test/testsEmx/capsule_trigger_guard/CapsuleTriggerGuard.emx

Lines changed: 404 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
let tc = TCF.define(TCF.CPP_TRANSFORM);
2+
tc.sources = [
3+
'platform:/resource/capsule_trigger_guard/CapsuleTriggerGuard.emx#_WZKo0XygEe-ybOKRD6Tr-A',
4+
];
5+
tc.prerequisites = [
6+
'platform:/resource/TestRTSUtils/testRTSlib.tcjs',
7+
];
8+
tc.compilationMakeType = MakeType.GNU_make;
9+
tc.createTargetProject = true;
10+
tc.targetConfiguration = 'WinT.x64-MinGw-12.2.0';
11+
tc.targetProject = 'capsule_trigger_guard_target';
12+
tc.topCapsule = 'platform:/resource/capsule_trigger_guard/CapsuleTriggerGuard.emx#_WZLP4nygEe-ybOKRD6Tr-A';

0 commit comments

Comments
 (0)