File: inres.mp

package info (click to toggle)
ttcn3parser 20050130-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 396 kB
  • ctags: 25
  • sloc: python: 1,126; makefile: 11
file content (538 lines) | stat: -rw-r--r-- 15,652 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
module InresExample1 ( ISDUType TestsuitePar ) {


  /* *** General Type Definitions *** */
  type integer ISDUType (-infinity .. infinity);
  type enumerated Sequencenumber { zero(1), one(2) };
  type enumerated IPDUType { CR(1), CC(2), DR(3), DT(4), AK(5) };


  /* *** Module Constants *** */
  const Sequencenumber TestSuiteConst := one;


  /* *** Configuration Definitions *** */
  group ConfigurationDefinitions {


    /* *** Port Type Definitions *** */
    type port PCO_Type1 message {
      in ICONconf, IDISind;	/* received from SUT */
      out ICONconf, IDATreq, IDISreq; /* send to SUT */
    } with { display "PCO Type, role := UT"; }

    type port PCO_Type2 message {
      in MDATind;		/* received from SUT */
      out MDATreq;		/* send to SUT */
    } with { display "PCO Type, role = LT"; }


    /* *** MTC Type Definition (is equal to Test System Interface) *** */
    type component MTCType {
      port PCO_Type1 ISAP1;
      port PCO_Type2 MSAP2;
    };

  } /* End ConfigurationDefinitions */


  /* *** ASP Type Definitions for Medium Interface */
  group MediumServiceASPTypes {

    type record MDATreq {
      IPDUType iPDUType1,
	Sequencenumber sequencenumber2,
	ISDUType iSDUType3
	};

    type record MDATind {
      IPDUType iPDUType1,
	Sequencenumber sequencenumber2,
	ISDUType iSDUType3
	};

  } with { display "ASP Type Definitions"; } /* End MediumServiceASPTypes */


  /* *** ASP Type Definitions for Inres Interface (Initiator side) *** */
  group InitiatorSideInresASPTypes {

    type record ICONreq {};
    type record IDATreq { ISDUType iSDUType1 };
    type record IDISreq {};
    type record ICONconf {};
    type record IDISind {};

  } with { display "ASP Type Definitions"; } /* End InitiatorSideInresASPTypes */


  /* *** Template Definitions *** */
  group TemplateDefinitions {

    template IDATreq DataRequest (ISDUType Par1) := { iSDUType1 := Par1 };

    template MDATreq Medium_Connection_Confirmation := {
      iPDUType1 := CC,
      sequencenumber2 := ?,
      iSDUType3 := ?
    };

    template MDATind Medium_Connection_Request := {
      iPDUType1 := CR,
      sequencenumber2 := ?,
      iSDUType3 := ?
    };

    template MDATind Medium_Data_Transfer := {
      iPDUType1 := DT,
      sequencenumber2 := TestSuiteConst,
      iSDUType3 := TestSuitePar
    };

    template MDATind Medium_Disconnection_Request := {
      iPDUType1 := DR,
      sequencenumber2 := ?,
      iSDUType3 := ?
    };

    template MDATreq cmi_synch1 := {
      iPDUType1 := AK,
      sequencenumber2 := one,
      iSDUType3 := 55
    };

  } /* End TemplateDefinitions */

  /* ** test step used as default for the following test cases *** */
  teststep OtherwiseFail() {
  []	ISAP1.receive {
    verdict.set(fail);
    stop;
  }
  []	MSAP2.receive {
    verdict.set(fail);
    stop;
  }
  } with { display "default"; }

  /* ** Test step **/

  teststep ReceiveIDISind (verdicttype result) { 
  []	ISAP1.receive( IDISind : { } ) {
    verdict.set(result);
  }
  } with { display "test step"; } /* End ReceiveIDISind */


  /* The following TTCN-3 test case is a one-to-one translation of the
     test case mi_synch1 in the example test suite, it is not the
     optimal way to 'program' TTCN-3, but shows at least how the
     result of a direct translation or TTCN-2 test cases into TTCN-3
     test cases may look. */

