blob: 8f86d9522e8275b64c6f5295fd3be1378872aed3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# Commands covered: spawn
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
# do this in a way that is backward compatible for Tcl 8.3
namespace import ::tcltest::test ::tcltest::cleanupTests
}
package require Expect
log_user 0
#exp_internal -f /dev/ttyp5 0
test spawn-1.1 {basic spawn operation} {
set x [catch {exp_spawn cat}]
set first_spawn_id $spawn_id; # save for later test
exp_close;exp_wait
set x
} {0}
test spawn-1.2 {spawn cat, then simple send/expect sequence} {
set cat [exp_spawn -noecho cat -u]
exp_send "a\r"
expect "a" {set x 1} timeout {set x 0}
exp_close;exp_wait
set x
} {1}
test spawn-1.3 {spawn two processes simultaneously} {
exp_spawn -noecho cat; set cat $spawn_id
exp_spawn -noecho cat; set cat2 $spawn_id
set x [expr {0!=[string compare [exp_pid -i $cat2] [exp_pid -i $cat]]}]
exp_close -i $cat;exp_wait -i $cat;exp_close -i $cat2;exp_wait -i $cat2
set x
} {1}
test spawn-1.4 {spawn open file} {
set x 0
set y 0
set file [open /tmp/[pid] w]
puts $file "testing expect's spawn -open"
exp_close $file
set pid [exp_spawn -open [open /tmp/[pid]]]
expect "testing expect's spawn -open" {set x 1}
expect eof {set y 1}
exec rm /tmp/[pid]
exp_wait
list $x $y $pid
} {1 1 0}
test spawn-1.5 {spawn with no fd leak} {
exp_spawn cat
set x [expr {"$first_spawn_id"=="$spawn_id"}]
exp_close; exp_wait
set x
} {1}
# looks to be some control-char problem
#ftest spawn-1.6 {spawn with echo} {
# exp_spawn cat
#} {spawn cat}
#ftest spawn-1.7 {spawn with -noecho} {
# exp_spawn -noecho cat
#} {}
cleanupTests
return
|