[25] | 1 | # Commands covered: pid |
---|
| 2 | # |
---|
| 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. |
---|
| 6 | # |
---|
| 7 | # Copyright (c) 1991-1993 The Regents of the University of California. |
---|
| 8 | # Copyright (c) 1994-1995 Sun Microsystems, Inc. |
---|
| 9 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
| 10 | # |
---|
| 11 | # See the file "license.terms" for information on usage and redistribution |
---|
| 12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 13 | # |
---|
| 14 | # RCS: @(#) $Id: pid.test,v 1.12 2004/05/19 22:06:07 dkf Exp $ |
---|
| 15 | |
---|
| 16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
| 17 | package require tcltest 2 |
---|
| 18 | namespace import -force ::tcltest::* |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | testConstraint pidDefined [llength [info commands pid]] |
---|
| 22 | |
---|
| 23 | test pid-1.1 {pid command} pidDefined { |
---|
| 24 | regexp {(^[0-9]+$)|(^0x[0-9a-fA-F]+$)} [pid] |
---|
| 25 | } 1 |
---|
| 26 | test pid-1.2 {pid command} -constraints {unixOrPc unixExecs pidDefined} -setup { |
---|
| 27 | set path(test1) [makeFile {} test1] |
---|
| 28 | file delete $path(test1) |
---|
| 29 | } -body { |
---|
| 30 | set f [open |[list echo foo | cat >$path(test1)] w] |
---|
| 31 | set pids [pid $f] |
---|
| 32 | close $f |
---|
| 33 | list [llength $pids] [regexp {^[0-9]+$} [lindex $pids 0]] \ |
---|
| 34 | [regexp {^[0-9]+$} [lindex $pids 1]] \ |
---|
| 35 | [expr {[lindex $pids 0] == [lindex $pids 1]}] |
---|
| 36 | } -cleanup { |
---|
| 37 | removeFile test1 |
---|
| 38 | } -result {2 1 1 0} |
---|
| 39 | test pid-1.3 {pid command} -constraints pidDefined -setup { |
---|
| 40 | set path(test1) [makeFile {} test1] |
---|
| 41 | file delete $path(test1) |
---|
| 42 | } -body { |
---|
| 43 | set f [open $path(test1) w] |
---|
| 44 | set pids [pid $f] |
---|
| 45 | close $f |
---|
| 46 | set pids |
---|
| 47 | } -cleanup { |
---|
| 48 | removeFile test1 |
---|
| 49 | } -result {} |
---|
| 50 | test pid-1.4 {pid command} pidDefined { |
---|
| 51 | list [catch {pid a b} msg] $msg |
---|
| 52 | } {1 {wrong # args: should be "pid ?channelId?"}} |
---|
| 53 | test pid-1.5 {pid command} pidDefined { |
---|
| 54 | list [catch {pid gorp} msg] $msg |
---|
| 55 | } {1 {can not find channel named "gorp"}} |
---|
| 56 | |
---|
| 57 | # cleanup |
---|
| 58 | ::tcltest::cleanupTests |
---|
| 59 | return |
---|