1 # Commands covered: spawn
3 # This file contains a collection of tests for one or more of the Tcl
4 # built-in commands. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 if {[lsearch [namespace children] ::tcltest] == -1} {
8 package require tcltest
9 # do this in a way that is backward compatible for Tcl 8.3
10 namespace import ::tcltest::test ::tcltest::cleanupTests
12 package require Expect
16 #exp_internal -f /dev/ttyp5 0
18 test spawn-1.1 {basic spawn operation} {
19 set x [catch {exp_spawn cat}]
20 set first_spawn_id $spawn_id; # save for later test
25 test spawn-1.2 {spawn cat, then simple send/expect sequence} {
26 set cat [exp_spawn -noecho cat -u]
28 expect "a" {set x 1} timeout {set x 0}
33 test spawn-1.3 {spawn two processes simultaneously} {
34 exp_spawn -noecho cat; set cat $spawn_id
35 exp_spawn -noecho cat; set cat2 $spawn_id
36 set x [expr {0!=[string compare [exp_pid -i $cat2] [exp_pid -i $cat]]}]
37 exp_close -i $cat;exp_wait -i $cat;exp_close -i $cat2;exp_wait -i $cat2
41 test spawn-1.4 {spawn open file} {
45 set file [open /tmp/[pid] w]
46 puts $file "testing expect's spawn -open"
48 set pid [exp_spawn -open [open /tmp/[pid]]]
49 expect "testing expect's spawn -open" {set x 1}
56 test spawn-1.5 {spawn with no fd leak} {
58 set x [expr {"$first_spawn_id"=="$spawn_id"}]
63 # looks to be some control-char problem
64 #ftest spawn-1.6 {spawn with echo} {
68 #ftest spawn-1.7 {spawn with -noecho} {
69 # exp_spawn -noecho cat