Matching long strings doesn't work
- From: zwenneh@xxxxxxxxxxx
- Date: 31 Aug 2006 06:39:25 -0700
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
.
- Follow-Ups:
- Re: Matching long strings doesn't work
- From: Larry W. Virden
- Re: Matching long strings doesn't work
- From: Robert Joy
- Re: Matching long strings doesn't work
- Prev by Date: Re: ttk::button missing a -anchor option?
- Next by Date: Re: A good menu tutorial?
- Previous by thread: Creating nested safe interpreters and load Tk into it
- Next by thread: Re: Matching long strings doesn't work
- Index(es):