TTCN3_SA_9_TD.script 171 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
.******************************************************************************
balaskoa's avatar
balaskoa committed
2
.* Copyright (c) 2000-2018 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
.* All rights reserved. This program and the accompanying materials
4
.* are made available under the terms of the Eclipse Public License v2.0
Elemer Lelik's avatar
Elemer Lelik committed
5
.* which accompanies this distribution, and is available at
6
.* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Elemer Lelik's avatar
Elemer Lelik committed
7
8
9
10
11
12
13
14
15
16
17
18
19
.*
.* Contributors:
.*   Balasko, Jeno
.*   Delic, Adam
.*   Harai, Tibor
.*   Kovacs, Ferenc
.*   Pandi, Krisztian
.*   Raduly, Csaba
.*   Szabados, Kristof
.*   Szabo, Janos Zoltan – initial implementation
.*   Szalai, Endre
.*   Szalai, Gabor
.*
Elemer Lelik's avatar
Elemer Lelik committed
20
21
22
23
24
25
26
27
28
29
.******************************************************************************/
:text.
:lang eng.

.* EDML webpage:       http://cpi.ericsson.se/dwaxe/
.* EDML2PDF converter: http://dwaxe.ericsson.se/x2pdf
.* EDML user guide:    http://www.lmc.ericsson.se/~lmcmarg/isit/edml_ug.html

.* Document header information
:docname.Test Description
Elemer Lelik's avatar
Elemer Lelik committed
30
:docno.xx/152 91-CRL 113 200/5 Uen
Elemer Lelik's avatar
Elemer Lelik committed
31
:rev.A
Elemer Lelik's avatar
Elemer Lelik committed
32
:date.2015-04-27
Elemer Lelik's avatar
Elemer Lelik committed
33

Elemer Lelik's avatar
Elemer Lelik committed
34
:prep.ETH/XZ Jeno Balasko
Elemer Lelik's avatar
Elemer Lelik committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
:appr.ETH/XZ (Gyula Koos)
:checked.ETHGRY

:title.Test description of the TTCN-3 Semantic Analyzer: Other requirements
:contents level=2.
.*---------------------------------------------------------------------*
:h1.Introduction
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2.Revision history
.*---------------------------------------------------------------------*
:xmp tab=2.
REV   DATE         PREPARED   CHANGE
__________________________________________________
PA1   2005-02-19   ETHGASZ    New document for TITAN R6
A     2005-03-18   ETHGASZ    Approved after review
B     2005-08-16   ETIBHRA    New req. added (SA-9/18,19,20)
C     2007-03-06   EJNOSZA    Updates for TITAN R7A (expected error messages for identifier overloading)
D     2007-06-08   EJNOSZA    Updates for TITAN R7B (expected error messages for identifier overloading)
E     2008-10-01   EKRISZA    Updates for TITAN R7E
F     2010-01-18   EKRISZA    Updated for TITAN R8C
K     2011-10-10   EKRISZA    Updated for TITAN R8H
Elemer Lelik's avatar
Elemer Lelik committed
57
58
59
60
A     2011-12-12   EKRISZA    Updated for release
A     2012-06-27   EFERKOV    Updated for release
A     2013-01-17   EKRIPND    Updated for release
A	  2015-04-27   ETHBAAT    Updated for release
Elemer Lelik's avatar
Elemer Lelik committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
:exmp.