  group Transmission { 
    group MultileInstances { 
      group SystemLevelMSC {
	/* The nested grouping is only done to be 100% consistent with
           the original TTCN2 testsuite */

	testcase mi_synch1 () runs on MTCType {

	  var default def := activate(OtherwiseFail()); /* Default activation */
	  ISAP1.send( ICONreq:{} ); /* Inline template definition */
	  alt {
	  [] MSAP2.receive( Medium_Connection_Request() ) { /* use of a template */
	    
	    MSAP2.send( MDATreq:Medium_Connection_Confirmation() ); /*optional template type*/
	    alt {
	    [] ISAP1.receive ( ICONconf:{} ) {
	      ISAP1.send ( Data_Request(TestSuitePar) );
	      alt {
	      [] MSAP2.receive ( Medium_Data_Transfer() ) {
		MSAP2.send ( MDATreq:cmi_synch1() );
		ISAP1.send ( IDISreq:{} );
		alt {
		[] ISAP1.receive (IDISind:{} ) {
		  MSAP2.receive (Medium_Disconnection_Request() );
		  verdict.set(pass);
		  stop;
		}
		[] MSAP2.receive ( Medium_Disconnection_Request() ) {
		  ISAP1.receive( IDISind:{} );
		  verdict.set(pass);
		  stop;
		}
		[] MSAP2.receive ( Medium_Data_Transfer() ) {
		  verdict.set(inconclusive);
		  stop;
		}
		}
	      }
	      [] ISAP1.receive( IDISind:{} ) {
		verdict.set(inconclusive);
		stop;
	      }
	      }
	    }
	    [] MSAP2.receive( MDATind:Medium_Connection_Request()) {
	      verdict.set(inconclusive);
	      stop;
	    }
	    [] ISAP1.receive( IDISind:{} ) {
	      verdict.set(inconclusive);
	      stop;
	    }
	    }
	  }
	  [] ISAP1.receive( IDISind:{} ) {
	    verdict.set(inconclusive);
	    stop;
	  }
	  }
	} /* End testcase mi_synch1 */

      } 
    } 
  } /* End groups SystemLevelMSC, MultipleInstances and Transmission */

  /* Although this one-to-one translation looks a little bit clumsy,
     it is 'readable' which is a great advantage compared to the
     TTCN2/MP Form. */

  /* This is a slight transformation of the previous example. It makes
     use of the 'sequential' character of TTCN-3. The stop operation
     is not copied to all branches of the 'behaviour tree'. Instead it
     is only executed at the end of the test case. Furthermore, the
     verdict is initialized with the verdict pass. During the test
     execution it can be overwritten by inconclusive or, in the
     default, by fail. The places where a pass has been assigned
     before are indicated by comments. The result looks much more
     readable, maybe because lots of the curly parenthesis have been
     deleted. */

  testcase mi_synch2 () runs on MTCType {

    var default def := activate(OtherwiseFail()); /* Default activation */
    ISAP1.send( ICONreq:{} );
    verdict.set(pass);
    alt {
    [] MSAP2.receive( Medium_Connection_Request() ) {
      MSAP2.send ( MDATreq:Medium_Connection_Confirmation() );
      alt {
      [] ISAP1.receive ( ICONconf:{} ) {
	ISAP1.send ( Data_Request(TestSuitePar) );
	alt {
	[] MSAP2.receive ( Medium_Data_Transfer() ) {
	  MSAP2.send ( MDATreq:cmi_synch1() );
	  ISAP1.send ( IDISreq:{} );
	  alt {
	  [] ISAP1.receive (IDISind:{} ) { /* PASS */
	    MSAP2.receive ( Medium_Disconnection_Request() );	
	  }
	  [] MSAP2.receive ( Medium_Disconnection_Request() ) {
	    ISAP1.receive( IDISind:{} ); /* PASS */
	  }
	  [] MSAP2.receive ( Medium_Data_Transfer() ) {
	    verdict.set(inconclusive);
	  }
	  }
	}
	[] ISAP1.receive( IDISind:{} ) {
	  verdict.set(inconclusive);
	}
	}
      }
      [] MSAP2.receive( MDATind:Medium_Connection_Request()) {
	verdict.set(inconclusive);
      }
      [] ISAP1.receive( IDISind:{} ) {
	verdict.set(inconclusive);
      }
      }
    }
    [] ISAP1.receive( IDISind:{} ) {
      verdict.set(inconclusive);
    }
    }
    stop;
  } /* End testcase mi_synch2 */




  /* This is a slight transformation of the previous example. It shows
     the usage of test steps. A test step is a special
     function which allows to extend the alternative
     construct by adding new alternatives. It is comparable to the
     TTCN-2 feature of tree attachment in sets of alternatives. */

