blob: a40252570e4444b9301359af9914fe307deb4a66 [file] [log] [blame]
Daniel Willmannd9304742018-10-23 20:29:59 +02001module Misc_Helpers {
2
3/* Try to properly shutdown a testcase.
4 * The reliable method to stop a testcase without running into dynamic
5 * testcase errors due to unconnected ports receiving messages is to call
6 * all component.stop before terminating. However, this can only be called
7 * from the mtc! So in case we want to terminate from a component that is not
8 * the mtc we try to do the next best thing which is calling mtc.stop and
9 * hoping for the best.
10 */
11function f_shutdown(charstring file, integer line, verdicttype verdict := none,
12 charstring text := "") {
13 if (verdict != none) {
14 text := file & ":" & int2str(line) & " : " & text
15 setverdict(verdict, text);
16 }
17
18 log("Stopping testcase execution from ", file, ":", line)
19 if (self == mtc) {
20 /* Properly stop all ports before disconnecting them. This avoids
21 * running into the dynamic testcase error due to messages arriving on
22 * unconnected ports. */
23 all component.stop;
24 }
25 mtc.stop
26}
27
Pau Espin Pedrol6a846bc2020-09-04 13:01:22 +020028function f_addr_is_ipv6(charstring addr) return boolean {
29 for (var integer i := 0; i < lengthof(addr); i := i + 1) {
30 if (addr[i] == ":") {
31 return true;
32 }
33 }
34 return false;
35}
36
Daniel Willmannd9304742018-10-23 20:29:59 +020037}