Re: Matching long strings doesn't work
- From: Robert Joy <robert@xxxxxxxxx>
- Date: Thu, 31 Aug 2006 09:11:23 -0700
zwenneh@xxxxxxxxxxx wrote:
I'm working on a program that has a command line. Now the users of this
program have requested that we extend the command line to support
longer commands, ie go from 1024 to 16K characters. My problem is that
when I write Expect scripts to perform automated tests, the scripts
fail to send commands of that length.
There's nothing wrong with the program I'm testing, I've tested it
quite a lot (manually, you can imagine), but of course I want the
Expect tests to work.
Below here is one version of the script I'm testing. I'm telnetting
into another computer, and on that computer I run the command-line
program ncli. I then try to verify that it echoes what I enter, but the
problem is that it doesn't: It seems to have a problem sending more
than 1000 chars _into_ the program/prompt, hence what is echoed is not
the full string, and the test times out. I've tried to use "slow
sending", and that helps me increase the number of chars to ~2500, but
it seems to stop there. As I said, there is no problem to enter 16K
chars manually, so there is something wrong with either Expect, the
Unix shell, or something else.
Has anybody encountered problems similar to this?
# script begins
#!/vobs/cello/cade_struct/bin/expect -f
# Author Sven
# I usually telnet to the same computer, but I can change if I want to.
if {[llength $argv] == 0 } { set ip "134.138.83.39" }
if {[llength $argv] == 1 } { set ip $argv }
# set up super long string to send, just lots of t's.
set longString ""
for { set i 0 } { $i < 16383 } { incr i } {
set longString "t$longString"
}
set passed 0
# logging in to the node
spawn telnet $ip
expect "username:"
send "x\r"
expect "password:"
send "x\r"
expect "Welcome"
expect "$"
# start ncli
send "ncli\r"
expect ">"
match_max 131072 # just to be on the safe side
send $longString"\r"
expect "NOT ACCEPTED" {set passed 1}
if { $passed == 0} { puts "Test Failed" }
if { $passed ==1 } { puts "Test OK" }
# exit ncli, then close the telnet connection
send "exit\r"
send "exit\r"
# script ends
I know you tried send slow but the parameters you enter are very important. Try:
set send_slow {1 .01}
and see if that helps. Make sure you set send_slow locally. I've done a lot of expecting with telnet and have found that many receiving devices act really strange if you try to send too fast. If that doesn't help try:
set send_slow {1 .1}
It's going to take a long time to send out 16K characters but give it a shot.
Btw, match_max will only affect your matching not the sending business.
Robert Joy
.
- References:
- Matching long strings doesn't work
- From: zwenneh
- Matching long strings doesn't work
- Prev by Date: Re: A good menu tutorial?
- Next by Date: Re: Embedding Tk in an MFC application
- Previous by thread: Matching long strings doesn't work
- Next by thread: Re: Matching long strings doesn't work
- Index(es):
Relevant Pages
|