sl@0
|
1 |
# Commands covered: pid
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# This file contains a collection of tests for one or more of the Tcl
|
sl@0
|
4 |
# built-in commands. Sourcing this file into Tcl runs the tests and
|
sl@0
|
5 |
# generates output for errors. No output means no errors were found.
|
sl@0
|
6 |
#
|
sl@0
|
7 |
# Copyright (c) 1991-1993 The Regents of the University of California.
|
sl@0
|
8 |
# Copyright (c) 1994-1995 Sun Microsystems, Inc.
|
sl@0
|
9 |
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
# See the file "license.terms" for information on usage and redistribution
|
sl@0
|
12 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
13 |
#
|
sl@0
|
14 |
# RCS: @(#) $Id: pid.test,v 1.8.2.2 2004/02/25 23:38:17 dgp Exp $
|
sl@0
|
15 |
|
sl@0
|
16 |
if {[lsearch [namespace children] ::tcltest] == -1} {
|
sl@0
|
17 |
package require tcltest 2
|
sl@0
|
18 |
namespace import -force ::tcltest::*
|
sl@0
|
19 |
}
|
sl@0
|
20 |
|
sl@0
|
21 |
# If pid is not defined just return with no error
|
sl@0
|
22 |
# Some platforms may not have the pid command implemented
|
sl@0
|
23 |
if {[info commands pid] == ""} {
|
sl@0
|
24 |
puts "pid is not implemented for this machine"
|
sl@0
|
25 |
::tcltest::cleanupTests
|
sl@0
|
26 |
return
|
sl@0
|
27 |
}
|
sl@0
|
28 |
|
sl@0
|
29 |
test pid-1.1 {pid command} {
|
sl@0
|
30 |
regexp {(^[0-9]+$)|(^0x[0-9a-fA-F]+$)} [pid]
|
sl@0
|
31 |
} 1
|
sl@0
|
32 |
test pid-1.2 {pid command} -constraints {unixOrPc unixExecs} -setup {
|
sl@0
|
33 |
set path(test1) [makeFile {} test1]
|
sl@0
|
34 |
file delete $path(test1)
|
sl@0
|
35 |
} -body {
|
sl@0
|
36 |
set f [open |[list echo foo | cat >$path(test1)] w]
|
sl@0
|
37 |
set pids [pid $f]
|
sl@0
|
38 |
close $f
|
sl@0
|
39 |
list [llength $pids] [regexp {^[0-9]+$} [lindex $pids 0]] \
|
sl@0
|
40 |
[regexp {^[0-9]+$} [lindex $pids 1]] \
|
sl@0
|
41 |
[expr {[lindex $pids 0] == [lindex $pids 1]}]
|
sl@0
|
42 |
} -cleanup {
|
sl@0
|
43 |
removeFile test1
|
sl@0
|
44 |
} -result {2 1 1 0}
|
sl@0
|
45 |
test pid-1.3 {pid command} -setup {
|
sl@0
|
46 |
set path(test1) [makeFile {} test1]
|
sl@0
|
47 |
file delete $path(test1)
|
sl@0
|
48 |
} -body {
|
sl@0
|
49 |
set f [open $path(test1) w]
|
sl@0
|
50 |
set pids [pid $f]
|
sl@0
|
51 |
close $f
|
sl@0
|
52 |
set pids
|
sl@0
|
53 |
} -cleanup {
|
sl@0
|
54 |
removeFile test1
|
sl@0
|
55 |
} -result {}
|
sl@0
|
56 |
test pid-1.4 {pid command} {
|
sl@0
|
57 |
list [catch {pid a b} msg] $msg
|
sl@0
|
58 |
} {1 {wrong # args: should be "pid ?channelId?"}}
|
sl@0
|
59 |
test pid-1.5 {pid command} {
|
sl@0
|
60 |
list [catch {pid gorp} msg] $msg
|
sl@0
|
61 |
} {1 {can not find channel named "gorp"}}
|
sl@0
|
62 |
|
sl@0
|
63 |
# cleanup
|
sl@0
|
64 |
::tcltest::cleanupTests
|
sl@0
|
65 |
return
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
|