  testcase mi_synch3 () runs on MTCType {
    var default def := activate(OtherwiseFail()); /* Default activation */
    ISAP1.send( ICONreq:{} );
    verdict.set(pass);
    alt {
    [] MSAP2.receive( Medium_Connection_Request() ) {
      MSAP2.send ( MDATreq:Medium_Connection_Confirmation() );
      alt {
      [] ISAP1.receive ( ICONconf:{} ) {
	ISAP1.send ( Data_Request(TestSuitePar) );
	alt {
	[] MSAP2.receive ( Medium_Data_Transfer() ) {
	  MSAP2.send ( MDATreq:cmi_synch1() );
	  ISAP1.send ( IDISreq:{} );
	  alt {
	  [] ISAP1.receive (IDISind:{} ) { 		/* PASS */
	    MSAP2.receive ( Medium_Disconnection_Request() );
	  }
	  [] MSAP2.receive ( Medium_Disconnection_Request() ) {
	    ReceiveIDISind(pass); /* direct call of test step */
	  }
	  [] MSAP2.receive ( Medium_Data_Transfer() ) {
	    verdict.set(inconclusive);
	  }
	  }
	}
	[] ReceiveIDISind(inconclusive); /* use of test step */
	}
      }
      [] MSAP2.receive( MDATind:Medium_Connection_Request() ) {
	verdict.set(inconclusive);
      }
      [] ReceiveIDISind(inconclusive);
      }
    }
    [] ReceiveIDISind(inconclusive);
    }
    stop;
  } /* End testcase mi_synch3 */



  /* All previous examples kept the TTCN-2 tree structure. But, TTCN-3
     allows also a pure sequential style which is more in line with
     most programming languages. */


  testcase mi_synch4 () runs on MTCType {
    var default def := activate(OtherwiseFail()); /* Default activation */

    ISAP1.send( ICONreq:{} );	/* ONE */
    
    alt {
    [] MSAP2.receive( Medium_Connection_Request() ) {}; /* response to ONE */
    [] ISAP1.receive( IDISind:{} ) { /* not expected response */
      verdict.set(inconclusive);
      stop;
    }
    }

    MSAP2.send ( MDATreq:Medium_Connection_Confirmation() ); /* TWO */

    alt {			
    [] ISAP1.receive ( ICONconf:{} ) {};	/* response to TWO */
    [] MSAP2.receive( MDATind:Medium_Connection_Request()) { /* not expected response */
      verdict.set(inconclusive);
      stop;
    }
    [] ISAP1.receive( IDISind:{} ) { /* not expected response */
      verdict.set(inconclusive);
      stop;
    }
    }

    ISAP1.send ( Data_Request(TestSuitePar) ); /* THREE */

    alt {
    [] MSAP2.receive ( Medium_Data_Transfer() ) {}; /* response to THREE */
    [] ISAP1.receive ( IDISind:{} ) { /* not expected response */
      verdict.set(inconclusive);
      stop;
    }
    }

    MSAP2.send ( MDATreq:cmi_synch1() ); /* FOUR */
    ISAP1.send ( IDISreq:{} );	/* FIVE */

    alt {
    [] ISAP1.receive ( IDISind:{} ) { /* the two responses to FIVE */
      MSAP2.receive ( Medium_Disconnection_Request() );
    }

    [] MSAP2.receive ( Medium_Disconnection_Request() ) { /* other order of responses */
      ISAP1.receive ( IDISind:{} );
    }	
	
    [] MSAP2.receive ( Medium_Data_Transfer() ) {
      verdict.set(inconclusive);
      stop;
    }
    }
    
    verdict.set(pass);
    stop;
    
  } /* End testcase mi_synch4 */


  /* At the first glance this test case description looks very strange
     because we (at least me) are familiar with the TTCN-2 tree
     representation. However, after a second look, you will see some
     advantages. For example, the alternatives at each stage of test
     execution are very clear and you can read the test case from top
     to button. There is no need to compare different levels of
     indentation in order to examine the alternatives. Note, this is a
     toy example, developed from another toy example. Further comments
     (e.g., about reached system states), structuring in test steps or
     a different style of formatting may increase the readability
     considerably. */

  /* A further transformation of the previous example. For readability
     purposes we may decide to hide the inconclusive cases in the
     default behaviour. The new default description would then look
     like: */

  teststep DefaultWithInconclusives() {

    /* INCONCLUSIVE CASES */

  [] MSAP2.receive( MDATind:Medium_Connection_Request()) {
    verdict.set(inconclusive); stop;		/* two statements on the same line */
  }
  [] ISAP1.receive ( IDISind:{} ) {
    verdict.set(inconclusive); stop;
  }
  [] MSAP2.receive ( Medium_Data_Transfer() ) {
    verdict.set(inconclusive); stop;
  }

  /* FAIL CASES */
  [] ISAP1.receive {
    verdict.set(fail); stop;
  }
  [] MSAP2.receive {
    verdict.set(fail); stop;
  }
  } with { display "default"; }


