tcltk編程及應(yīng)用簡介課件_第1頁
tcltk編程及應(yīng)用簡介課件_第2頁
tcltk編程及應(yīng)用簡介課件_第3頁
tcltk編程及應(yīng)用簡介課件_第4頁
tcltk編程及應(yīng)用簡介課件_第5頁
已閱讀5頁,還剩47頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

OutlinesProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Tcl/Tk

Around

Us

Tcl/Tk

Overview

Basic

Tcl

Syntax

Introduction

for

Tk

Introduction

for

Expect

Homebrew

Test

Automation

Framework

The

SUR

of

TAOProject

ResourcesPage

1Tcl/TkAround

UsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellPage

2FromWorkPlaceProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

In

WCS…

In

ITE/8610Using

Expect

to

communicate

with

WCS

:

send

CLI

commands

and

getresponse.

In

Cisco

IOSRouter>enableRouter#tclshRouter(tcl)#puts

$tcl_version8.3

Test

Automation

for

Telecommunication

and

Network

EquipmentsPage

3To

Our

Daily

Life

It’s

easy

to

design

handy

programsbased

on

Tcl

to

fulfill

different

tasksA

fish

screen

save

program…A

e-pianoA

Painting

padPage

4Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellTcl/TkOverviewProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell--Say

“tickletee-kay”

Page

5What’s

Tcl

Tcl

stands

for

Tool

Command

LanguageJoh

Ousterhout,

University

of

California.First

release

was

in1989.

A

simple

scripting

language:Cross

platform

support.

Tcl

can

run

on

most

popular

operation

system

suchas

unix/linux,

Windows,

Macintosh

and

so

forthScripts

are

interpreted

at

run

time.

Which

makes

the

development

cycle

fasterthan

compiled

languages,

no

waiting

for

long

compilationsThe

capability

to

call

C/C++routinesSimilar

to

other

shell

languages

such

as

UNIX

C

shell,

Perl,

VB.

“Easy”

tostudyExcellent

text

analysis

competencePage

6Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellWhat’s

Tcl

(cont’)Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Un-typed

and

a

string-based

command

languageData

types

are

not

used

when

variables

are

defined.

You

needn’t

specifya

variable

as

integer,

float

or

astring.The

basic

mechanisms

are

all

related

to

strings

and

stringsubstitutionsAll

variables

are

stored

asstrings.automatic

type

conversion

in

contextset

x

10

;#create

a

variable

“x”

and

give

a

value

“10”

to

itset

y

20;

#create

a

variable

“y”

and

give

a

value

“20”

to

itset

z

[

expr

$x

+

$y]

;#

x

plus

y

and

save

result

in

“z”set

y

“I’m

a

string

now.

Indeed

I’m

always

string:-)”puts

“Expression

result

is:

$z”;

#print

result

on

standard

outputs

“Y

becomes

as:

\”$y\””set

aArray

“Jack

boy

Merry

girl”

;#

define

anarrayputs

“I’m

an

array,

but

a

string

indeed:\n

$aArray”Page

7What’s

Tcl

(cont’)Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Easy

to

extendThere

are

numerous

free

extensions

built

on

top

of

Tcl/Tk

for

specificfunctions

available

on

the

Internet.Tclx:

Handling

signal

eventsNet-Snmp

:support

snmpcommuninicationBWidget/IWidget

etc.:

Tk

extensions

provides

special

and

powerful

widgetsHttp

&

ncgi:

for

http

server

programmingIt

is

easy

to

add

new

Tcl

primitives

by

writing

C

proceduresTcl/Tk

is

Pure

COpen-Source

code,

new

Tcl

commands

can

beimplementedby

specific

extensions

programmed

in

C

,

fairly

easy

without

changing

Tclcore.

Totally

Free!Page

8What’s

TkProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

TkA

Tcl-based

toolkit

for

programming

graphical

user

interfacesQuick

and

easy

to

build

powerful

user

interfaces.Portable

,

one

copy

of

script

can

work

unchanged