.*---------------------------------------------------------------------*
:h2.Purpose
.*---------------------------------------------------------------------*
The purpose of this Test Description is to define and describe the function
test activity for the Semantic Analyser functionality of the TTCN-3 compiler:
:nl.SA-9/x: Other requirements.
:p.The specification of the test cases can be found in this document.
.*---------------------------------------------------------------------*
:h1.Test environment
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h2.Hardware
.*---------------------------------------------------------------------*
No specific hardware requirement.
.*---------------------------------------------------------------------*
:h2.Software
.*---------------------------------------------------------------------*
Tests shall be carried out on the following platforms:
:list.
:li D='1.'.Solaris 8 (Sun OS 5.8) (gcc 3.0.4)
:li D='2.'.SUSE Linux Enterprise server 8 (2.4.19-4GB) (gcc 3.2)
:li D='3.'.CYGWIN_NT-5.0 (Cygwin DLL: 1.5.12) on Windows 2000 (gcc 3.3.3)
:elist.
.*---------------------------------------------------------------------*
:h2.Configuration
.*---------------------------------------------------------------------*
The test environment had been setup in CVS. The tester program is stored in:
:nl.TTCNv3/function_test/Tools/SAtester.pl
:nl.Test cases are stored with extension .script in the directory:
:nl.TTCNv3/function_test/Semantic_Analyser/
.*---------------------------------------------------------------------*
:h2.Installation
.*---------------------------------------------------------------------*
Install proper TITAN binaries on the used platforms and make sure that
your environment settings are correct:
:list.
:li D='1.'.TTCN3_DIR is set
:li D='2.'.$TTCN3_DIR/bin is added to the PATH variable
:li D='3.'.$TTCN3_DIR/lib is added to the LD_LIBRARY_PATH variable
:li D='4.'.Perl 5.6.0 or higher is available on the platform
:li D='5.'.Create a symlink to your Perl binary into the directory where the
test cases are stored:
:nl.ln -s <your Perl> perl
:elist.
.*---------------------------------------------------------------------*
:h2.Test Tools
.*---------------------------------------------------------------------*
A tester program had been written in Perl especially for the Semantic Analyser
tests. For the list of command line parameters, type 'SAtester.pl -help', for the
complete documentation, type 'SAtester.pl -doc'.
:p.Test cases are specified in the Test Description documents in EDML format.
The tester program parses these files and generates the TTCN-3/ASN.1 modules, then
calls the compiler to compile them. The result printout is then matched against
different patterns to be able to set the verdict. Test cases contain not only
the source modules, but the patterns as well.
:p.The tester program allows one-by-one execution of test cases and batched
execution as well.
:p.NOTE: the tester program requires Perl 5.6.0 or higher.
.*---------------------------------------------------------------------*
:h2.Test cases
.*---------------------------------------------------------------------*
.*---------------------------------------------------------------------*
:h3.Module Parameters->Redeclaration of a module parameter SA-9/1
.*---------------------------------------------------------------------*
Requirement: Redeclaration of a module parameter.
:nl.Explanation:
:nl.Redefinition of the module parameter is not allowed.
:nl.
.*---------------------------------------------------------------------*
:h4.Module Parameters->Redeclaration of a module parameter with a different type
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Module Parameters->Redeclaration of a module parameter with a different type>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   modulepar {
      integer MyTSP1;
      integer MyTSP2 := 10;
      boolean MyTSP1 := false;
      boolean MyTSP2
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 2>
(?im)\berror\b.+?duplicate.+?definition.+?MyTSP
<END_RESULT>
<RESULT IF_PASS COUNT 2>
(?im)\bnote\b.+?previous.+?definition
<END_RESULT>
<RESULT IF_PASS COUNT 2>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Module Parameters->Redeclaration of a module parameter in a different group
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Module Parameters->Redeclaration of a module parameter in a different group>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   modulepar {
      integer MyTSP1;
      integer MyTSP2 := 10;
   }
   modulepar {
      boolean MyTSP1 := false;
      boolean MyTSP2
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 2>
(?im)\berror\b.+?duplicate.+?definition.+?MyTSP
<END_RESULT>
<RESULT IF_PASS COUNT 2>
(?im)\bnote\b.+?previous.+?definition
<END_RESULT>
<RESULT IF_PASS COUNT 2>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h3.Signatures->Duplicate exception type in a signature SA-9/2
.*---------------------------------------------------------------------*
Requirement: Duplicate exception type in a signature.
:nl.Explanation:
:nl.One or more exception type is listed in a signature more than once.
.*---------------------------------------------------------------------*
:h4.Signatures->Duplicate exception type in a signature
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Signatures->Duplicate exception type in a signature>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   signature s() noblock
      exception (
      bitstring, boolean, charstring, universal charstring,
      integer, octetstring, objid, hexstring, verdicttype, float,
      bitstring, boolean, charstring, universal charstring,
      integer, octetstring, objid, hexstring, verdicttype, float);
}
<END_MODULE>
<RESULT IF_PASS COUNT 10>
(?im)\berror\b.+?duplicate.+?type
<END_RESULT>
<RESULT IF_PASS COUNT 10>
(?im)\bnote\b.+?already.+?here
<END_RESULT>
<RESULT IF_PASS COUNT 10>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.Signatures-> 'all' shall not be mixed with additional names SA-9/2
.*---------------------------------------------------------------------*
Requirement: 'all' shall not be mixed with additional names in one list.
:nl.Explanation:
:nl.Becasue the 'all' is not supported currently, it can not be tested.
.*---------------------------------------------------------------------*
:h3.Import-> Duplicated module reference in import statements SA-9/3
.*---------------------------------------------------------------------*
Requirement: Duplicated module reference in import statements.
:nl.Explanation:
:nl.A module name is listed more than once to import from.
.*---------------------------------------------------------------------*
:h4.Import->Duplicated module reference in import statements
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Import->Duplicated module reference in import statements>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
  import from ModuleB all;
  import from ModuleB all;
}
<END_MODULE>
<MODULE TTCN ModuleB ModuleB.ttcn>
module ModuleB {
  type integer Myint;
}
<END_MODULE>
<RESULT IF_PASS NEGATIVE>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)Notify: File `ModuleA.hh' was generated.
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h3.No signatures in the test suite when using 'all' in port definition SA-9/4
.*---------------------------------------------------------------------*
Requirement: No signatures in the test suite when using 'all' in port
definition.
:nl.Explanation:Using the all keyword in one of the lists associated to a
:nl.port type allows all of signatures defined in the module to be
:nl.received and sent over port. SA shall detect the cases when no
:nl.signatures are defined in the test suite, but receive-like port
:nl.operations (e.g. getcall, getreply, catch) are used.
:nl.NOTE:Because the 'all' is not supported currently, it can not be tested.
:nl.NOTE:TR698
.*---------------------------------------------------------------------*
:h4.No signatures in the test suite when using 'all' in port definition
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - No signatures in the test suite when using 'all' in port definition>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType1 procedure { inout all}
   type component MyComp {
      port MyPortType1 MyPort1;
   }
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_FAIL POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h3.Communication operations->Port operation when no ports defined 9/5
.*---------------------------------------------------------------------*
Requirement: Port operation when no ports defined.
:nl.Explanation:
:nl.Port operations on a component that has no ports defined shall be
:nl.detected.
.*---------------------------------------------------------------------*
:h4.Communication operations->Port operation when no ports defined
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Communication operations->Port operation when no ports defined>

<COMPILEGCC>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   signature MySig() noblock;
   type component MyComp {
      var integer MyVar;
      var MyComp MyWar1;
   }
   // TR 699: Port and timer operation when no ports or timer defined
	altstep MyAltstep() runs on MyComp {
      [] any port.receive { setverdict(fail); }
      [] any port.trigger { setverdict(fail); }
      [] any port.getcall { setverdict(fail); }
      [] any port.getreply { setverdict(fail); }
      [] any port.catch { setverdict(fail); }
      [] any port.check(-> sender MyWar1) { setverdict(fail); }
      [] any port.check(receive) { setverdict(fail); }
      [] any port.check(getcall) { setverdict(fail); }
      [] any port.check(getreply) { setverdict(fail); }
      [] any port.check(catch) { setverdict(fail); }
      [else] {
         all port.stop;
         all port.start;
         all port.clear;
   all timer.stop;
      }
   }
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_FAIL POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h3.Timer operations when no timers defined SA-9/6
.*---------------------------------------------------------------------*
Requirement: Timer operations when no timers defined.
:nl.Explanation:
:nl.Timer operations shall be handled correctly if no timers are defined.
.*---------------------------------------------------------------------*
:h4.Timer operations when no timers defined
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Timer operations when no timers defined>

<COMPILEGCC>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type component MyComp {}
   function MyFunc1() runs on MyComp {
      // valid
      all timer.stop;
      // TR 699: Port and timer operation when no ports or timer defined
		// would block forever
      any timer.timeout;
      if (any timer.running) { setverdict(fail); }
      else { setverdict(pass); }
   }
   testcase MyTC() runs on MyComp {
      MyFunc1();
   }
}
<END_MODULE>
<RESULT IF_FAIL COUNT 3>
(?is)\berror:
<END_RESULT>
<RESULT IF_FAIL POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.Import-> Import from the same module SA-9/7
.*---------------------------------------------------------------------*
Requirement: Import from the same module.
:nl.Explanation:
:nl.A module cannot import from itself.
.*---------------------------------------------------------------------*
:h4.Import->Import from the same module
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Import->Import from the same module>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
  import from ModuleA all;
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?im)\berror\b.+?\bimport\b.+?\bitself\b
<END_RESULT>
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.

.*---------------------------------------------------------------------*
:h3.Functions->Return value SA-9/8
.*---------------------------------------------------------------------*
Requirement: Functions->Return value.
:nl.Explanation:
:nl.The keyword return, when used in the body of the function with a
:nl.return type defined in its header, always shall be followed by a value,
:nl.a constant or variable reference or an expression presenting the return
:nl.value.
.*---------------------------------------------------------------------*
:h4.Functions->Return value if no return type defined
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Functions->Return value if no return type defined>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   // no return value, but try to return an actual value
   // catched by the parser curently
   function MyFunc1() { if(true) {return '11A7'O;}}
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?im)\berror\b.+?function.+?not.+?have.+?return.+?type
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->Missing return value, but return type defined
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Functions->Missing return value, but return type defined>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   // missing return value
   // catched by the parser
   function MyFunc1() return float {if(true) {return;}}
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?im)\berror\b.+?missing.+?return.+?value
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\berror.+?control.+?might.+?leave.+?without.+?reaching.+?return.+?statement
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->Missing return value, but return type defined indirect case 1
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->Missing return value, but return type defined indirect case 1>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   function MyFunc1() {return;}
   function MyFunc2(integer par) return integer {return (par + 10);}
   function MyFunc3() return float {
      if(true) {return MyFunc1();}
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror.+?control.+?might.+?leave.+?without.+?reaching.+?return.+?statement
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bexpected\b.+?\bfunction\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->Missing return value, but return type defined indirect case 2
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->Missing return value, but return type defined indirect case 2>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   function MyFunc1() {return;}
   function MyFunc2(integer par) return integer {return (par + 10);}
   function MyFunc4() return float {
      if(true) {return int2float( MyFunc2(MyFunc1() ));}
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror.+?control.+?might.+?leave.+?without.+?reaching.+?return.+?statement
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bexpected\b.+?\bfunction\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->Missing return value, but return type defined indirect case 3
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Functions->Missing return value, but return type defined indirect case 3>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   function MyFunc1() {return;}
   control {
      // void return value is not allowed in expression
      var integer MyVar := 666 + MyFunc1() - 666;
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bexpected\b.+?\bfunction\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h3.Functions->runs on clause SA-9/9
.*---------------------------------------------------------------------*
Requirement: Functions->runs on clause.
:nl.Explanation:
:nl.A function without runs on clause shall never invoke a function or
:nl.altstep or activate an altstep as default with a runs on clause locally.
:nl.Functions started by using the start test component operation shall
:nl.always have a runs on clause.
:nl.Functions used in the control part of a TTCN-3 module shall have no
:nl.runs on clause.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, referencing to a functions with runs on
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->runs on clause, referencing to a functions with runs on>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   function MyFunc_comp() runs on MyComp {return;}
   function NastyFunc01() {
      if (true) { MyFunc_comp(); }
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bcannot\b.+?\bcall\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, referencing to an altstep with runs on
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Functions->runs on clause, referencing to an altstep with runs on>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   altstep MyAltstep_comp() runs on MyComp { [] MyPort.trigger {} }
   function NastyFunc02(inout MyPortType loc_port) {
      if (true) {
         alt {
            [] loc_port.trigger {}
            [] MyAltstep_comp();
         }
      }
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bcannot\b.+?\bcall\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, referencing to a func with runs on,indirect call
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->runs on clause, referencing to a func with runs on,indirect call>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   function MyFunc_comp2() runs on MyComp return integer {return 0;}
   function MyCoolFunction1 (integer par) return integer {return par;}
   function NastyFunc03() return float {
      if (true) { return int2float( MyCoolFunction1(MyFunc_comp2()) ); }
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror.+?control.+?might.+?leave.+?without.+?reaching.+?return.+?statement
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bcannot\b.+?\bcall\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, default activation/deactivation
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->runs on clause, default activation/deactivation>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   altstep MyAltstep_comp() runs on MyComp { [] MyPort.trigger {} }
   function NastyFunc04() {
      var default MyDef := activate(MyAltstep_comp());
      deactivate(MyDef);
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bcannot\b.+?\bactivate\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, start operations
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->runs on clause, start operations>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   function MyFunc_comp3(integer par) runs on MyComp {}
   function MyFunc_nocomp() {}
   function MyFunc_nocomp2(integer par) return integer { return 0; }
   function MyFunc1() {
      var MyComp MyComponent := MyComp.create;
      var MyComp MyComponent2 := MyComp.create;
      MyComponent.start(MyFunc_nocomp());
      // this should be ok however
      MyComponent2.start(MyFunc_comp3(MyFunc_nocomp2(666)));
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bcannot\b.+?\bstarted\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>

:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, function called from a template
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - Functions->runs on clause, function called from a template>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   function MyFunc_comp2() runs on MyComp return integer {return 0;}
   template integer MyTemplate := MyFunc_comp2();
}
<END_MODULE>
<RESULT IF_PASS COUNT 1>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 1>
(?is)\bcannot\b.+?\bcall\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h4.Functions->runs on clause, functions in the control part
.*---------------------------------------------------------------------*
:xmp tab=0.

<TC - Functions->runs on clause, functions in the control part>

<COMPILE>
<VERDICT_LEAF PASS>
<MODULE TTCN ModuleA ModuleA.ttcn>
module ModuleA {
   type port MyPortType message { inout integer }
   type component MyComp { port MyPortType MyPort }
   function MyFunc_comp() runs on MyComp {return;}
   function MyFunc_comp2() runs on MyComp return integer {return 0;}
   function MyCoolFunction1 (integer par) return integer {return par;}
   control {
      var integer MyVar;
      if (true) {
         MyFunc_comp();
         MyVar := MyCoolFunction1(MyFunc_comp2());
      }
   }
}
<END_MODULE>
<RESULT IF_PASS COUNT 2>
(?is)\berror:
<END_RESULT>
<RESULT IF_PASS COUNT 2>
(?is)\bcannot\b.+?\bcall\b
<END_RESULT>
<RESULT IF_PASS POSITIVE>
(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b
<END_RESULT>
<END_TC>
:exmp.

834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.*---------------------------------------------------------------------*
:h3.Functions->invoking functions from specific places
.*---------------------------------------------------------------------*
Requirement: Functions->invoking functions from specific places (16.1.4)
:nl.Explanation:
:nl.Invoking functions and some other features (e.g. get state of port or components)
:nl.may have side effects or different return-value
:nl.and it's can create unexpected changes on the actual snapshot.
:nl.In these cases the compiler gives warnings.
.*---------------------------------------------------------------------*
:h4.TTCN3::Value::chk_expr_immutability: V_REFD->A_FUNCTION_RVAL
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - TTCN3::Value::chk_expr_immutability: V_REFD->A_FUNCTION_RVAL>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN M M.ttcn>
module M {
	type component C {};
	function FB() return boolean { return true; }
	testcase T() runs on C {
		timer t := 5.0; t.start;
		var boolean VB := FB();
		alt {
			[VB] t.timeout {}
			[FB()] t.timeout {}
		}
	}
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?im)\bwarning\b.+?\bFunction invocation\b.+?\bmay change the actual snapshot\b
<END_RESULT>
<END_TC>
:exmp.

.*---------------------------------------------------------------------*
:h4.TTCN3::Value::chk_expr_immutability: V_REFD->A_EXT_FUNCTION_RVAL
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - TTCN3::Value::chk_expr_immutability: V_REFD->A_EXT_FUNCTION_RVAL>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN M M.ttcn>
module M {
	type component C {};
	external function FB() return boolean;
	testcase T() runs on C {
		timer t := 5.0; t.start;
		var boolean VB := FB();
		alt {
			[VB] t.timeout {}	// OK
			[FB()] t.timeout {}	// NOT OK
		}
	}
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?im)\bwarning\b.+?\bFunction invocation\b.+?\bmay change the actual snapshot\b
<END_RESULT>
<END_TC>
:exmp.

.*---------------------------------------------------------------------*
:h4.TTCN3::Value::chk_expr_immutability: V_REFD->A_PAR_VAL_IN->FUZZY_EVAL
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - TTCN3::Value::chk_expr_immutability: V_REFD->A_PAR_VAL_IN->FUZZY_EVAL>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN M M.ttcn>
module M {
	type component C {};
	testcase T(in @fuzzy boolean FFP_B) runs on C {
		timer t := 5.0; t.start;
		var boolean VB := FFP_B;
		alt {
			[VB] t.timeout {}		// OK
			[FFP_B] t.timeout {}	// NOT OK
		}
	}
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?im)\bwarning\b.+?\bFuzzy parameter\b.+?\bmay change \(during\) the actual snapshot\b
<END_RESULT>
<END_TC>
:exmp.

.*---------------------------------------------------------------------*
:h4.TTCN3::Value::chk_expr_immutability: V_EXPR->OPTYPE_RND
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - TTCN3::Value::chk_expr_immutability: V_EXPR->OPTYPE_RND>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN M M.ttcn>
module M {
	type component C {};
	testcase T() runs on C {
		timer t := 5.0; t.start;
		var float VF := rnd();
		alt {
			[VF < 1.0]  t.timeout {}	// OK
			[rnd() < 1.0]  t.timeout {}	// NOT OK
		}
	}
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?im)\bwarning\b.+?\bRandom number generation\b.+?\bchange the actual snapshot\b
<END_RESULT>
<END_TC>
:exmp.

.*---------------------------------------------------------------------*
:h4.TTCN3::Value::chk_expr_immutability: V_EXPR->OPTYPE_RNDWITHVAL
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - TTCN3::Value::chk_expr_immutability: V_EXPR->OPTYPE_RNDWITHVAL>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN M M.ttcn>
module M {
	type component C {};
	testcase T() runs on C {
		timer t := 5.0; t.start;
		var float VF := rnd(2.0);
		alt {
			[VF < 1.0]  t.timeout {}		// OK
			[rnd(2.0) < 1.0]  t.timeout {}	// NOT OK
		}
	}
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?im)\bwarning\b.+?\bRandom number generation\b.+?\bchange the actual snapshot\b
<END_RESULT>
<END_TC>
:exmp.

.*---------------------------------------------------------------------*
:h4.TTCN3::Value::chk_expr_immutability: V_EXPR->OPTYPE_NOT
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC - TTCN3::Value::chk_expr_immutability: V_EXPR->OPTYPE_NOT>
<COMPILE>
<VERDICT_LEAF FAIL>
<MODULE TTCN M M.ttcn>
module M {
	type component C {};
	function FB() return boolean { return true; }
	testcase T() runs on C {
		timer t := 5.0; t.start;
		var boolean VB := FB();
		alt {
			[not VB]  t.timeout {}		// OK
			[not FB()]  t.timeout {}	// NOT OK
		}
	}
}
<END_MODULE>
<RESULT IF_FAIL COUNT 1>
(?im)\bwarning\b.+?\bFunction invocation\b.+?\bmay change the actual snapshot\b
<END_RESULT>
<END_TC>
:exmp.
For faster browsing, not all history is shown. View entire blame