logo资料库

TTCN-3 Core Language v4.6.1.pdf

第1页 / 共315页
第2页 / 共315页
第3页 / 共315页
第4页 / 共315页
第5页 / 共315页
第6页 / 共315页
第7页 / 共315页
第8页 / 共315页
资料共315页,剩余部分请下载后查看
Intellectual Property Rights
Foreword
Modal verbs terminology
1 Scope
2 References
2.1 Normative references
2.2 Informative references
3 Definitions and abbreviations
3.1 Definitions
3.2 Abbreviations
4 Introduction
4.1 The core language and presentation formats
4.2 Unanimity of the specification
4.3 Conformance
5 Basic language elements
5.1 Identifiers and keywords
5.2 Scope rules
5.2.1 Scope of formal parameters
5.2.2 Uniqueness of identifiers
5.3 Ordering of language elements
5.4 Parameterization
5.4.1 Formal parameters
5.4.1.1 Formal parameters of kind value
5.4.1.2 Formal parameters of kind template
5.4.1.3 Formal parameters of kind timer
5.4.1.4 Formal parameters of kind port
5.4.2 Actual parameters
5.5 Cyclic Definitions
6 Types and values
6.1 Basic types and values
6.1.0 Simple basic types and values
6.1.1 Basic string types and values
6.1.1.1 Accessing individual string elements
6.1.2 Subtyping of basic types
6.1.2.1 Lists of templates
6.1.2.2 Lists of types
6.1.2.3 Ranges
6.1.2.4 String length restrictions
6.1.2.5 Pattern subtyping of character string types
6.1.2.6 Mixing subtyping mechanisms
6.1.2.6.1 Mixing patterns, lists and ranges
6.1.2.6.2 Using length restriction with other constraints
6.2 Structured types and values
6.2.1 Record type and values
6.2.1.1 Referencing fields of a record type
6.2.1.2 Optional elements in a record
6.2.1.3 Nested type definitions for field types
6.2.2 Set type and values
6.2.2.1 Referencing fields of a set type
6.2.2.2 Optional elements in a set
6.2.2.3 Nested type definition for field types
6.2.3 Records and sets of single types
6.2.3.1 Nested type definitions
6.2.3.2 Referencing elements of record of and set of types
6.2.4 Enumerated type and values
6.2.5 Unions
6.2.5.1 Referencing fields of a union type
6.2.5.2 Option and union
6.2.5.3 Nested type definition for field types
6.2.6 The anytype
6.2.7 Arrays
6.2.8 The default type
6.2.9 Communication port types
6.2.10 Component types
6.2.10.1 Component type definition
6.2.10.2 Reuse of component types
6.2.11 Component references
6.2.12 Addressing entities inside the SUT
6.2.13 Subtyping of structured types
6.2.13.1 Length subtyping of record ofs and set ofs
6.2.13.2 List subtyping of structured types and anytype
6.2.13.3 Subtyping of the iterated type of record ofs and set ofs
6.2.13.4 Mixing subtyping mechanisms
6.3 Type compatibility
6.3.1 Compatibility of non-structured types
6.3.2 Compatibility of structured types
6.3.2.1 Compatibility of enumerated types
6.3.2.2 Compatibility of record and record of types
6.3.2.3 Compatibility of set and set of types
6.3.2.4 Compatibility of union types
6.3.2.5 Compatibility of anytype types
6.3.2.6 Compatibility between sub-structures
6.3.3 Compatibility of component types
6.3.4 Type compatibility of communication operations
6.3.5 Type conversion
6.4 Type synonym
7 Expressions
7.1 Operators
7.1.1 Arithmetic operators
7.1.2 List operator
7.1.3 Relational operators
7.1.4 Logical operators
7.1.5 Bitwise operators
7.1.6 Shift operators
7.1.7 Rotate operators
7.2 Field references and list elements
8 Modules
8.1 Definition of a module
8.2 Module definitions part
8.2.1 Module parameters
8.2.2 Groups of definitions
8.2.3 Importing from modules
8.2.3.1 General format of import
8.2.3.2 Importing single definitions
8.2.3.3 Importing groups
8.2.3.4 Importing definitions of the same kind
8.2.3.5 Importing all definitions of a module
8.2.3.6 Import definitions from other TTCN-3 editions and from non-TTCN-3 modules
8.2.3.7 Importing of import statements from TTCN-3 modules
8.2.3.8 Compatibility of language specifications in imports
8.2.4 Definition of friend modules
8.2.5 Visibility of definitions
8.3 Module control part
9 Port types, component types and test configurations
9.1 Communication ports
9.2 Test system interface
10 Declaring constants
11 Declaring variables
11.1 Value variables
11.2 Template variables
12 Declaring timers
13 Declaring messages
14 Declaring procedure signatures
15 Declaring templates
15.1 Declaring message templates
15.2 Declaring signature templates
15.3 Global and local templates
15.4 In-line Templates
15.5 Modified templates
15.6 Referencing elements of templates or template fields
15.6.1 Referencing individual string elements
15.6.2 Referencing record and set fields
15.6.3 Referencing record of and set of elements
15.6.4 Referencing signature parameters
15.7 Template matching mechanisms
15.7.1 Specific values
15.7.2 Special symbols that can be used instead of values
15.7.3 Special symbols that can be used inside values
15.7.4 Special symbols which describe attributes of values
15.8 Template Restrictions
15.9 Match Operation
15.10 Valueof Operation
15.11 Concatenating templates of string and list types
16 Functions, altsteps and testcases
16.1 Functions
16.1.1 Invoking functions
16.1.2 Predefined functions
16.1.3 External functions
16.1.4 Invoking functions from specific places
16.2 Altsteps
16.2.1 Invoking altsteps
16.3 Test cases
17 Void
18 Overview of program statements and operations
19 Basic program statements
19.1 Assignments
19.2 The If-else statement
19.3 The Select case statement
19.4 The For statement
19.5 The While statement
19.6 The Do-while statement
19.7 The Label statement
19.8 The Goto statement
19.9 The Stop execution statement
19.10 The Return statement
19.11 The Log statement
19.12 The Break statement
19.13 The Continue statement
19.14 Statement block
20 Statement and operations for alternative behaviours
20.1 The snapshot mechanism
20.2 The Alt statement
20.3 The Repeat statement
20.4 The Interleave statement
20.5 Default Handling
20.5.1 The default mechanism
20.5.2 The Activate operation
20.5.3 The Deactivate operation
21 Configuration Operations
21.1 Connection Operations
21.1.1 The Connect and Map operations
21.1.2 The Disconnect and Unmap operations
21.2 Test case operations
21.2.1 Test case stop operation
21.3 Test Component Operations
21.3.1 The Create operation
21.3.2 The Start test component operation
21.3.3 The Stop test behaviour operation
21.3.4 The Kill test component operation
21.3.5 The Alive operation
21.3.6 The Running operation
21.3.7 The Done operation
21.3.8 The Killed operation
21.3.9 Summary of the use of any and all with components
22 Communication operations
22.1 The communication mechanisms
22.1.1 Principles of message-based communication
22.1.2 Principles of procedure-based communication
22.1.3 Principles of unicast, multicast and broadcast communication
22.1.4 General format of communication operations
22.1.4.1 General format of the sending operations
22.1.4.2 General format of the receiving operations
22.2 Message-based communication
22.2.1 The Send operation
22.2.2 The Receive operation
22.2.3 The Trigger operation
22.3 Procedure-based communication
22.3.1 The Call operation
22.3.2 The Getcall operation
22.3.3 The Reply operation
22.3.4 The Getreply operation
22.3.5 The Raise operation
22.3.6 The Catch operation
22.4 The Check operation
22.5 Controlling communication ports
22.5.1 The Clear port operation
22.5.2 The Start port operation
22.5.3 The Stop port operation
22.5.4 The Halt port operation
22.5.5 The Checkstate port operation
22.6 Use of any and all with ports
23 Timer operations
23.1 The timer mechanism
23.2 The Start timer operation
23.3 The Stop timer operation
23.4 The Read timer operation
23.5 The Running timer operation
23.6 The Timeout operation
23.7 Summary of use of any and all with timers
24 Test verdict operations
24.1 The Verdict mechanism
24.2 The Setverdict operation
24.3 The Getverdict operation
25 External actions
26 Module control
26.1 The Execute statement
26.2 The Control part
27 Specifying attributes
27.1 The Attribute mechanism
27.1.1 Scope of attributes
27.1.2 Overwriting rules for attributes
27.1.2.1 Additional overwriting rules for variant attributes
27.1.3 Changing attributes of imported language elements
27.2 The With statement
27.3 Display attributes
27.4 Encoding attributes
27.5 Variant attributes
27.6 Extension attributes
27.7 Optional attributes
Annex A (normative): BNF and static semantics
A.1 TTCN-3 BNF
A.1.1 Conventions for the syntax description
A.1.2 Statement terminator symbols
A.1.3 Identifiers
A.1.4 Comments
A.1.5 TTCN-3 terminals
A.1.5.1 Use of whitespaces and newlines
A.1.6 TTCN-3 syntax BNF productions
A.1.6.0 TTCN-3 module
A.1.6.1 Module definitions part
A.1.6.1.0 General
A.1.6.1.1 Typedef definitions
A.1.6.1.2 Constant definitions
A.1.6.1.3 Template definitions
A.1.6.1.4 Function definitions
A.1.6.1.5 Signature definitions
A.1.6.1.6 Testcase definitions
A.1.6.1.7 Altstep definitions
A.1.6.1.8 Import definitions
A.1.6.1.9 Group definitions
A.1.6.1.10 External function definitions
A.1.6.1.11 External constant definitions
A.1.6.1.12 Module parameter definitions
A.1.6.1.13 Friend module definitions
A.1.6.2 Control part
A.1.6.3 Local definitions
A.1.6.3.1 Variable instantiation
A.1.6.3.2 Timer instantiation
A.1.6.4 Operations
A.1.6.4.1 Component operations
A.1.6.4.2 Port operations
A.1.6.4.3 Timer operations
A.1.6.4.4 Testcase operation
A.1.6.5 Type
A.1.6.6 Value
A.1.6.7 Parameterization
A.1.6.8 Statements
A.1.6.8.1 With statement
A.1.6.8.2 Behaviour statements
A.1.6.8.3 Basic statements
A.1.6.9 Miscellaneous productions
Annex B (normative): Matching values
B.1 Template matching mechanisms
B.1.1 Matching specific values
B.1.2 Matching mechanisms instead of values
B.1.2.1 Template list
B.1.2.2 Complemented template list
B.1.2.3 Any value
B.1.2.4 Any value or none
B.1.2.5 Value range
B.1.2.6 SuperSet
B.1.2.7 SubSet
B.1.2.8 Omitting optional fields
B.1.3 Matching mechanisms inside values
B.1.3.1 Any element
B.1.3.1.1 Using single character wildcards
B.1.3.2 Any number of elements or no element
B.1.3.2.1 Using multiple character wildcards
B.1.3.3 Permutation
B.1.4 Matching attributes of values
B.1.4.1 Length restrictions
B.1.4.2 The IfPresent indicator
B.1.5 Matching character pattern
B.1.5.1 Set expression
B.1.5.2 Reference expression
B.1.5.3 Match expression n times
B.1.5.4 Match a referenced character set
B.1.5.5 Type compatibility rules for patterns
Annex C (normative): Predefined TTCN-3 functions
C.0 General exception handling procedures
C.1 Conversion functions
C.1.1 Integer to character
C.1.2 Integer to universal character
C.1.3 Integer to bitstring
C.1.4 Integer to enumerated
C.1.5 Integer to hexstring
C.1.6 Integer to octetstring
C.1.7 Integer to charstring
C.1.8 Integer to float
C.1.9 Float to integer
C.1.10 Character to integer
C.1.11 Character to octetstring
C.1.12 Universal character to integer
C.1.13 Bitstring to integer
C.1.14 Bitstring to hexstring
C.1.15 Bitstring to octetstring
C.1.16 Bitstring to charstring
C.1.17 Hexstring to integer
C.1.18 Hexstring to bitstring
C.1.19 Hexstring to octetstring
C.1.20 Hexstring to charstring
C.1.21 Octetstring to integer
C.1.22 Octetstring to bitstring
C.1.23 Octetstring to hexstring
C.1.24 Octetstring to character string
C.1.25 Octetstring to character string, version II
C.1.26 Charstring to integer
C.1.27 Character string to hexstring
C.1.28 Character string to octetstring
C.1.29 Character string to float
C.1.30 Enumerated to integer
C.1.31 Octetstring to universal character string
C.1.32 Universal character string to octetstring
C.2 Length/size functions
C.2.1 Length of strings and lists
C.2.2 Number of elements in a structured value
C.3 Presence checking functions
C.3.1 The IsPresent function
C.3.2 The IsChosen function
C.3.3 The IsValue function
C.3.4 The IsBound function
C.4 String/list handling functions
C.4.1 The Regexp function
C.4.2 The Substring function
C.4.3 The Replace function
C.5 Codec functions
C.5.1 The encoding function
C.5.2 The decoding function
C.5.3 The encoding to universal charstring function
C.5.4 The decoding from universal charstring function
C.6 Other functions
C.6.1 The random number generator function
C.6.2 The testcasename function
C.6.3 The hostId function
Annex D (normative): Preprocessing macros
D.1 Preprocessing macro __MODULE__
D.2 Preprocessing macro __FILE__
D.3 Preprocessing macro __BFILE__
D.4 Preprocessing macro __LINE__
D.5 Preprocessing macro __SCOPE__
Annex E (informative): Library of Useful Types
E.1 Limitations
E.2 Useful TTCN-3 types
E.2.1 Useful simple basic types
E.2.1.0 Signed and unsigned single byte integers
E.2.1.1 Signed and unsigned short integers
E.2.1.2 Signed and unsigned long integers
E.2.1.3 Signed and unsigned longlong integers
E.2.1.4 IEEE 754 floats
E.2.2 Useful character string types
E.2.2.0 UTF-8 character string "utf8string"
E.2.2.1 BMP character string "bmpstring"
E.2.2.2 UTF-16 character string "utf16string"
E.2.2.3 ISO/IEC 10646 character string "iso8859string"
E.2.2.4 Status values for TTCN-3 objects
E.2.3 Useful structured types
E.2.3.0 Fixed-point decimal literal
E.2.4 Useful atomic string types
E.2.4.1 Single Recommendation ITU-T T.50 character type
E.2.4.2 Single universal character type
E.2.4.3 Single bit type
E.2.4.4 Single hex type
E.2.4.5 Single octet type
Annex F (informative): Operations on TTCN-3 active objects
F.1 Test components
F.1.1 Test component references
F.1.2 Dynamic behaviour of PTCs
F.1.3 Dynamic behaviour of the MTC
F.2 Timers
F.3 Ports
F.3.1 Configuration Operations
F.3.2 Port Controlling Operations
F.3.3 Communication Operations
Annex G (informative): Deprecated language features
G.1 Group style definition of module parameters
G.2 Recursive import
G.3 Using all in port type definitions
G.4 sizeof for length of lists
G.5 sizeoftype predefined function
G.6 Mixed ports
G.7 External constants
G.8 Prefixing enumerated values
G.9 Record of/arrays not compatible to record; set of not compatible with set
Annex H (informative): Bibliography
History
ETSI ES 201 873-1 V4.6.1 (2014-06) ETSI Standard Methods for Testing and Specification (MTS); The Testing and Test Control Notation version 3; Part 1: TTCN-3 Core Language
2 ETSI ES 201 873-1 V4.6.1 (2014-06) Reference RES/MTS-201873-1 T3ed461 Keywords language, methodology, testing, TTCN-3 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 The present document can be downloaded from: http://www.etsi.org The present document may be made available in electronic versions and/or in print. The content of any electronic and/or print versions of the present document shall not be modified without the prior written authorization of ETSI. In case of any existing or perceived difference in contents between such versions and/or in print, the only prevailing document is the print of the Portable Document Format (PDF) version kept on a specific network drive 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 or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm except as authorized by written permission of ETSI. The content of the PDF version shall not be modified without the written authorization of ETSI. The copyright and the foregoing restriction extend to reproduction in all media. © European Telecommunications Standards Institute 2014. All rights reserved. DECTTM, PLUGTESTSTM, UMTSTM and the ETSI logo are Trade Marks of ETSI registered for the benefit of its Members. 3GPPTM and LTE™ are Trade Marks of ETSI registered for the benefit of its Members and GSM® and the GSM logo are Trade Marks registered and owned by the GSM Association. of the 3GPP Organizational Partners. ETSI
3 ETSI ES 201 873-1 V4.6.1 (2014-06) Contents Intellectual Property Rights .............................................................................................................................. 11 Foreword ........................................................................................................................................................... 11 Modal verbs terminology .................................................................................................................................. 11 1 Scope ...................................................................................................................................................... 12 References .............................................................................................................................................. 12 2 Normative references ....................................................................................................................................... 12 2.1 2.2 Informative references ...................................................................................................................................... 13 Definitions and abbreviations ................................................................................................................. 13 3 Definitions ........................................................................................................................................................ 13 3.1 Abbreviations ................................................................................................................................................... 18 3.2 4 Introduction ............................................................................................................................................ 19 The core language and presentation formats .................................................................................................... 19 4.1 Unanimity of the specification ......................................................................................................................... 20 4.2 4.3 Conformance .................................................................................................................................................... 21 Basic language elements ........................................................................................................................ 21 5 Identifiers and keywords .................................................................................................................................. 22 5.1 Scope rules ....................................................................................................................................................... 22 5.2 Scope of formal parameters ........................................................................................................................ 24 5.2.1 5.2.2 Uniqueness of identifiers ............................................................................................................................ 24 Ordering of language elements ......................................................................................................................... 25 5.3 Parameterization ............................................................................................................................................... 25 5.4 Formal parameters ...................................................................................................................................... 26 5.4.1 5.4.1.1 Formal parameters of kind value ........................................................................................................... 26 Formal parameters of kind template ...................................................................................................... 29 5.4.1.2 Formal parameters of kind timer ........................................................................................................... 30 5.4.1.3 Formal parameters of kind port ............................................................................................................. 31 5.4.1.4 5.4.2 Actual parameters ....................................................................................................................................... 31 Cyclic Definitions............................................................................................................................................. 35 5.5 Types and values .................................................................................................................................... 35 6 Basic types and values ...................................................................................................................................... 36 6.1 6.1.0 Simple basic types and values..................................................................................................................... 36 Basic string types and values ...................................................................................................................... 37 6.1.1 Accessing individual string elements .................................................................................................... 38 6.1.1.1 Subtyping of basic types ............................................................................................................................. 39 6.1.2 6.1.2.1 Lists of templates .................................................................................................................................. 39 Lists of types ......................................................................................................................................... 39 6.1.2.2 Ranges ................................................................................................................................................... 39 6.1.2.3 String length restrictions ....................................................................................................................... 40 6.1.2.4 Pattern subtyping of character string types ........................................................................................... 41 6.1.2.5 6.1.2.6 Mixing subtyping mechanisms .............................................................................................................. 41 Mixing patterns, lists and ranges ..................................................................................................... 41 6.1.2.6.1 6.1.2.6.2 Using length restriction with other constraints ................................................................................ 41 Structured types and values .............................................................................................................................. 42 6.2 6.2.1 Record type and values ............................................................................................................................... 43 Referencing fields of a record type ....................................................................................................... 45 6.2.1.1 Optional elements in a record................................................................................................................ 46 6.2.1.2 Nested type definitions for field types .................................................................................................. 46 6.2.1.3 6.2.2 Set type and values ..................................................................................................................................... 47 Referencing fields of a set type ............................................................................................................. 47 6.2.2.1 Optional elements in a set ..................................................................................................................... 47 6.2.2.2 Nested type definition for field types .................................................................................................... 47 6.2.2.3 6.2.3 Records and sets of single types ................................................................................................................. 47 ETSI
4 ETSI ES 201 873-1 V4.6.1 (2014-06) 6.2.3.1 6.2.3.2 6.2.4 6.2.5 6.2.5.1 6.2.5.2 6.2.5.3 6.2.6 6.2.7 6.2.8 6.2.9 6.2.10 6.2.10.1 6.2.10.2 6.2.11 6.2.12 6.2.13 6.2.13.1 6.2.13.2 6.2.13.3 6.2.13.4 6.3 6.3.1 6.3.2 6.3.2.1 6.3.2.2 6.3.2.3 6.3.2.4 6.3.2.5 6.3.2.6 6.3.3 6.3.4 6.3.5 6.4 7 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.2 8 8.1 8.2 8.2.1 8.2.2 8.2.3 8.2.3.1 8.2.3.2 8.2.3.3 8.2.3.4 8.2.3.5 8.2.3.6 8.2.3.7 8.2.3.8 8.2.4 8.2.5 Nested type definitions .......................................................................................................................... 50 Referencing elements of record of and set of types .............................................................................. 50 Enumerated type and values ....................................................................................................................... 51 Unions ......................................................................................................................................................... 52 Referencing fields of a union type ........................................................................................................ 52 Option and union ................................................................................................................................... 52 Nested type definition for field types .................................................................................................... 52 The anytype ................................................................................................................................................ 53 Arrays ......................................................................................................................................................... 53 The default type .......................................................................................................................................... 55 Communication port types .......................................................................................................................... 55 Component types ........................................................................................................................................ 57 Component type definition .................................................................................................................... 57 Reuse of component types .................................................................................................................... 58 Component references ................................................................................................................................ 60 Addressing entities inside the SUT ............................................................................................................. 62 Subtyping of structured types ..................................................................................................................... 64 Length subtyping of record ofs and set ofs ........................................................................................... 64 List subtyping of structured types and anytype ..................................................................................... 65 Subtyping of the iterated type of record ofs and set ofs ........................................................................ 67 Mixing subtyping mechanisms .............................................................................................................. 68 Type compatibility ........................................................................................................................................... 69 Compatibility of non-structured types ........................................................................................................ 69 Compatibility of structured types ................................................................................................................ 70 Compatibility of enumerated types ....................................................................................................... 70 Compatibility of record and record of types ......................................................................................... 71 Compatibility of set and set of types ..................................................................................................... 72 Compatibility of union types ................................................................................................................. 72 Compatibility of anytype types ............................................................................................................. 73 Compatibility between sub-structures ................................................................................................... 73 Compatibility of component types .............................................................................................................. 74 Type compatibility of communication operations ...................................................................................... 74 Type conversion .......................................................................................................................................... 75 Type synonym .................................................................................................................................................. 75 Expressions ............................................................................................................................................. 75 Operators .......................................................................................................................................................... 76 Arithmetic operators ................................................................................................................................... 77 List operator ................................................................................................................................................ 78 Relational operators .................................................................................................................................... 78 Logical operators ........................................................................................................................................ 80 Bitwise operators ........................................................................................................................................ 81 Shift operators ............................................................................................................................................. 82 Rotate operators .......................................................................................................................................... 82 Field references and list elements ..................................................................................................................... 83 Modules .................................................................................................................................................. 83 Definition of a module ..................................................................................................................................... 83 Module definitions part .................................................................................................................................... 84 Module parameters ..................................................................................................................................... 85 Groups of definitions .................................................................................................................................. 86 Importing from modules ............................................................................................................................. 87 General format of import ...................................................................................................................... 88 Importing single definitions .................................................................................................................. 94 Importing groups ................................................................................................................................... 94 Importing definitions of the same kind ................................................................................................. 95 Importing all definitions of a module .................................................................................................... 96 Import definitions from other TTCN-3 editions and from non-TTCN-3 modules ................................ 97 Importing of import statements from TTCN-3 modules ....................................................................... 99 Compatibility of language specifications in imports ........................................................................... 100 Definition of friend modules ..................................................................................................................... 100 Visibility of definitions ............................................................................................................................. 101 ETSI
5 ETSI ES 201 873-1 V4.6.1 (2014-06) Module control part ........................................................................................................................................ 102 8.3 Port types, component types and test configurations ........................................................................... 103 9 Communication ports ..................................................................................................................................... 103 9.1 Test system interface ...................................................................................................................................... 105 9.2 10 Declaring constants .............................................................................................................................. 107 11 Declaring variables ............................................................................................................................... 107 Value variables ............................................................................................................................................... 108 11.1 11.2 Template variables ......................................................................................................................................... 109 12 Declaring timers ................................................................................................................................... 110 13 Declaring messages .............................................................................................................................. 111 14 Declaring procedure signatures ............................................................................................................ 111 15 Declaring templates .............................................................................................................................. 113 Declaring message templates ......................................................................................................................... 114 15.1 15.2 Declaring signature templates ........................................................................................................................ 115 Global and local templates ............................................................................................................................. 117 15.3 In-line Templates ............................................................................................................................................ 117 15.4 Modified templates ......................................................................................................................................... 118 15.5 Referencing elements of templates or template fields .................................................................................... 121 15.6 15.6.1 Referencing individual string elements..................................................................................................... 121 Referencing record and set fields ....................................................................................................... 121 15.6.2 Referencing record of and set of elements ...................................................................................... 122 15.6.3 15.6.4 Referencing signature parameters ............................................................................................................. 125 Template matching mechanisms .................................................................................................................... 126 15.7 Specific values .......................................................................................................................................... 127 15.7.1 Special symbols that can be used instead of values .................................................................................. 128 15.7.2 Special symbols that can be used inside values ........................................................................................ 129 15.7.3 15.7.4 Special symbols which describe attributes of values ................................................................................ 129 Template Restrictions ..................................................................................................................................... 130 15.8 Match Operation ............................................................................................................................................. 132 15.9 Valueof Operation .......................................................................................................................................... 132 15.10 15.11 Concatenating templates of string and list types ............................................................................................ 133 Functions, altsteps and testcases .......................................................................................................... 134 16 Functions ........................................................................................................................................................ 134 16.1 Invoking functions .................................................................................................................................... 137 16.1.1 16.1.2 Predefined functions ................................................................................................................................. 138 External functions ..................................................................................................................................... 140 16.1.3 16.1.4 Invoking functions from specific places ................................................................................................... 140 Altsteps ........................................................................................................................................................... 141 16.2 16.2.1 Invoking altsteps ....................................................................................................................................... 143 16.3 Test cases........................................................................................................................................................ 144 17 Void ...................................................................................................................................................... 145 18 Overview of program statements and operations ................................................................................. 145 19 Basic program statements ..................................................................................................................... 147 Assignments ................................................................................................................................................... 148 19.1 The If-else statement ...................................................................................................................................... 149 19.2 19.3 The Select case statement ............................................................................................................................... 149 The For statement ........................................................................................................................................... 150 19.4 The While statement ....................................................................................................................................... 151 19.5 The Do-while statement ................................................................................................................................. 151 19.6 The Label statement ....................................................................................................................................... 152 19.7 19.8 The Goto statement ........................................................................................................................................ 153 The Stop execution statement ......................................................................................................................... 154 19.9 The Return statement ...................................................................................................................................... 154 19.10 The Log statement .......................................................................................................................................... 155 19.11 19.12 The Break statement ....................................................................................................................................... 157 ETSI
6 ETSI ES 201 873-1 V4.6.1 (2014-06) The Continue statement .................................................................................................................................. 157 19.13 Statement block .............................................................................................................................................. 158 19.14 Statement and operations for alternative behaviours ............................................................................ 158 20 The snapshot mechanism ................................................................................................................................ 159 20.1 The Alt statement ........................................................................................................................................... 159 20.2 The Repeat statement ..................................................................................................................................... 163 20.3 The Interleave statement ................................................................................................................................ 164 20.4 Default Handling ............................................................................................................................................ 166 20.5 The default mechanism ............................................................................................................................. 166 20.5.1 The Activate operation .............................................................................................................................. 167 20.5.2 20.5.3 The Deactivate operation .......................................................................................................................... 168 21 Configuration Operations ..................................................................................................................... 169 21.1 Connection Operations ................................................................................................................................... 170 The Connect and Map operations ............................................................................................................. 170 21.1.1 21.1.2 The Disconnect and Unmap operations .................................................................................................... 172 Test case operations........................................................................................................................................ 173 21.2 21.2.1 Test case stop operation ............................................................................................................................ 173 Test Component Operations ........................................................................................................................... 174 21.3 The Create operation ................................................................................................................................. 174 21.3.1 The Start test component operation .......................................................................................................... 175 21.3.2 The Stop test behaviour operation ............................................................................................................ 176 21.3.3 21.3.4 The Kill test component operation ............................................................................................................ 177 The Alive operation .................................................................................................................................. 178 21.3.5 The Running operation ............................................................................................................................. 179 21.3.6 The Done operation .................................................................................................................................. 180 21.3.7 21.3.8 The Killed operation ................................................................................................................................. 182 21.3.9 Summary of the use of any and all with components ............................................................................... 183 22 Communication operations................................................................................................................... 183 The communication mechanisms ................................................................................................................... 184 22.1 22.1.1 Principles of message-based communication............................................................................................ 184 Principles of procedure-based communication ......................................................................................... 184 22.1.2 Principles of unicast, multicast and broadcast communication ................................................................. 185 22.1.3 General format of communication operations .......................................................................................... 185 22.1.4 22.1.4.1 General format of the sending operations ........................................................................................... 186 22.1.4.2 General format of the receiving operations ......................................................................................... 186 Message-based communication ...................................................................................................................... 187 22.2 The Send operation ................................................................................................................................... 188 22.2.1 The Receive operation .............................................................................................................................. 189 22.2.2 22.2.3 The Trigger operation ............................................................................................................................... 192 Procedure-based communication .................................................................................................................... 194 22.3 The Call operation .................................................................................................................................... 194 22.3.1 The Getcall operation................................................................................................................................ 198 22.3.2 22.3.3 The Reply operation.................................................................................................................................. 200 The Getreply operation ............................................................................................................................. 201 22.3.4 The Raise operation .................................................................................................................................. 203 22.3.5 22.3.6 The Catch operation .................................................................................................................................. 204 The Check operation ...................................................................................................................................... 207 22.4 Controlling communication ports ................................................................................................................... 209 22.5 The Clear port operation ........................................................................................................................... 209 22.5.1 The Start port operation ............................................................................................................................ 210 22.5.2 The Stop port operation ............................................................................................................................ 210 22.5.3 22.5.4 The Halt port operation ............................................................................................................................. 210 22.5.5 The Checkstate port operation .................................................................................................................. 211 Use of any and all with ports .......................................................................................................................... 213 22.6 23 Timer operations .................................................................................................................................. 213 The timer mechanism ..................................................................................................................................... 213 23.1 The Start timer operation ................................................................................................................................ 214 23.2 The Stop timer operation ................................................................................................................................ 214 23.3 23.4 The Read timer operation ............................................................................................................................... 215 ETSI
7 ETSI ES 201 873-1 V4.6.1 (2014-06) The Running timer operation.......................................................................................................................... 215 23.5 The Timeout operation ................................................................................................................................... 216 23.6 Summary of use of any and all with timers .................................................................................................... 217 23.7 Test verdict operations ......................................................................................................................... 218 24 The Verdict mechanism .................................................................................................................................. 218 24.1 The Setverdict operation ................................................................................................................................ 219 24.2 The Getverdict operation ................................................................................................................................ 220 24.3 External actions .................................................................................................................................... 220 25 26 Module control ..................................................................................................................................... 221 The Execute statement .................................................................................................................................... 221 26.1 The Control part ............................................................................................................................................. 223 26.2 27 Specifying attributes ............................................................................................................................. 225 The Attribute mechanism ............................................................................................................................... 225 27.1 Scope of attributes .................................................................................................................................... 225 27.1.1 Overwriting rules for attributes ................................................................................................................. 226 27.1.2 27.1.2.1 Additional overwriting rules for variant attributes .............................................................................. 228 27.1.3 Changing attributes of imported language elements ................................................................................. 228 The With statement ........................................................................................................................................ 229 27.2 Display attributes ............................................................................................................................................ 229 27.3 Encoding attributes ......................................................................................................................................... 230 27.4 27.5 Variant attributes ............................................................................................................................................ 231 Extension attributes ........................................................................................................................................ 233 27.6 27.7 Optional attributes .......................................................................................................................................... 233 BNF and static semantics ............................................................................ 235 Annex A (normative): A.1 TTCN-3 BNF ....................................................................................................................................... 235 Conventions for the syntax description .......................................................................................................... 235 A.1.1 Statement terminator symbols ........................................................................................................................ 235 A.1.2 A.1.3 Identifiers ....................................................................................................................................................... 235 Comments....................................................................................................................................................... 235 A.1.4 TTCN-3 terminals .......................................................................................................................................... 236 A.1.5 A.1.5.1 Use of whitespaces and newlines .............................................................................................................. 238 TTCN-3 syntax BNF productions .................................................................................................................. 238 A.1.6 TTCN-3 module ........................................................................................................................................ 238 A.1.6.0 Module definitions part ............................................................................................................................. 239 A.1.6.1 General ................................................................................................................................................ 239 A.1.6.1.0 A.1.6.1.1 Typedef definitions ............................................................................................................................. 239 Constant definitions ............................................................................................................................ 241 A.1.6.1.2 Template definitions............................................................................................................................ 241 A.1.6.1.3 Function definitions ............................................................................................................................ 243 A.1.6.1.4 Signature definitions ........................................................................................................................... 244 A.1.6.1.5 A.1.6.1.6 Testcase definitions ............................................................................................................................. 244 Altstep definitions ............................................................................................................................... 244 A.1.6.1.7 Import definitions ................................................................................................................................ 244 A.1.6.1.8 Group definitions ................................................................................................................................ 245 A.1.6.1.9 A.1.6.1.10 External function definitions ............................................................................................................... 245 External constant definitions ............................................................................................................... 245 A.1.6.1.11 Module parameter definitions ............................................................................................................. 245 A.1.6.1.12 Friend module definitions ................................................................................................................... 245 A.1.6.1.13 A.1.6.2 Control part ............................................................................................................................................... 246 Local definitions ....................................................................................................................................... 246 A.1.6.3 Variable instantiation .......................................................................................................................... 246 A.1.6.3.1 Timer instantiation .............................................................................................................................. 246 A.1.6.3.2 Operations ................................................................................................................................................. 246 A.1.6.4 A.1.6.4.1 Component operations ........................................................................................................................ 246 Port operations .................................................................................................................................... 247 A.1.6.4.2 Timer operations ................................................................................................................................. 249 A.1.6.4.3 Testcase operation ............................................................................................................................... 249 A.1.6.4.4 A.1.6.5 Type .......................................................................................................................................................... 249 ETSI
A.1.6.6 A.1.6.7 A.1.6.8 A.1.6.8.1 A.1.6.8.2 A.1.6.8.3 A.1.6.9 8 ETSI ES 201 873-1 V4.6.1 (2014-06) Value ......................................................................................................................................................... 250 Parameterization ....................................................................................................................................... 250 Statements ................................................................................................................................................. 251 With statement .................................................................................................................................... 251 Behaviour statements .......................................................................................................................... 251 Basic statements .................................................................................................................................. 252 Miscellaneous productions ....................................................................................................................... 255 Matching values ........................................................................................... 256 Annex B (normative): B.1 Template matching mechanisms .......................................................................................................... 256 Matching specific values ................................................................................................................................ 256 B.1.1 Matching mechanisms instead of values ........................................................................................................ 256 B.1.2 Template list ............................................................................................................................................. 256 B.1.2.1 B.1.2.2 Complemented template list ..................................................................................................................... 257 Any value .................................................................................................................................................. 258 B.1.2.3 Any value or none ..................................................................................................................................... 258 B.1.2.4 Value range ............................................................................................................................................... 259 B.1.2.5 B.1.2.6 SuperSet .................................................................................................................................................... 260 SubSet ....................................................................................................................................................... 261 B.1.2.7 B.1.2.8 Omitting optional fields ............................................................................................................................ 262 Matching mechanisms inside values .............................................................................................................. 263 B.1.3 Any element .............................................................................................................................................. 263 B.1.3.1 B.1.3.1.1 Using single character wildcards ......................................................................................................... 263 Any number of elements or no element .................................................................................................... 263 B.1.3.2 Using multiple character wildcards ..................................................................................................... 264 B.1.3.2.1 B.1.3.3 Permutation ............................................................................................................................................... 264 Matching attributes of values ......................................................................................................................... 265 B.1.4 Length restrictions .................................................................................................................................... 265 B.1.4.1 B.1.4.2 The IfPresent indicator .............................................................................................................................. 266 Matching character pattern ............................................................................................................................. 267 B.1.5 B.1.5.1 Set expression ........................................................................................................................................... 269 Reference expression ................................................................................................................................ 269 B.1.5.2 Match expression n times ......................................................................................................................... 271 B.1.5.3 Match a referenced character set ............................................................................................................... 271 B.1.5.4 B.1.5.5 Type compatibility rules for patterns ........................................................................................................ 272 Annex C (normative): Predefined TTCN-3 functions ..................................................................... 273 C.0 General exception handling procedures ............................................................................................... 273 C.1 Conversion functions ............................................................................................................................ 273 Integer to character ......................................................................................................................................... 273 C.1.1 Integer to universal character ......................................................................................................................... 273 C.1.2 Integer to bitstring .......................................................................................................................................... 273 C.1.3 C.1.4 Integer to enumerated ..................................................................................................................................... 274 Integer to hexstring ......................................................................................................................................... 274 C.1.5 Integer to octetstring ....................................................................................................................................... 274 C.1.6 Integer to charstring........................................................................................................................................ 275 C.1.7 C.1.8 Integer to float ................................................................................................................................................ 275 Float to integer ............................................................................................................................................... 275 C.1.9 Character to integer ........................................................................................................................................ 275 C.1.10 C.1.11 Character to octetstring .................................................................................................................................. 275 C.1.12 Universal character to integer ......................................................................................................................... 276 C.1.13 Bitstring to integer .......................................................................................................................................... 276 Bitstring to hexstring ...................................................................................................................................... 276 C.1.14 Bitstring to octetstring .................................................................................................................................... 276 C.1.15 C.1.16 Bitstring to charstring ..................................................................................................................................... 277 C.1.17 Hexstring to integer ........................................................................................................................................ 277 C.1.18 Hexstring to bitstring ...................................................................................................................................... 277 C.1.19 Hexstring to octetstring .................................................................................................................................. 278 C.1.20 Hexstring to charstring ................................................................................................................................... 278 C.1.21 Octetstring to integer ...................................................................................................................................... 278 ETSI
分享到:
收藏