  /* The test case using this default will look like: */
  
  
  testcase mi_synch5 () runs on MTCType {
    var default def := activate(DefaultWithInconclusives()); /* Default activation */

    ISAP1.send( ICONreq:{} );	/* ONE */

    MSAP2.receive( Medium_Connection_Request() ); /* response to ONE */

    MSAP2.send ( MDATreq:Medium_Connection_Confirmation() );	/* TWO */

    ISAP1.receive ( ICONconf:{} ); /* response to TWO */

    ISAP1.send ( Data_Request(TestSuitePar) ); /* THREE */
    
    MSAP2.receive ( Medium_Data_Transfer() ); /* response to THREE */

    MSAP2.send ( MDATreq:cmi_synch1() ); /* FOUR */
    ISAP1.send ( IDISreq:{} ); /* FIVE */

    interleave {					/* the two responses to FIVE can arrive in any order */
    [] ISAP1.receive (IDISind:{} ) {}; 		
    [] MSAP2.receive ( Medium_Disconnection_Request() ) {};
    }

    verdict.set(pass);
    stop;

  } /* End testcase mi_synch5 */



  /* The previous example with some more meaningful comments ... */
  
  testcase mi_synch6 () runs on MTCType {
    var default def := activate(DefaultWithInconclusives()); /* Default activation */

    /* ***** Inres Initiator state = DISCONNECTED ***** */

    /* Connection Set-Up */
    ISAP1.send( ICONreq:{} );	/* Connection Request from Initiator user */
    MSAP2.receive( Medium_Connection_Request() ); /* Connection Request on Responder side */

    MSAP2.send ( MDATreq:Medium_Connection_Confirmation() );
    /* Connection Confirmation from Responder side */
    ISAP1.receive ( ICONconf:{} );/* Connection Confirmation on Initiator user */

    /* ***** Inres Initiator state = CONNECTED ***** */

    /* Data transfer */
    ISAP1.send ( Data_Request(TestSuitePar) );/* Data transfer from Initiator user */

    MSAP2.receive ( Medium_Data_Transfer() ); /* Data reception on Responder side */

    MSAP2.send ( MDATreq:cmi_synch1() ); /* Acknowledgement for data reception by Responder */

    /* End Data transfer, ***** Inres Initiator state = CONNECTED ***** */


    /* Disconnection */
    ISAP1.send ( IDISreq:{} );	/* Disconnection Request from Initiator user */

    interleave {		/* Disconnection is indicated on both sides */
    [] ISAP1.receive ( IDISind:{} ) {};
    [] MSAP2.receive ( Medium_Disconnection_Request() ) {};
    }

    /* ***** Inres Initiator state = DISCONNECTED ***** */

    verdict.set(pass);
    stop;

  } /* End testcase mi_synch6 */



  testcase mi_synch7 () runs on MTCType {
    var default def := activate(DefaultWithInconclusives()); // Default activation

    // * Inres Initiator state = DISCONNECTED *

    // Connection Set-Up
    ISAP1.send( ICONreq:{} );	// Connection Request from Initiator user
    MSAP2.receive( MDATind:Medium_Connection_Request() );
    // Connection Request on Responder side

    MSAP2.send ( MDATreq:Medium_Connection_Confirmation() );
    // Connection Confirmation from Responder side
    ISAP1.receive ( ICONconf:{} );// Connection Confirmation on Initiator user

    // * Inres Initiator state = CONNECTED *
    
    // Data transfer
    ISAP1.send ( IDATreq:Data_Request(TestSuitePar) );
    // Data transfer from Initiator user
    
    MSAP2.receive ( MDATind:Medium_Data_Transfer() );
    // Data reception on Responder side
    
    MSAP2.send ( MDATreq:cmi_synch1() ); // Acknowledgement for data reception by Responder

    // End Data transfer, * Inres Initiator state = CONNECTED *


    // Disconnection
    ISAP1.send ( IDISreq:{} );	// Disconnection Request from Initiator user 

    interleave {		// Disconnection is indicated on both sides
    [] ISAP1.receive ( IDISind:{} ) {};
    [] MSAP2.receive ( MDATind:Medium_Disconnection_Request() ) {};
    }

    // End Disconnection, * Inres Initiator state = DISCONNECTED *

    verdict.set(pass);
    stop;

  } // End testcase mi_synch5

} /* end  module InresExample1 */