Data Declarations TTCN-3 allows the declarations of constants and variables. A constant is denoted

10.11.2 Data Declarations TTCN-3 allows the declarations of constants and variables. A constant is denoted

by the const keyword, and the value of the constant is assigned at the point of declaration. The value of a constant cannot be changed afterward.

TTCN-3 has its own scoping rules for all data definitions. All declarations made at the “top” level, that is, module level, are accessible throughout the module. Here, top level means before the control part. The concept of a “code block,” enclosed by a matching pair of curly braces, helps us understand scoping rules. Definitions made within a specific code block are only accessible within that code block, and identifiers are not reused in nested code blocks. In other words, there do not exist two data items with the same name but different scopes. No variable can be defined at the module level, and, therefore, all module-level declarations are constants. Absence of module-level variables means absence of global variables.

297 /* One can document a module by writing comments in this way. */

10.11 TESTING AND TEST CONTROL NOTATION VERSION 3 (TTCN-3)

// Additional comments can be included here. module ExampleTestModule1 { // A module can be empty.

// First, define some data to be used in the control part const integer MaxCount := 15; constant integer UnitPacket = 256; // More data can be defined here . . .

// Second, specify the control part to execute control { // The control part is optional var integer counter := 0; var integer loopcount := MaxCount; const integer PacketSize := UnitPacket * 4;

// Specify more execution behavior here . . . } // End of the control part

} // end of module TestCase1

Figure 10.26 Structure of module in TTCN-3.

Since a test case can have distributed components, it is difficult to guarantee the semantics of global variable across distributed test components.

TTCN-3 supports a powerful set of built-in types, such as integer, float, Boolean (universal), charstring, verdicttype, bitstring, hexstring, octetstring, objid, and default. Such a rich set of built-in types is essential to protocol testing. TTCN-3 also allows the definitions of structured types and list types from existing types. Constructs to define structured types are enumerated, record, set, and union. Simi- larly, constructs to define list types are array, set of, and record of.

TTCN-3 allows programmers to use the concept of data subtyping. Subtyping means restricting the values of a type to a subset of all values allowed by the original type. For example, given the set of all integers, one can create a subtype of all unsigned numbers that can be represented with 16 bits. Such a subtype is useful in representing port numbers while testing using TCP. Two examples of subtyping are shown in Figure 10.27, where TCPPort is a new user-defined type.

A variable of type TCPPort can take on values in the range 0, . . . , 65535. Similarly, IPUserProtocol is a subtype of charstring. A variable of type IPUserProtocol can take on values from the given set and not outside the set.

A PDU in a communication protocol can be defined using a record type. In some protocols, their PDUs are simply called messages. TTCN-3 allows one to

type integer TCPPort ( 0 .. 65535 ); // a 16 bit unsigned number type charstring IPUserProtocol ( ‘‘TCP’’, ‘‘UDP’’, ‘‘OSPF’’,

‘‘RIP’’ );

Figure 10.27 Definitions of two subtypes.

298 CHAPTER 10 TEST GENERATION FROM FSM MODELS

define a PDU field of arbitrary bit length. For example, one can define PDU fields of 1 bit, 4 bits, and 6 bits which are found in the packet header of IPv4 (Internet Protocol version 4). Often protocols put a limit on the length of some of the PDU fields. Such limits are easily expressed using the length attribute of variables.

One creates instances of those types by using concrete values after defin- ing a PDU or a message type. Such concrete instances have two applications: (i) send messages to a remote protocol entity and (ii) receive messages having the desired values. Concrete instances of message types are called templates in TTCN-3. TTCN-3 allows parameterization of templates for easily creating mes- sages. An example of a template is shown in Figure 10.28, where MyMessage is

a message type and SFCRequest is an instance of MyMessage. The MyMessage type consists of four fields. The response field can be omitted while creating an instance of the template.

An example definition of a response message of type MyMessage is shown in Figure 10.29. One can specify what message is expected to be received from

a SUT by defining a response message. The identification field can be used to associate a response message with a request message. A “?” value of the input field in the SFCResponse tells us that the field can contain any value, which is ignored. The response field in the received SFCResponse carries the actual value expected to be received from the SUT.

Dokumen yang terkait

ANALISIS DANA PIHAK KETIGA PADA PERBANKAN SYARIAH DI INDONESIA PERIODE TRIWULAN I 2002 – TRIWULAN IV 2007

40 502 17

ANALISIS KEMAMPUAN SISWA SMP DALAM MENYELESAIKAN SOAL PISA KONTEN SHAPE AND SPACE BERDASARKAN MODEL RASCH

69 778 11

Analisis Komparasi Internet Financial Local Government Reporting Pada Website Resmi Kabupaten dan Kota di Jawa Timur The Comparison Analysis of Internet Financial Local Government Reporting on Official Website of Regency and City in East Java

19 819 7

STUDI PENJADWALAN DAN RENCANA ANGGARAN BIAYA (RAB) PADA PROYEK PEMBANGUNAN PUSAT PERDAGANGAN CIREBON RAYA (PPCR) CIREBON – JAWA BARAT

34 235 1

PENGARUH PENGGUNAAN BLACKBERRY MESSENGER TERHADAP PERUBAHAN PERILAKU MAHASISWA DALAM INTERAKSI SOSIAL (Studi Pada Mahasiswa Jurusan Ilmu Komunikasi Angkatan 2008 Universitas Muhammadiyah Malang)

127 505 26

AN ANALYSIS OF DESCRIPTIVE TEXT WRITING COMPOSED BY THE HIGH AND THE LOW ACHIEVERS OF THE EIGHTH GRADE STUDENTS OF SMPN SUKORAMBI JEMBER

11 83 16

AN ANALYSIS OF LANGUAGE CONTENT IN THE SYLLABUS FOR ESP COURSE USING ESP APPROACH THE SECRETARY AND MANAGEMENT PROGRAM BUSINESS TRAINING CENTER (BTC) JEMBER IN ACADEMIC YEAR OF 2000 2001

3 95 76

A DISCOURSE ANALYSIS ON “SPA: REGAIN BALANCE OF YOUR INNER AND OUTER BEAUTY” IN THE JAKARTA POST ON 4 MARCH 2011

9 161 13

Improving the Eighth Year Students' Tense Achievement and Active Participation by Giving Positive Reinforcement at SMPN 1 Silo in the 2013/2014 Academic Year

7 202 3

THE INTEGRATION BETWEEN INDONESIA AND WORLD RICE MARKET

1 88 12