summaryrefslogtreecommitdiff
path: root/tests/pid.test
blob: 211c893e59076856d739ddb979cbd284a0c1ff7b (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
# Commands covered:  pid
#
# 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

catch {unset x}

#exp_internal -f /dev/ttyp5 0

test pid-1.2 {basic pid operation} {
    set cat [exp_spawn -noecho cat]
    set x [expr 0!=$cat]
    set y [expr 0==[string compare $cat [exp_pid -i $spawn_id]]]
    exp_close;exp_wait
    list $x $y
} {1 1}

test pid-1.3 {basic pid operation} {
    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 pid-1.4 {basic pid operation} {
    list [catch {exp_pid -i 100} msg] $msg
} {1 {can not find channel named "100"}}

test pid-1.5 {basic pid operation} {
	list [catch {exp_pid -j} msg] $msg
} {1 {usage: -i spawn_id}}

cleanupTests
return