on

UNIX,Windows,

and

the

Macintosh.Page

9What’s

Expect

ExpectATcl-based

Toolkit

for

AutomatingInteractive

ProgramsThe

program

interactively

promptand

expect

user

to

enterkeystrokes

inresponseA

default

command

in

someoperation

systemsThere’s

also

an

Expect

extensionfor

tcl

which

can

also

be

loaded

totclshellPage

10Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellTcl

not

so

good

newsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Interpreted

languages

run

slower

and

use

more

processing

time

oParge

11overhead

Without

a

complier,syntax

errors

can’t

be

found

until

the

script

isexecuted

Un-typed

languages

do

not

allow

for

the

most

efficient

translation

ofcodeBasic

Tcl

SyntaxProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellPage

12Tcl

Commands’

FormatProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

A

Tcl

script

consists

of

one

or

more

commandsCommands

are

separated

by

newlines

or

semi-colonsA

script

with

two

commands

separated

by

a

newlinecharacter:set

a

24set

b

25Above

script

could

be

written

on

a

single

line

using

a

semi-colonseparator:set

a

24;

set

b

25Basically

each

command

consists

of

one

or

more

wordsFirst

word

is

the

name

of

a

commandAdditional

words

are

arguments

to

that

commandWords

are

separated

by

spaces

and

tabs<Command>

[var1

[var2

[…]]]Page

13VariableProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Needn’t

declare

the

type

of

variable,

automatic

conversion

incontextset

x

“10.99”;

#

this

is

astringputs

“[expr

int($x)]”;#

output

would

be

10

Need

to

be

declared

and

assigned

a

value

before

use

Variable

name

is

case-sensitive

Assignment

expression

:

set

<var

name>

<value:

a

string

indeed>

To

use

value

of

a

variable,

put

a

“$”

ahead

of

it

as

$<var

name>If

you

want

to

append

extra

characters

to

a

variable,

use

braces

aroundvariable

name

as:set

x

“Hello

”puts

“$xJack!”;

#

This

is

wrong,

it

would

treat

xJack

as

variable

nameputs

“${x}Jack!”;#This

is

right!

Different

scopes

should

share

variable

values

by

specificmethods.namespaceprocedureTo

use

global

to

visit

global

variableschildren

interpreterPage

14CommentsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Comment

is

set

in

a

shell

way,

leading

by

a

“#”set

a(“john”)

boy

;#Set

value

of

element

“john”

of

array

“a”

as“boy”#

Or

we

can

do

asarray

set

a

“johnboy”;#If

you

lik,

you

can\comment

using

multi-lines

Be

careful

when

add

comments

to

a

“switch”

expressionswitch

var

{“go”

{to

handle

go}#

If

it

does

not

support

following

value,

comment

it

later:

=>Wrong!“pause{…}..}Page

15Standard

Output

&

InputProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

I/O

operation

for

standard

input

and

output,

normally

the

terminalPainge

16front

of

us.

Print

out

onterminal:puts“abcdefg No

Thanks.”

Format

the

string

by

using

“format”

commandSimilar

as

Cset

str

[format“%-2d%20s%9d”,

193

{

is

not

equal

to

}

0133];#octal

number“193 is

not

equal

to

91”

Get

input:puts

-nonewline

“Your

name

please:”gets

stdin

sNameMath

and

Logical

ExpressionProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

exprexpr

<math

expression>expr

1

+

2;

set

x

10;

set

y

20;

expr

$x

+

$y

=>

30expr

abs(-10)=>

10expr

10

*

rand()

=>

9.06197207004855;#result

is

double

,

0<

value

<10expr

int(8

*

rand())

=>

5

;#

in

range

of

0~7

incrset

x

1incr

x

=>

2incr

x

3

=>

5incr

x

-2

=>

3logic

“and”

“or”

...Page

17Control:

Branch

and

LoopProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

If

..[elseif...[else..]]if

{Boolean

expression}

{}if

{xxx}

{ }

else

{}if

{xxx}

