Skip to content

Commit 844e9a2

Browse files
Sandeep PinnintiGitHub Enterprise
authored andcommitted
Added test case port_multiplicity_04 (#71)
* Added test case port_multiplicity_04 * Delete .vscode files * Improved Test case * Update in test case * Update in test case * Update in test case * PR comments
1 parent ded4dec commit 844e9a2

4 files changed

Lines changed: 99 additions & 0 deletions

File tree

art-comp-test/port_multiplicity.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
{
1818
"path": "tests/port_multiplicity_03"
1919
},
20+
{
21+
"path": "tests/port_multiplicity_04"
22+
},
2023
{
2124
"path": "tests/threads"
2225
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
group: cpp_code_generation
3+
---
4+
This test ensures that the count and sequence of rtg_interfaces align with the defined order of the respective part ports. Additionally, it verifies that any unconnected ports are properly represented with an entry as (nullptr, 0). If an unconnected port is not listed or replaced with nullptr, a runtime exception "Insufficient interface replication" will occur.
5+
6+
In this example, kPort is defined in the Capsule A but is not connected to any other port. The position of kPort in the RTInterfaceDescriptor array is represented by nullptr for the name and 0 for the multiplicity.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
protocol Protocol{
2+
in message();
3+
};
4+
5+
capsule CapsuleA{
6+
7+
service behavior port bPort : Protocol;
8+
service behavior port kPort : Protocol;
9+
behavior port timing: Timing;
10+
service behavior port dPort : Protocol[5];
11+
service behavior port cPort: Protocol[2];
12+
13+
statemachine{
14+
state S;
15+
initial -> S;
16+
};
17+
};
18+
19+
capsule CapsuleB{
20+
21+
service behavior port aPort: Protocol;
22+
service behavior port aPort1~: Protocol;
23+
24+
statemachine{
25+
state S;
26+
initial -> S;
27+
};
28+
};
29+
30+
capsule CapsuleC{
31+
32+
service behavior port aPort~: Protocol;
33+
service behavior port aPort1~: Protocol;
34+
35+
statemachine{
36+
state S;
37+
initial -> S;
38+
};
39+
};
40+
capsule CapsuleD{
41+
42+
service behavior port aPort1~: Protocol;
43+
44+
statemachine{
45+
state S;
46+
initial -> S;
47+
};
48+
};
49+
50+
capsule Top{
51+
52+
part b : CapsuleB;
53+
part d : CapsuleD[5];
54+
part c : CapsuleC[2];
55+
part a : CapsuleA;
56+
57+
connect b.aPort1 with a.bPort;
58+
connect c.aPort1 with a.cPort;
59+
connect d.aPort1 with a.dPort;
60+
connect b.aPort with c.aPort;
61+
62+
statemachine{
63+
state S;
64+
initial -> S `
65+
/** CapsuleA contains 4 non-predfied Ports*/
66+
ASSERT(sizeof(rtg_interfaces_a) / sizeof(rtg_interfaces_a[0]) == 4 , "Expected the size of rtg_interfaces_a to be 4, matching the number of ports in CapsuleA");
67+
68+
ASSERT(rtg_interfaces_a[1].name == nullptr , "Expected unconnected kPort to have nullptr name");
69+
ASSERT(rtg_interfaces_a[1].replication == 0 , "Expected unconnected kPort to have 0 replication");
70+
71+
ASSERT(RTMemoryUtil::strcmp(rtg_interfaces_a[0].name, "bPort") == 0 , "Expected connected aPort to have nullptr name");
72+
ASSERT(rtg_interfaces_a[0].replication == 1 , "Expected connected aPort to have 1 replication");
73+
74+
ASSERT(RTMemoryUtil::strcmp(rtg_interfaces_a[2].name, "dPort") == 0 , "Expected connected dPort to have nullptr name");
75+
ASSERT(rtg_interfaces_a[2].replication == 5 , "Expected connected dPort to have 5 replication");
76+
77+
PASS();
78+
`;
79+
};
80+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let tc = TCF.define(TCF.ART_TO_CPP);
2+
tc.topCapsule = 'Top';
3+
tc.targetProject = 'port_multiplicity_04_target';
4+
tc.prerequisites = [
5+
'../../TestUtils/testlib.tcjs'
6+
];
7+
tc.commonPreface = `
8+
#include "testlib.art.h"
9+
#include <stdio.h>
10+
`;

0 commit comments

Comments
 (0)