ETSI ES 201 873-1 V4.3.1 (2011-06
)
ETSI Standard
Methods for Testing and Specification (MTS);
The Testing and Test Control Notation version 3;
Part 1: TTCN-3
Core Language
ETSI
ETSI ES 201 873
-
1 V4.3.1 (2011
-
06)
2
Reference
RES/MTS-00107-1 T3 ed431 core
Keywords
methodology, MTS, testing, TTCN
ETSI
650 Route des Lucioles
F-06921 Sophia Antipolis Cedex - FRANCE
Tel.: +33 4 92 94 42 00 Fax: +33 4 93 65 47 16
Siret N° 348 623 562 00017 - NAF 742 C
Association à but non lucratif enregistrée à la
Sous-Préfecture de Grasse (06) N° 7803/88
Important notice
Individual copies of the present document can be downloaded from:
http://www.etsi.org
The present document may be made available in more than one electronic version or in print. In any case of existing or
perceived difference in contents between such versions, the reference version is the Portable Document Format (PDF).
In case of dispute, the reference shall be the printing on ETSI printers of the PDF version kept on a specific network dr
ive
within ETSI Secretariat.
Users of the present document should be aware that the document may be subject to revision or change of status.
Information on the current status of this and other ETSI documents is available at
http://portal.etsi.org/tb/status/status.asp
If you find errors in the present document, please send your comment to one of the following services:
http://portal.etsi.org/chaircor/ETSI_support.asp
Copyright Notification
No part may be reproduced except as authorized by written permission.
The copyright and the foregoing restriction extend to reproduction in all media.
© European Telecommunications Standards Institute 2011.
All rights reserved.
DECT
TM
, PLUGTESTS
TM
, UMTS
TM
, TIPHON
TM
, the TIPHON logo and the ETSI logo
are Trade Marks of ETSI registered
for the benefit of its Members.
3GPP
TM
is a Trade Mark of ETSI registered for the benefit of its Members and of the 3GPP Organizational Partners.
LTE™ is a Trade Mark of ETSI currently being registered
for the benefit of its Members and of the 3GPP Organizational Partners.
GSM® and the GSM logo are Trade Marks registered and owned by the GSM Association.
ETSI
ETSI ES 201 873
-
1 V4.3.1 (2011
-
06)
3
Contents
Intellectual Property Rights .............................................................................................................................. 11
Foreword ........................................................................................................................................................... 11
1 Scope ...................................................................................................................................................... 12
2 References .............................................................................................................................................. 12
2.1 Normative references ....................................................................................................................................... 12
2.2 Informative references ...................................................................................................................................... 13
3 Definitions and abbreviations ................................................................................................................. 14
3.1 Definitions ........................................................................................................................................................ 14
3.2 Abbreviations ................................................................................................................................................... 17
4 Introduction ............................................................................................................................................ 17
4.1 The core language and presentation formats .................................................................................................... 18
4.2 Unanimity of the specification ......................................................................................................................... 19
4.3 Conformance .................................................................................................................................................... 19
5 Basic language elements ........................................................................................................................ 20
5.1 Identifiers and keywords .................................................................................................................................. 20
5.2 Scope rules ....................................................................................................................................................... 21
5.2.1 Scope of formal parameters ........................................................................................................................ 23
5.2.2 Uniqueness of identifiers ............................................................................................................................ 23
5.3 Ordering of language elements ......................................................................................................................... 24
5.4 Parameterization ............................................................................................................................................... 24
5.4.1 Formal parameters ...................................................................................................................................... 24
5.4.1.1 Formal parameters of kind value ........................................................................................................... 25
5.4.1.2 Formal parameters of kind template ...................................................................................................... 27
5.4.1.3 Formal parameters of kind timer ........................................................................................................... 28
5.4.1.4 Formal parameters of kind port ............................................................................................................. 29
5.4.2 Actual parameters ....................................................................................................................................... 29
5.5 Cyclic Definitions............................................................................................................................................. 32
6 Types and values .................................................................................................................................... 32
6.1 Basic types and values ...................................................................................................................................... 33
6.1.0 Simple basic types and values..................................................................................................................... 33
6.1.1 Basic string types and values ...................................................................................................................... 34
6.1.1.1 Accessing individual string elements .................................................................................................... 36
6.1.2 Subtyping of basic types ............................................................................................................................. 36
6.1.2.1 Lists of values ....................................................................................................................................... 36
6.1.2.2 Lists of types ......................................................................................................................................... 36
6.1.2.3 Ranges ................................................................................................................................................... 37
6.1.2.4 String length restrictions ....................................................................................................................... 37
6.1.2.5 Pattern subtyping of character string types ........................................................................................... 38
6.1.2.6 Mixing subtyping mechanisms .............................................................................................................. 38
6.1.2.6.1 Mixing patterns, lists and ranges ..................................................................................................... 38
6.1.2.6.2 Using length restriction with other constraints ................................................................................ 39
6.2 Structured types and values .............................................................................................................................. 39
6.2.1 Record type and values ............................................................................................................................... 41
6.2.1.1 Referencing fields of a record type ....................................................................................................... 42
6.2.1.2 Optional elements in a record................................................................................................................ 42
6.2.1.3 Nested type definitions for field types .................................................................................................. 43
6.2.2 Set type and values ..................................................................................................................................... 43
6.2.2.1 Referencing fields of a set type ............................................................................................................. 43
6.2.2.2 Optional elements in a set ..................................................................................................................... 43
6.2.2.3 Nested type definition for field types .................................................................................................... 43
6.2.3 Records and sets of single types ................................................................................................................. 44
6.2.3.1 Nested type definitions .......................................................................................................................... 45
6.2.3.2 Referencing elements of record of and set of types .............................................................................. 45
ETSI
ETSI ES 201 873
-
1 V4.3.1 (2011
-
06)
4
6.2.4 Enumerated type and values ....................................................................................................................... 46
6.2.5 Unions ......................................................................................................................................................... 47
6.2.5.1 Referencing fields of a union type ........................................................................................................ 47
6.2.5.2 Option and union ................................................................................................................................... 48
6.2.5.3 Nested type definition for field types .................................................................................................... 48
6.2.6 The anytype ................................................................................................................................................ 48
6.2.7 Arrays ......................................................................................................................................................... 48
6.2.8 The default type .......................................................................................................................................... 50
6.2.9 Communication port types .......................................................................................................................... 50
6.2.10 Component types ........................................................................................................................................ 52
6.2.10.1 Component type definition .................................................................................................................... 52
6.2.10.2 Reuse of component types .................................................................................................................... 53
6.2.11 Component references ................................................................................................................................ 55
6.2.12 Addressing entities inside the SUT ............................................................................................................. 57
6.2.13 Subtyping of structured types ..................................................................................................................... 59
6.2.13.1 Length subtyping of record ofs and set ofs ........................................................................................... 59
6.2.13.2 List subtyping of structured types and anytype ..................................................................................... 60
6.2.13.3 Subtyping of the iterated type of record ofs and set ofs ........................................................................ 62
6.2.13.4 Mixing subtyping mechanisms .............................................................................................................. 63
6.3 Type compatibility ........................................................................................................................................... 63
6.3.1 Type compatibility of non-structured types ................................................................................................ 63
6.3.2 Type compatibility of structured types ....................................................................................................... 64
6.3.2.1 Type compatibility of enumerated types ............................................................................................... 64
6.3.2.2 Type compatibility of record and record of types ................................................................................. 64
6.3.2.3 Type compatibility of set and set of types ............................................................................................. 66
6.3.2.4 Type compatibility of union types ........................................................................................................ 67
6.3.2.5 Type compatibility of anytype types ..................................................................................................... 67
6.3.2.6 Compatibility between sub-structures ................................................................................................... 68
6.3.3 Type compatibility of component types...................................................................................................... 68
6.3.4 Type compatibility of communication operations ...................................................................................... 68
6.3.5 Type conversion .......................................................................................................................................... 69
6.4 Type synonym .................................................................................................................................................. 69
7 Expressions ............................................................................................................................................. 69
7.1 Operators .......................................................................................................................................................... 70
7.1.1 Arithmetic operators ................................................................................................................................... 71
7.1.2 List operator ................................................................................................................................................ 72
7.1.3 Relational operators .................................................................................................................................... 72
7.1.4 Logical operators ........................................................................................................................................ 74
7.1.5 Bitwise operators ........................................................................................................................................ 74
7.1.6 Shift operators ............................................................................................................................................. 75
7.1.7 Rotate operators .......................................................................................................................................... 76
7.2 Field references and list elements ..................................................................................................................... 76
8 Modules .................................................................................................................................................. 77
8.1 Definition of a module ..................................................................................................................................... 77
8.2 Module definitions part .................................................................................................................................... 78
8.2.1 Module parameters ..................................................................................................................................... 78
8.2.2 Groups of definitions .................................................................................................................................. 80
8.2.3 Importing from modules ............................................................................................................................. 81
8.2.3.1 General format of import ...................................................................................................................... 81
8.2.3.2 Importing single definitions .................................................................................................................. 87
8.2.3.3 Importing groups ................................................................................................................................... 88
8.2.3.4 Importing definitions of the same kind ................................................................................................. 89
8.2.3.5 Importing all definitions of a module .................................................................................................... 90
8.2.3.6 Import definitions from other TTCN-3 editions and from non-TTCN-3 modules ................................ 90
8.2.3.7 Importing of import statements from TTCN-3 modules ....................................................................... 92
8.2.3.8 Compatibility of language specifications in imports ............................................................................. 93
8.2.4 Definition of friend modules ....................................................................................................................... 93
8.2.5 Visibility of definitions ............................................................................................................................... 94
8.3 Module control part .......................................................................................................................................... 95
9 Port types, component types and test configurations ............................................................................. 96
ETSI
ETSI ES 201 873
-
1 V4.3.1 (2011
-
06)
5
9.1 Communication ports ....................................................................................................................................... 97
9.2 Test system interface ........................................................................................................................................ 99
10 Declaring constants .............................................................................................................................. 101
11 Declaring variables ............................................................................................................................... 101
11.1 Value variables ............................................................................................................................................... 101
11.2 Template variables ......................................................................................................................................... 102
12 Declaring timers ................................................................................................................................... 103
13 Declaring messages .............................................................................................................................. 104
14 Declaring procedure signatures ............................................................................................................ 104
15 Declaring templates .............................................................................................................................. 106
15.1 Declaring message templates ......................................................................................................................... 106
15.2 Declaring signature templates ........................................................................................................................ 108
15.3 Global and local templates ............................................................................................................................. 109
15.4 In-line Templates ............................................................................................................................................ 110
15.5 Modified templates ......................................................................................................................................... 111
15.6 Referencing elements of templates or template fields .................................................................................... 113
15.6.1 Referencing individual string elements..................................................................................................... 113
15.6.2 Referencing record and set fields ....................................................................................................... 114
15.6.3 Referencing record of and set of elements ...................................................................................... 115
15.6.4 Referencing signature parameters ............................................................................................................. 116
15.7 Template matching mechanisms .................................................................................................................... 117
15.7.1 Specific values .......................................................................................................................................... 118
15.7.2 Special symbols that can be used instead of values .................................................................................. 118
15.7.3 Special symbols that can be used inside values ........................................................................................ 119
15.7.4 Special symbols which describe attributes of values ................................................................................ 119
15.8 Template Restrictions ..................................................................................................................................... 120
15.9 Match Operation ............................................................................................................................................. 122
15.10 Valueof Operation .......................................................................................................................................... 123
15.11 Concatenating templates of string and list types ............................................................................................ 123
16 Functions, altsteps and testcases .......................................................................................................... 125
16.1 Functions ........................................................................................................................................................ 125
16.1.1 Invoking functions .................................................................................................................................... 126
16.1.2 Predefined functions ................................................................................................................................. 128
16.1.3 External functions ..................................................................................................................................... 130
16.1.4 Invoking functions from specific places ................................................................................................... 130
16.2 Altsteps ........................................................................................................................................................... 131
16.2.1 Invoking altsteps ....................................................................................................................................... 132
16.3 Test cases........................................................................................................................................................ 134
17 Void ...................................................................................................................................................... 135
18 Overview of program statements and operations ................................................................................. 135
19 Basic program statements ..................................................................................................................... 137
19.1 Assignments ................................................................................................................................................... 138
19.2 The If-else statement ...................................................................................................................................... 138
19.3 The Select case statement ............................................................................................................................... 139
19.4 The For statement ........................................................................................................................................... 140
19.5 The While statement ....................................................................................................................................... 140
19.6 The Do-while statement ................................................................................................................................. 141
19.7 The Label statement ....................................................................................................................................... 141
19.8 The Goto statement ........................................................................................................................................ 142
19.9 The Stop execution statement ......................................................................................................................... 143
19.10 The Return statement ...................................................................................................................................... 143
19.11 The Log statement .......................................................................................................................................... 144
19.12 The Break statement ....................................................................................................................................... 145
19.13 The Continue statement .................................................................................................................................. 146
19.14 Statement block .............................................................................................................................................. 147