os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/pid.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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.8.2.2 2004/02/25 23:38:17 dgp Exp $
    15 
    16 if {[lsearch [namespace children] ::tcltest] == -1} {
    17     package require tcltest 2
    18     namespace import -force ::tcltest::*
    19 }
    20 
    21 # If pid is not defined just return with no error
    22 # Some platforms may not have the pid command implemented
    23 if {[info commands pid] == ""} {
    24     puts "pid is not implemented for this machine"
    25     ::tcltest::cleanupTests
    26     return
    27 }
    28 
    29 test pid-1.1 {pid command} {
    30     regexp {(^[0-9]+$)|(^0x[0-9a-fA-F]+$)} [pid]
    31 } 1
    32 test pid-1.2 {pid command} -constraints {unixOrPc unixExecs} -setup {
    33     set path(test1) [makeFile {} test1]
    34     file delete $path(test1)
    35 } -body {
    36     set f [open |[list echo foo | cat >$path(test1)] w]
    37     set pids [pid $f]
    38     close $f
    39     list [llength $pids] [regexp {^[0-9]+$} [lindex $pids 0]] \
    40        [regexp {^[0-9]+$} [lindex $pids 1]] \
    41        [expr {[lindex $pids 0] == [lindex $pids 1]}]
    42 } -cleanup {
    43     removeFile test1
    44 } -result {2 1 1 0}
    45 test pid-1.3 {pid command} -setup {
    46     set path(test1) [makeFile {} test1]
    47     file delete $path(test1)
    48 } -body {
    49     set f [open $path(test1) w]
    50     set pids [pid $f]
    51     close $f
    52     set pids
    53 } -cleanup {
    54     removeFile test1
    55 } -result {}
    56 test pid-1.4 {pid command} {
    57     list [catch {pid a b} msg] $msg
    58 } {1 {wrong # args: should be "pid ?channelId?"}}
    59 test pid-1.5 {pid command} {
    60     list [catch {pid gorp} msg] $msg
    61 } {1 {can not find channel named "gorp"}}
    62 
    63 # cleanup
    64 ::tcltest::cleanupTests
    65 return
    66 
    67 
    68 
    69 
    70 
    71 
    72 
    73 
    74 
    75 
    76 
    77