{}elseif

{}

{}

else

{}Forset

sum

0;for

{set

i

0;set

y

10}{$i<10}{incr

i}

{set

sum

[expr

$sum

+

$i

*$y]}puts

“sum

is

$sum”

=>

450Whilewhile

{[gets

$fd

line]

>=0}

{}Switchswitch

-exact

$xyz

{“0”

{…;?break?;}“1”

{…}?default

{…}?}Foreach

(refer

to

operationoflist)Page

18List,

Array

&

OperationProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell“l(fā)ist”

represent

a

list

ofstringCommands

for

listlist,

lindex,

lrange,

lappend,

lreplacesplit,

joinArray

is

similar

as

the

“associate”array

or

hash

data

in

perl

or

php.%set

lst1

“Jack

boy

blue

Merry

girl

red”;

#or%set

lst2

[list

Red

White

Yellow

Blue]%foreach

x

$lst

{puts“$x\n”}%foreach

{x

y

z}

$lst1

{puts

"student

name:

$x,

a

$y,

who

likes

$z"}student

name:

Jack,

a

boy,

who

likes

bluestudent

name:

Merry,

a

girl,

who

likes

redputs

[lindex

$lst2

2]

=>

Whiteputs

[lindex

$lst2

0]

=>

Red%%array

set

aArr

[list

Jack

boy

Merrygirl]%parray

aArraArr(Jack)

=

boyaArr(Merry)

=

girl%array

get

aArrJack

boy

Merry

girl%array

names

aArrJack

Merry%array

size

aArr2%foreach

{x

y}

[array

get

aArr]

{puts

"Name:

$x,

a

$y"}Name:

Jack,

a

boyName:

Merry,

a

girlPage

19String

&

OperationProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bellappendformatsubststringcommandstringcomparestringmatchstring

equal

(added

in

8.4)stringrangestringtolower/toupperstring

trimstringcomparation:if

{$str1

==

$str2

}

{puts

equal}string

comparing

commands

such

as“stringmatch”string

class

check:string

isif

{string

is

integer

10

}

{puts

ok}Page

20Proc

andReturnProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bellreturn

[expr

$opa

+

$opb]

}proc

calc1

{opa “opb

10”}

{calc1

2

3

=>

5calc1

2

=>

12proc

calc2

{args}

{

;#

Vary

argument

listset

opa

[lindex

$args

0]set

opb

[lindex

$args

1]return

[expr

$opa

+

$opb]}global

variableIn

a

procedure,

use“global

<var

name>”

to

make

a

global

variablevisible

from

inside

ofprocedure

Procedure

in

tcl

similar

as

function

in

C,

perl,

php,

unix

shell

etc.Page21proc

{[arg1]

[arg2]...[args]}

{proc

body}return

[string]File

I/OProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Writefile%

set

fd

[open

abc

w+]=>filef76ec0%

puts

$fd"abcd\n"%

puts

$fd"efgt\n"%

flush

$fd%

close

$fdReadfile%set

fd

[open

abc

r]=>filef840d8Get

file

content

line

by

line%

while

{[gets

$fd

line]

!=

-1}

{>

puts

-nonewline$line}=>abcdefgtRead

commandread

<file

handle>

?chunk

bytes?set

str

[read

$fd]while

{![eof

$fd]}

{svet

buf

[read

$fd10000]...}Page

22Socket

&

File

Event

socket

?-myaddr

addr??-myport

myport??-async?

host

port

socket

-server

command

?-myaddr

addr?

portproc

Accept

{

newSock

addr

port}

{global

sock_arrputs

"Accepted

$newSock

from

$addr

port$port"setsock_arr(addr,$newSock)

[list

$addr

$port]fconfigure

$newSock

-blocking

0

–bufferingnonefileevent

$newSock

readable

[list

Echo$newSock]}NOTE:

“port”

specified

here

is

the

“l(fā)istening”

port

which

can’t

be

used

to

transfer

data.

As

theconnection

request

is

accepted,

a

new

socket

will

be

created

for

transportdata.set

status

[catch

{

socket

-server

Accept

$SERVER_PORT

}

ss]if

{!$status}

{set

sock_arr(main)

$ssputs

"Create

server

socket

success.

Server's

socketis

$ss"}

else

{error

"Create

server's

socket

failed:

$ss"}proc

Echo

{sock}

{global

sock_arrif

{

[eof

$sock]

||

[catch

{gets

$sockline}]}

{return}puts

$sock

[string

toupper

$line]flush

$sock}Page

23Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellVariable

interpolationProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Happens

in

double

quote

“”

and

normal

expressionsset

x“Hello”puts

“$xJack!”set

y

[list

$xJack]“!”

Interpolation

would

be

prohibited

in

most

kinds

of

braces

{}puts

{$x

Jack}the

result

would

be

:$x

Jack

It’s

not

always

such

thing

for

brace,

brace

in

some

command

willnot

prohibit

variable

replacement

:catch

{

}

errforifPage

24Error

Handling

&

DiagnosticProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Multi-line

commandset

x

[list

Nanjing

Beijing\[list

Shen

Yang]

\Dalian]Should

no

special

character

except

for

carriage-return/newlineShould

not

put

comment

after

\

the“catch”

commandcatch

{command}<variable>catch

errors,

but

would

not

break

the

processerror

information

to

be

saved

as

<variable>

the

“errorInfo”

global

variableStore

error

information

the“error”

commanderror

command

can

cause

anerror,error

“l(fā)ine

50

broken

for

mismatched

value”=>

This

error

can

be

captured

by

“catch”

command

and

return

1,

and

error

string

will

be

set

toerrorInfo.Page

25Regular

Expression

Syntax

-

CommandsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bellregexpregexp

?flags?

pattern

string

?match

sub1

sub2...?#

Get

IP

address

out,

and

last

numberregexp

{[0-9]{1,3}\.[0-9]{1,3}\.[[:digit:]]+\.([[:digit:]]{1,3})}

"IP

Address:"

sMatch

sVar1regsubregsub

?switches?

pattern

string

subspec

varnamePage

26Regular

Expression

Syntax

-

BasicProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellMatchingcharactersMost

characters

simply

match

themselvesthe

period,

“.”

,matches

any

single

characterab

matches

ab;

“a.”

match

an

a

followed

by

anycharactor.Character

sets

[

][a-z]

matches

any

character

in

this

range[^a-z]

matches

any

character

isn’t

in

this

range,

^

=

not[][]

matches

]

or

[Quantifiers*

for

zero

or

more:

a*

matches

zero

or

more

a’s.“.*”

matches

anything

+

for

once

or

more

:

a+

matches

a,

aa,aa...a? zero

or

one:

a?

matches

zero

or

one

aAlternation

(or

branch)(H|h)ello

matches

Hello

and

hello,

same

as

hello|HelloAnchor^:

matches

the

beginning

of

a

string$:

matches

to

the

end

of

a

string:

^.*$

matches

a

whole

line

with

anything,

even

empty

lineBachslash

QuotingTo

turn

off

special

means

of

following

character:.

*

?

+

[

]

(

)

^

$

|

\Capturing

sub-patternsgrouped

with

parentheses“^I’m.*

IP

address

(\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+)$”NOTE:

sub-patterns

will

be

captured

and

save

in

specific

variables.

If

use

(?:pattern),

pattern

will

becaptured

but

not

saved,

command

will

befasterPage

27Regular

Expression

Syntax

-

AdvancedProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bellcharacter

classes[[:digit:]]

=[0-9]=\d[[:alpha:]]

=[A-Za-z][[:space:]]=[

\b\f\n\r\t\v]

=\sNongreedy

QuantifiersBy

default

quantifier

+

*

?

will

match

as

many

characters

as

possible.Use

“?”

behind

them

can

prohibit

such.+\n

matches

as

many

lines

as

possible

till

last

line.+?\n

matches

just

one

lineBound

Quantifiers{m,n}

matches

latest

m

times,

and

maximum

n

timesBack

referencesNOTE:

regsub

does

not

support

the

function

of

using

back-referencesoutside

of

regular

expression

in

perls/(\S+)\s+(\S+)/$2

$1/Page

28SignalProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Belltrap

{call

back

scripts}sig_nametrap

{

puts

“bye

bye”;exit}

SIGINTSIGHUPHang

up

PagSIGINTInterruptSIGQUITquitSIGKILLkillSIGPIPESIGTERMSIGSTOPSIGTSTPSIGCONTSIGHLDSIGWINCHwindow

size

changeSIGUSR1SIGUSR2e

29Time

Event:

the

after

commandproc

Circle

{}

{global

switcherif

{

$switcher

==

"off"

}

{#

kill

all

after

event,

and

thenreturn}#

do

something

for

repeatafter

1000

Circle}after

millisecondsafter

ms

arg

?arg...?after

cancelidafter

cancel

commandafter

idle

commandafter

info?id?Page

30Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellIntroduction

forTkProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellPage

31Create

children

widgetsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Window

is

organized

in

a

hierarchyA

primary

window

--

the

root

of

the

hierarchy,

is

the

main

window

of

theapplication

named

as

“.”

.Widgets

in

primary

window

are

it’s

children

window,

named

as“.<name>”And

child

window

can

has

it’s

own

children

...“.<name>.<name2>...”First

charactor

of

<name>

should

be

in

lower-case

or

a

digitalnumberframe

.fButframe

.fText.fBut

configure

-borderwidth

1

;

.fText

configure

-borderwidth

1entry

.fBut.eEnt

-width

20set

bBut

[button

.fBut.bHello

-text

"

HELLO!

"].fBut.eEnt

configure

-bg

pink.fBut.bHello

configure

-command

{.fBut.eEnt

insert

end

"hello!";

.fText.tText

insert

end

"

Hello

"}set

tTr

[text

.fText.tText

-yscrollcommand

".fText.yscroll

set

"

-xscrollcommand

".fText.xscroll

set

"]$tTr

configure

-width

40

-height

20

-foreground

brown

-wrap

wordscrollbar

.fText.yscroll

-command

"$tTr

yview"

-orient

verticalscrollbar

.fText.xscroll

-command

"$tTr

xview"

-orient

horizontalPage

32Display

WidgetsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellPut

and

display

widgets

in

main

window:.fBut

: a

Framework

contains

a

single

line

text

input

entry.fText

: a

Framework

contains

a

text

will

scrollbar.fBut.eEnt

:

The

entryset

bBut

.fBut.bHello

:

A

buttonset

tTr

.fText.text

:

Text

body.fText.yscroll

:

X

scroll

bar

(horizontal).fText.xscroll

:

Y

scroll

bar

(vertical)Three

main

geometry

managerpack

:

constraint-based

geometry

managergrid

:

control

indetailplace:

place

a

widget

in

another

onepack

.fBut

.fText

-side

left

-fill

both

-expand

truegrid

.fBut.eEnt

-sticky

newsgrid

$bBut

-stickynewsgrid

$tTr

.fText.yscroll

-sticky

newsgrid

.fText.xscroll

-sticky

ewgrid

rowconfigure

.fText

0

-weight

1grid

columnconfigure

.fText

0

-weight

1grid

propagate

.fText

falsePage

33A

Simple

MenuProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bellmenubutton

.mb

-text

File

-menu

.mb.menupack

.mb

-padx

10

-pady

10set

m

[menu

.mb.menu

-tearoff

1]$m

add

command

-label

Hello

-command

{puts

"Hello,

World!"}$m

add

check

-label

Boolean

-variable

foo

\-command

{puts

"foo

=$foo"}$m

addseparator$m

add

cascade

-label

Fruit

-menu

$m.sub1set

m2

[menu

$m.sub1

-tearoff

0]$m2

add

radio

-label

apple

-variable

fruit

-valueapple$m2

add

radio

-label

orange

-variable

fruit

-valueorange$m2

add

radio

-label

kiwi

-variable

fruit

-value

kiwinote:

to

add

menu

inBsPmMonitorGuiPage

34Introduction

for

ExpectProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellPage

35Expect

Commands

SyntaxProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bellspawnspawn

telnet

<ip>return

a

pidsave

handle

in

local

variable“spawn_id”sendalias

of

exp_sendWhen

use

together

with

Tk,exp_send

is

prefer.expectexpect

{-re

“Password:”

{}-re

“User

Name:”

{...exp_continue}eof

{}timeout

{}}interactcloseexp_internal

<-f

file>0|1log_file

<file

name>

options

of

“send”-hset

send_human

{.1

.3

1

.05

2}set

send_human

{.4

.4

.2

.5

100}send

-sset

send_slow

{10,.001}

timeoutPage

36user_spawn_iduser_spawn_idfifooutspawn_idinuser_spawn_iduser_spawn_idinoutspawn_id

No.

1fifoinoutspawn_id

No.

2ExpectExpectfifoinoutfifostandard

I/OPage

37Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellExample

1:

Manipulate

MGWautomaticallyspawn

<ip

of

mgw>expect

"Login:“send“root\r\n”expect

“Password:”send“root\n\r”expect“>”send“send

13,1:connect\r\n”expect

-timeout

5

-re“connect.*C>”send“help\r\n”expect

–timeout

3

“C>”spawn

<ip

of

mgw>expect

{"Login:“

{exp_send

“root\r\n”exp_continue}“Password:”

{exp_send

“root\n\r”exp_continue}-re“>”

{exp_send

“send

13,1:connect\r\n”puts

“connect

ok”}timeout

{puts

“timeout”}eof

{

puts

“sessionbroken”}}Page

38Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellTest

AutomationwithProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellTcl/Tk

and

ExpectPage

39Manul

TestTest

Simulatoranalyzes

traffic/signalingSNMP/CLI/WEMSUTsends

traffic/signalingOther

EM...controlscontrolscontrolsTest

Management

DBTest

Engineerfeedback

test

results

andupdatetest

statustests

to

doProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellTest

Equipment

(

ITE,

EAST...

)System

Under

TestElement

ManagerTest

management

Data

BasePage

40Example

Test

ScenarioInstall

patchesConfigure

SystemChange

Specific

configCleanup

ConfigurationPatch

fallbackSpecific

ConfigurationInvoke

Test

ToolVerify

result?Calling

TestToolVerify

result?Pass/FailPass/failPage

41Product

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellAutomationSimulatoranalyzes

traffic/signalingSNMP/CLI/WEMSUTsends

traffic/signalingOther

EM...controlscontrolscontrolsTest

Management

DBTest

Scriptsfeedback

test

results

andupdatetest

statustests

to

doProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

BellTest

Equipment

(

ITE,

EAST...

)System

Under

TestElement

ManagerTest

management

Data

BasePage

42Thinking

About

Automation:

MethodsProduct

Test

Shanghai

/

April

2010All

rights

reserved

?

2010,

Alcatel

Shanghai

Bell

Test

HarnessEditorExecutionExecute

test

scripts

in

specificflow/sequenceConfigurationStart/Pause/StopStatus

monitor

:

pass/failure

TC

number

andlistLogReportCompatibleTest-case

language

independent[Additional:

Test

requirement

mgmt]

Test Script

and

Data

MethodLined

script

--data

hardcode

with

script

,

script

can’t

besharedCapture-Playback

--data

hardcode

with

script,

script

can’t

be

sharedShared

scriptData-driven

(few

data

drives

scripts)Table-driven

(huge

data

drives

samescripts)Try

to

detach

data

from

scriptsKey-word

driven

...Page

43Thinking

About

Automation:

Variable

Test

Multi-Path

instead

of

static/single

pathPage

44Product

Test

Shanghai

/

April

2010All

rights

r

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論