Beruflich Dokumente
Kultur Dokumente
TTCN-3 Advanced
C u t y o u r s o ftw a re te s tin g e x p e n s e s
F u n c tio n a l b la c k -b o x te s ts a u to m a tio n
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Outline
Types in TTCN-3
Basic types String types Structured types (more common) TTCN-3 specific structured types
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Types in TTCN-3
Basic types integer
float boolean verdicttype objid (ASN.1)
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Float Type
values: signed real values - in standard values can be arbitrary large and use precision is not specified - examples: 0.0, 0.020, 20E-3 const float c_pi =0.03141592E2; // pi= 0.03141592... 10*2 The special values of the float type: float operators: - equality/inequality: ==, != - comparison: <, >, <=, >= - arithmetic: +, -, *, / infinity (positive infinity) - infinity (negative infinity) not_a_number
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Verdicttype Type
verdicttype type values: none, pass, inconc, fail, or error verdicttype operators: - equality/inequality: ==, !=
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Example Sub-typing
//list of values type bitstring MyBitstrings ('01'B, '10'B, '11'B); type integer SmallEvenNumbers (2,4,6,8,10); // ranges type integer ErrorCode (-2..-1); type char YourCharacters ("A" .. "Z", "a" .. "z"); // string length restrictions type bitstring LengthField length(8); type octetstring AddressField length(1..2); type charstring ThreeLetterWord length(3); // list and list of types type bitstring BitStrings1 ('0'B, '1'B ); type bitstring BitStrings2 ('00'B, '01'B, '10'B, '10'B); type bitstring BitStrings_1_2 (Bitstrings1, Bitstrings2);
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Structured Types
Structured Types enumerated type record type, ordered structure set type, unordered structure - order is not significant when comparing two values record of type - ordered list of values of one type set of type - unordered list of values of one type union type, collection of fields of which only one is present at a time - Used by defining user defined types
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Value // MyEnumType value := Monday; // MyRecord value // in assignment notation := { field1 := 42, field2 := false, field3 := '101'B } // in value list notation := { 42, false, '101'B } // MySet value notation is // the same as MyRecords
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
The Anytype
The type is defined as a shorthand for the union of all known data types and the address type in a TTCN-3 module. The anytype shall comprise all the known data types but not the port, component, and default types.
EXAMPLE:
var anytype v_atype; v_atype.integer := 42; v_atype.charstring := "Hello!"; v_atype := {charstring := Tere};
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Address
Special configuration type Address of specific entity of the SUT Used with to, from, sender of procedure-based communication operations Resolved either in TTCN-3 module (in type deifinition) or externally (it is left as an open type within TTCN-3 spec.) Example: type integer address; type record address { charstring ip_address, integer port_number }; MyPort.send(charstring:"My string") to MyPartner; // Sends the string "My string" to a component
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Default
Special default type default: holds a default reference default reference is the result of an activate operation Variables of type default can be used to handle activated defaults in test components. Default references are used in deactivate operations in order to identify the default to be deactivated. altstep MyAltStep2 ( integer par_value1, MyType par_value2, MyPortType par_port, timer par_timer ) .. function MyFunc () runs on MyCompType {: var default MyDefaultVar := null; MyDefaultVar := activate(MyAltStep2(5, myVar, myCompPort, myCompTimer); : }
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Type compatibility
Generally, TTCN-3 requires type compatibility of values at assignments and comparison. - For the purpose of this clause the actual value to be assigned, passed as parameter, etc., is called value "x". - The type of value "x" is called type "B". - The type of the formal parameter, which is to obtain the actual value of value "x" is called type "A".' type integer A; type integer B; var A i1 := 1; var B i2 := 2; I1 := i2; //assignment if (I1 == I2) {} //equal if (I2 != I1) {} //not equal
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Pattern in sub-typing
allowed for charstring and universal charstring
all values denoted by the pattern shall be a subset of the type being subtyped
type charstring MyString (pattern "abc*xyz"); // all permitted values of MyString have prefix abc and postfix xyz type universal charstring MyUString (pattern "*\r\n") // all permitted values of MyUString are terminated by CR/LF
charstring and universal charstring subtype definitions it is not allowed to mix pattern, value list, type list, or range constraints
type charstring MyCharStr0 ("gr", "xyz"); // character strings gr and xyz; type charstring MyCharStr1 ("a".."z"); // strings of arbitrary length containing characters a to z. type charstring MyCharStr6 ("a".."z") length (3..9); // strings of length from 3 to 9 characters and containing characters a to z
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Structured Types
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
permutation
boolean integer float bitstring octetstring hexstring character strings record record of array set set of enumerated uninon anytype
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + 2) + + + + + + + + + 2) + + +
+ + + + + + + + + + + + + + +
NOTE 1: Can be assigned to templates, however when used shall be applied to optional fields of record and set types only (without restriction on the type of that field). NOTE 2: Have matching mechanism meaning within character patterns only.
ifPresent 1)
value list
superset
omit 1)
pattern
subset
range
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Pattern
Character patterns can be used in templates to define the format of a required character string to be received Charstring & universal charstring types Example: type charstring MyString (pattern "abc*xyz"); // all permitted values of MyString have prefix abc and postfix xyz type charstring MyCharStr2 (pattern "[a-z]#(3,9)"); // mach at least 3, but not more than 9 chars from a-z
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Pattern Example
template charstring RegExp1:= pattern "[a-z]"; // this will match any character from a to z template charstring RegExp2:= pattern "[^a-z]"; // this will match any character except a to z template charstring RegExp3:= pattern "[AC-E][0-9][0-9][0-9]YKE"; // RegExp3 will match a string which starts with the letter A or a letter between // C and E (but not e.g. B) then has three digits and the letters YKE template charstring MyTemplate:= pattern "ab??xyz*0"; template charstring MyTemplate:= pattern "ab?\?xyz*";
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
In-line Template
Templates can be specified directly at the place they are used. Such templates are called in-line templates. In-line templates do not have names, therefore they can not be referenced or reused. The lifetime of in-line templates is the TTCN-3 statement (an assignment, a testcase/function/alstep, a return from a function, a communication operation), where they are defined. Syntactical Structure [ Type ":" ] [ modifies TemplateRefWithParList ":=" ] TemplateBody
C u t y o u r s o ftw a re te s tin g e x p e n s e s
// template for MyPDU template MyPDU a_PDU := { field1 := 42, field2 := true, field3 := omit }
// template for MyASP using // static parameterization template MyASP a_MyASP_1_s := { addr := 3055, payload := a_PDU } // usage in testcase etc. Port_M.send(a_MyASP_1_s);
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Modified Template
Normally, a template specifies a set of base or default values or matching symbols for each and every field defined in the appropriate type. In cases where small changes are needed to specify a new template, it is possible to specify a modified template. A modified template specifies modifications to particular fields of the original template, either directly or indirectly. As well as creating explicitly named modified templates, TTCN-3 allows the definition of in-line modified templates.
C u t y o u r s o ftw a re te s tin g e x p e n s e s
EXAMPLE : Modified record of template. template MyRecordOfType MyBaseTemplate := { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; template MyRecordOfType MyModifTemplate modifies MyBaseTemplate := { [2] := 3, [3] := 2 }; // MyModifTemplate shall match the sequence of values { 0, 1, 3, 2, 4, 5, 6, 7, 8, 9 }
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Template restrictions
Template restrictions allow to restrict the matching mechanisms that can be used with a template.
template "(" ( omit | present | value ) ")" Type template(omit) ExampleType exampleOmit := omit; template(omit) ExampleType exampleOmitValue:= { 1, true }; template(omit) ExampleType exampleOmitAny := ?; // incorrect template(value) ExampleType incorrect template(value) ExampleType template(value) ExampleType // omit assigned to a field exampleValueomit := omit; // exampleValue := { 1, true }; exampleValueOptional := { 1, omit }; is correct
C u t y o u r s o ftw a re te s tin g e x p e n s e s
sender
receiver
BLOCKING receive
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Procedure-based Communication
Communication operation Invoke procedure call Handle response from a previous call Catch exception (from called entity) Check call/exception/reply received Accept procedure call from remote entity Reply to procedure call from remote entity Raise exception (to an accepted call) Possible Sub-Types
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Sending Operations
The call operation specifies the call of a remote operation on another test component or within the SUT. A call is made (call), reply is sent (reply), or an exception is raised (raise) through port Syntactical Structure Port "." call "(" TemplateInstance [ "," CallTimerValue ] ")" [ to ( AddressRef | AddressRefList | all component ) ] EXAMPLE : Blocking call with timeout exception. MyPort.call(MyProc:{5,MyVar}, 20E-3) { [] MyPort.getreply(MyProc:{?, ?}) { } [] MyPort.catch(timeout) { // timeout exception after 20ms setverdict(fail); stop; } }
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Receiving Operations
A port accepts a procedure call (getcall), receives a reply for a previously called procedure (getreply), or catches an exception (catch). The getcall operation is used to accept calls. Syntactical Structure ( Port | any port ) "." getcall [ "(" TemplateInstance ")" ] [ from AddressRef ] [ "->" [ param "(" { ( VariableRef ":=" ParameterIdentifier ) "," } | { ( VariableRef | "-" ) "," } ")" ] [ sender VariableRef ] ]
EXAMPLE : Basic getcall. MyPort.getcall(MyProc:{5, MyVar}) from MyPeer; // accepts a call of MyProc at MyPort from MyPeer
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Signatures Declarations
Used to specify the procedure-based operation interface of the SUT - Functions/methods Signature is denoted by the keyword signature Declared in the module definitions part For blocking or non-blocking communication - Non-blocking signatures can have only in parameters and return no value Can have parameters with direction: - In, out, inout Can return a value or specify exceptions
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Signature Structure
Syntactical Structure signature SignatureIdentifier "(" { [ in | inout | out ] Type ValueParIdentifier [ ","] } ")" [ ( return Type ) | noblock ] [ exception "(" ExceptionTypeList ")" ]
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Example Signature
signature MyRemoteProcOne (); signature MyRemoteProcTwo () noblock; signature MyRemoteProcThree (in integer Par1, out float Par2, inout integer Par3); signature MyRemoteProcFour (in integer Par1) return integer; signature MyRemoteProcFive (inout float Par1) return integer exception (ExceptionType1, ExceptionType2); signature MyRemoteProcSix (in integer Par1) noblock exception (integer, float);
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Signature Templates
Instances of procedure parameter lists with actual values may be specified using templates. Templates may be defined for any procedure by referencing the associated signature definition. A signature template defines the values and matching mechanisms of the procedure parameters only, but not the return value. The values or matching mechanisms for a return have to be defined within the reply or getreply operation.
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Example Signature
EXAMPLE : Templates for invoking and accepting procedures. signature RemoteProc(in integer Par1, out integer Par2, inout integer Par3) return integer; template RemoteProc Template1:= { Par1 := 1, Par2 := 2, Par3 := 3 } template RemoteProc Template2:= { Par1 := 1, Par2 := ?, Par3 := 3 } template RemoteProc Template3:= { Par1 := 1, Par2 := ?, Par3 := ? }
C u t y o u r s o ftw a re te s tin g e x p e n s e s
getcall
CALLEE IUT
reply or raise exception
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
MyPort.getcall(MyProc:{?, ?}) from MyPartner -> param (MyPar1Var, MyPar2Var); // The in or inout parameter values of MyProc are assigned to MyPar1Var and MyPar2Var. signature MyProc2(in integer A, integer B, integer C, out integer D, inout integer E); MyPort.getcall(MyProc2:{?, ?, 3, - , ?}) -> param (MyVarA, MyVarB, - , -, MyVarE); // The parameters A, B, and E are assigned to the variables MyVarA, MyVarB, and MyVarE. The out parameter D needs not to be considered.
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
MyPort.raise(MySignature, "My string") to MyPartner; // Raises an exception with the value "My string" at MyPort for MySignature and send it to MyPartner
MyPort.raise(MySignature, "My string") to (MyPartnerOne, MyPartnerTwo); // Raises an exception with the value "My string" at MyPort and sends it to MyPartnerOne and MyPartnerTwo (i.e. multicast communication)
MyPort.raise(MySignature, "My string") to all component; // Raises an exception with the value "My string" at MyPort for MySignature and sends it to all entites connected to MyPort (i.e. broadcast communication)
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
The start operation enables sending and receiving operations on the port(s). MyPort.start; // starts MyPort
The stop operation disables sending and disallow receiving operations to match at the port(s). MyPort.stop; // stops MyPort
C u t y o u r s o ftw a re te s tin g e x p e n s e s
C u t y o u r s o ftw a re te s tin g e x p e n s e s
Thank you!
E-mail: elvior@elvior. com Website: www.elvior.com