Documentos de Académico
Documentos de Profesional
Documentos de Cultura
TTCN: Testing and Test Control Notation Original meaning: Tree and Tabular Combined Notation Original purpose: Specification of abstract test suites for conformance testing of International Telecommunications Union protocols. Now promoted as a general purpose test language for distributed / communicating systems. Goal: Provide a complete, internationally standardized, specification for test case behaviour and execution that is repeatable in any test lab. Predictable execution requires very precise semantic definitions.
1
History (1)
Initial discussions on a standardized test language as part of a conformance test framework for communications protocols started in 1984. In 1994, the first version of the conformance test framework standard, ISO-9646, was published. TTCN-1 eventually was part 3 of this standard, published in 1995. Language assumed that the entire protocol testing methodology was being used. In 1997, TTCN-2 was issued. Most used in Europe; only limited use in North America.
2
TTCN-2
Tree and Tabular Combined Notation
TTCN-2 Tables
Example: an abstract service primitive type definition:
ASP Type Definition ASP name: ConnectRequest PCO type: UpperTesterPCO Comments: Parameter Name Parameter Type SA RA Contents OCTET_STRING[2] OCTET_STRING[2] OCTET_STRING[252] Comments sender address receiver address user data
Detailed comments:
5
TTCN-2 Tables
This table describes the data values to be used in one instance of a message of the type of the previous table, sent during a test case.
SA RA Contents
Detailed comments:
TTCN-2: Trees
Verdict
10
11
12
encoder
form
decoder
extract
manuallywritten code operating system service test equipmentspecific
13
!A
011001.
encoder
form
decoder
extract
History (2)
Discussions after TTCN-2 centred on making the language more flexible and user-friendly. Standardization taken over by ETSI, the European Telecommunications Standards Institute.
15
Credits
Much of the following has been adapted from:
About TTCN-3
Tutorial available at www.etsi.org
16
What is TTCN-3?
Testing and Test Control Notation Version 3 Internationally standardized testing language Product of the European Telecommunications Standards Institute (ETSI) A programming language that has been used for more than 15 years in standardization as well as industry
17
TTCN-3 Standards
Standards from ETSI [some cross-listed as ITU standards] ES 201 873-1 (Z.140): TTCN-3 Core Language ES 201 873-2 (Z.141): TTCN-3 Tabular Presentation Format (TFT) ES 201 873-3 (Z.142): TTCN-3 Graphical Presentation Format (GFT) ES 201 873-4 (Z.143): TTCN-3 Operational Semantics ES 201 873-5: TTCN-3 Runtime Interface (TRI) ES 201 873-6: TTCN-3 Control Interfaces (TCI) ES 201 873-7: Using ASN.1 with TTCN-3 ES 201 873-8: The IDL to TTCN-3 Mapping Proposed: Mappings to XML, C++ Currently: Edition 3 of TTCN-3 (2007/8)
18
19
20
Logging
Codecs
Tool Logging
IPv6 Codecs
TTCN-3 Executable
Ethernet Adapter
Real-time Adapter
22
MTC
Communication with IUT
MTC
Logging
Internal Communication
PTC
TRI SUT Adapter
PTC
Codecs
Platform Adapter
A test involves execution of many parallel test components Dynamic instantiation of components and communication links
24
Basic Concepts
25
26
Presentation Formatn
DnsClient
timer t_ack t_ack alt pass fail t_ack inconc t_ack m_dnsQuestion("www.etsi.org") mw_dnsAnswer("172.26.1.17")
DnsPort
29
Type
timer Behavior
Initial value
Comments
serverPort.send(m_dnsQuestion("www.etsi.org")); t_ack.start(1.0); alt { [] serverPort.receive(mw_dnsAnswer("172.26.1.17")) { setverdict (pass); } [] serverPort.receive // any other message { setverdict(fail); } [] t_ack.timeout { setverdict(inconc); } } t_ack.stop; Detailed Comments:
30
Built-in and user-defined generic data types (e.g., to define messages, service primitives, information elements, PDUs) Actual test data transmitted/received during testing
Definition of the components and communication ports that are used to build various testing configurations
Specification of the dynamic test system behaviour
32
TTCN-3 Modules
Module () Module Definitions Module Control Attributes
34
Modules are the building blocks of all TTCN-3 specifications A test suite is a module A module has a definitions part and a control part Modules can be parameterized Modules can import definitions from other modules
// Control part
35
Module Definitions
Definitions are global to the entire module Data Type definitions are based on the TTCN-3 predefined types Templates and Signatures define the test data Ports and Components are used in Test Configurations Functions, Named Alts and Test Cases define behaviour
Data Types Constants RP Signatures Data Templates Signature Templates Communication Ports Test Components Functions Named Alternatives
Test Cases
36
Importing Definitions
// Importing single definitions import template MyTemplate from MyModule; // Importing definitions of the same kind import all template from MyModule; // Importing all definitions import all from MyModule; // inhibiting recursive import import template MyTemplate from MyModule nonrecursive; /* To avoid name clashes the imported definition is prefixed with the identifier of the source module */
37
External Definitions
// External constants may be defined
external const integer MyExternalConst;
38
Groups of Definitions
// A nested group of function definitions group MyTestStepLibrary { group MyGroup1 { function MyTestStep11 { } : function MyTestStep1n { } } group MyGroup2 { function MyTestStep21 { } : function MyTestStep2n { } } }
39
40
Sub-type
range, list
Basic string types Character string types User-defined structure types Special configuration types
41
/* integer sub-type as a mixed LIST and RANGE */ type integer MyIntegerListAndRange (1 ..5, 7, 9)
42
43
Arrays
/* Arrays are not considered to be types in TTCN-3. Instead, they are specified at the point of variable declaration */ // integer array of 5 elements var integer MyArray[5];
44
45
46
/* Constants are defined in the definitions part of a module (and inside functions and test components) */ constant integer MyConstant := 1; /* Variables can only be declared in the module control part (and inside functions and test components) TTCN-3 does not support global variables */ var hexstring MyHexString;
47
Data Templates
Templates are special data values that have the following characteristics matching mechanisms they can be parameterized
Are most often used to define the possible received values of messages and responses to remote procedure calls
49
Matching Mechanisms
Notation ( ... ) not ( ... ) Description Match a value in a list of values Match a value not in a list of values
(lower..upper)
? * ... <?> ... ... <*> ... length ifpresent
51
52
53
54
Modified Templates
// Writing template MyMessageType MyMessage1 { field1 123, field2 true } // and template MyMessageType MyMessage2 modifies MyMessage1 { field2 false } // Is the same as writing template MyMessageType MyMessage3 { field1 123, field2 false }
55
56
Procedure Signatures
/* Procedure signatures are needed for synchronous communication over procedurebased ports (remote procedure calls) */ signature MyRemoteProc ( in integer Par1, out float Par2, inout integer Par3 ) return integer exception (ExceptType1, ExceptType2);
57
Signature Templates
signature MyRemoteProc ( in integer Par1, out float Par2, inout integer Par3 ) return integer exception (ExceptType1, ExceptType2); /* templates may be used to define the actual parameters to a remote procedure call */ template MyRemoteProc Mytemplate := { Par1 := 7, Par2 := *, Par3 := MyConst }
58
59
Test Components
Test components are the entities on which test behaviour is executed (in parallel) Declarations may be made locally in the component A list of the ports used by the component must also be given Actual configurations are built dynamically in the test behaviour using operations such as create, connect etc.
Ports Used
60
Communication Ports
Test components communicate via communication ports A test port is modeled as an infinite FIFO queue Ports have direction (in, out, inout) There are three types of port message-based, procedure-based or mixed
P1 (out) P1 (in)
PTC1
P1.send(Msg)
PTC2
P1.receive(Msg)
62
63
64
65
66
TTCN-3 Functions
Functions are the building-blocks of test system behaviour Functions have local declarations and a program part Can be a 'pure' function doing some internal test system task or specify test behaviour using communication operations such as send and receive External functions are allowed There are some pre-defined functions (type conversion etc.)
67
Pre-defined Functions
Function Conversion functions
Convert bitstring value to integer value Convert hexstring value to integer value Convert octetstring value to integer value Convert charstring value to integer value Convert integer value to bitstring value bit2int hex2int oct2int str2int int2bit
Name
int2hex
int2oct int2str
Length functions
Return the length of a value of any string type Return number of elements in record, record of, template, set, set of lengthof sizeof
ispresent
ischosen 68
Function Definitions(1)
// Functions can be parameterised // in, out, inout paramters. Default is in function MyFunction (in integer MyPar) { : } // Functions can return values // Default is void function MyFunction return integer { : }
69
Function Definitions(2)
/* This function performs a generic task. It does not use any communication operations */ function MyFunction { : } /* This function uses communication operations consistent with the ports offered by MyPTC */ function MyFunction runs on MyPTC { : }
70
System Part
Behaviour Part
Expressions Assignment
Logging If-else statement For loop While loop Do loop Label definition Jump to label Stop execution of function or control Execute test case
(...) :=
log if (...) {...} else {...} for (...) {...} while (...) {...} do {...} while (...) label goto stop execute
75
76
Operators (1)
Category Operation
Arithmetic operators
addition
subtraction multiplication division modulo
concatenation equal not equal less than less than or equal greater than greater than or equal
Operators (2)
Category Operation
Logical operators
logical not
logical and logical or logical exclusive or
Symbol not and or xor not4b and4b or4b xor4b << >> <@ @>
78
Bitwise operators
Pre-defined Functions
Function Conversion functions
Convert bitstring value to integer value Convert hexstring value to integer value Convert octetstring value to integer value Convert charstring value to integer value Convert integer value to bitstring value Convert integer value to hexstring value Convert integer value to octetstring value Convert integer value to charstring value bit2int hex2int oct2int str2int int2bit int2hex int2oct int2str
Name
Length functions
Return the length of a value of any string type Return number of elements in record, record of, template, set, set of lengthof sizeof
Configuration Operations
Operation Keyword
create
connect
map
mtc system self start stop
done
81
Creating Components
The master test component (MTC) is the only component that is automatically created when the test case is executed
All parallel test components (PTCs) must be created explicitly using the create operation The create operation returns the unique component reference for the newly created component Components can be created at any point in a behaviour description
82
Example of Create
// Define a variable of type component type component MyComponentType { : }
83
IN
MyMTC
P1
OUT
P1
IN OUT Mapped Ports
MyPTC P2 PCO
IN
IN
OUT
SUT
84
/* The map operation is used to connect components to the abstract test system interface */ map(MyPTC:P2, system:PCO)
85
Asynchronous Communication
send MTC
receive PTC
non-blocking
blocking
87
88
89
Synchronous Communication
call MTC
getcall PTC
catch
check clear start stop
91
92
93
Behaviour Statements
Statement Sequential behaviour ... Keyword or symbol ... ; ... ; ... ;
Alternative behaviour
Interleaved behaviour Activate a default Deactivate a default Returning control
alt {}
interleave {} activate deactivate return
94
Behaviour Statements
// Sequential statements are denoted by a semi-colon function MyFunction1 { MyFunction2; x:=x+1; MyPort.receive(myMessage); // Blocks execution until message received MyPort.send(MyMessage) }
95
Alternative Behaviour
Alternative behaviour is defined using the alt statement alt statements may only be the receiving communication operations and timer events receive, trigger, getcall, getreply, catch, check, timeout
S1
S2 S4 S7 S9 S5 S8
S3
S6 S10
S1; alt {[ ] S3; S6; [ ] S2; alt { [ ] S4; S7; [ ] S5; S8; alt { [ ] S9; [ ] S10; } } }
96
[x>1] [x<1] }
98
Named Alternatives
Named alternatives (named alt) are descriptions of partial alternatives defined in the module definitions are named and may be parameterised
99
100
101
Default Behaviour
Default behaviour is defined using named alternatives Defaults must be explicitly activated and deactivated The expansion of defaults is applied to the end of the top-level set of alternatives in an alt statement and to all single receiving operations and timeouts // Note that the single statement L1.receive(MyMessage1); // is equivalent to alt { [] L1.receive(MyMessage1)}
102
Interleaved Behaviour
/* The interleave statement specifies all possible combinations of executing a given set of alternative statements */
interleave {
[] PCO1.receive(MyMessageOne);
[] PCO1.receive(MyMessageTwo); [] PCO1.receive(MyMessageThree); }
104
105
Additional Operations
Statement Timer operations Start timer start Yes Yes Keyword or symbol Module control part Functions and test cases
Stop timer
Read elapsed time Check timeout event Check timer status Verdict operations Set local verdict Get local verdict
stop
read timeout running
Yes
Yes Yes Yes
Yes
Yes Yes Yes Yes Yes Yes
106
SUT operations
Cause SUT action
Verdicts
Verdicts: pass, fail, inconc, none, error Each test component has its own local verdict can be written (set) and read (get) Global verdict returned by Test Case (read-only)
Verdict returned by the test case when it terminates
MTC
PTC1
PTC2
verdict.set(fail)
verdict.set(pass)
verdict.set(inconc)
107
Timer Operations
// Starting, stopping and reading a timer MyTimer.start(20E-3)// Default unit is seconds MyTimer.stop MyVar := MyTimer.read // Check if a timer is running if (MyTimer.running) { } // timeout in an alternative : [] MyTimer.timeout :
108
Module Control
Module control is the dynamic part of a TTCN-3 specification where test cases are executed (execute) Local declarations, such as variables and timers may be made in the control part Basic programming statements may be used to select and control the execution of the test cases
110
control { const hexstring MyConst := FF00H; var integer MyVar :=1; timer MyTimer; : }
:
111
control
{ } } // and executed in the control part execute (MyTestCase())
112
113
114
Defining Attributes
Special attributes can be associated with most TTCN-3 language elements using the with statement encoding information (encode) standardized: ASN.1 application specific, proprietary display information (display) standardized: tabular and MSC formats
Language Element
Attributes
or proprietary
user-defined (extension) proprietary
115
Example Attributes
type record MyPDU { integer field1, ia5string field2, boolean field3 } with { display ETSI Tabular := PDU; encode BER; extension MyRule }
116