Tcl Source Code

Hex Artifact Content
Login

Artifact 6d39aa276fc4671794dbf3ffa1e149df3e816a92d9ea5a48faca8dd0bec24ae6:


0000: 23 20 54 68 69 73 20 66 69 6c 65 20 74 65 73 74  # This file test
0010: 73 20 74 68 65 20 74 63 6c 55 6e 69 78 46 43 6d  s the tclUnixFCm
0020: 64 2e 63 20 66 69 6c 65 2e 0a 23 0a 23 20 54 68  d.c file..#.# Th
0030: 69 73 20 66 69 6c 65 20 63 6f 6e 74 61 69 6e 73  is file contains
0040: 20 61 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 6f 66   a collection of
0050: 20 74 65 73 74 73 20 66 6f 72 20 6f 6e 65 20 6f   tests for one o
0060: 72 20 6d 6f 72 65 20 6f 66 20 74 68 65 20 54 63  r more of the Tc
0070: 6c 0a 23 20 62 75 69 6c 74 2d 69 6e 20 63 6f 6d  l.# built-in com
0080: 6d 61 6e 64 73 2e 20 20 53 6f 75 72 63 69 6e 67  mands.  Sourcing
0090: 20 74 68 69 73 20 66 69 6c 65 20 69 6e 74 6f 20   this file into 
00a0: 54 63 6c 20 72 75 6e 73 20 74 68 65 20 74 65 73  Tcl runs the tes
00b0: 74 73 20 61 6e 64 0a 23 20 67 65 6e 65 72 61 74  ts and.# generat
00c0: 65 73 20 6f 75 74 70 75 74 20 66 6f 72 20 65 72  es output for er
00d0: 72 6f 72 73 2e 20 20 4e 6f 20 6f 75 74 70 75 74  rors.  No output
00e0: 20 6d 65 61 6e 73 20 6e 6f 20 65 72 72 6f 72 73   means no errors
00f0: 20 77 65 72 65 20 66 6f 75 6e 64 2e 0a 23 0a 23   were found..#.#
0100: 20 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 31   Copyright (c) 1
0110: 39 39 36 20 53 75 6e 20 4d 69 63 72 6f 73 79 73  996 Sun Microsys
0120: 74 65 6d 73 2c 20 49 6e 63 2e 0a 23 0a 23 20 53  tems, Inc..#.# S
0130: 65 65 20 74 68 65 20 66 69 6c 65 20 22 6c 69 63  ee the file "lic
0140: 65 6e 73 65 2e 74 65 72 6d 73 22 20 66 6f 72 20  ense.terms" for 
0150: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 6f 6e 20 75  information on u
0160: 73 61 67 65 20 61 6e 64 20 72 65 64 69 73 74 72  sage and redistr
0170: 69 62 75 74 69 6f 6e 0a 23 20 6f 66 20 74 68 69  ibution.# of thi
0180: 73 20 66 69 6c 65 2c 20 61 6e 64 20 66 6f 72 20  s file, and for 
0190: 61 20 44 49 53 43 4c 41 49 4d 45 52 20 4f 46 20  a DISCLAIMER OF 
01a0: 41 4c 4c 20 57 41 52 52 41 4e 54 49 45 53 2e 0a  ALL WARRANTIES..
01b0: 0a 69 66 20 7b 5b 6c 73 65 61 72 63 68 20 5b 6e  .if {[lsearch [n
01c0: 61 6d 65 73 70 61 63 65 20 63 68 69 6c 64 72 65  amespace childre
01d0: 6e 5d 20 3a 3a 74 63 6c 74 65 73 74 5d 20 3d 3d  n] ::tcltest] ==
01e0: 20 2d 31 7d 20 7b 0a 20 20 20 20 70 61 63 6b 61   -1} {.    packa
01f0: 67 65 20 72 65 71 75 69 72 65 20 74 63 6c 74 65  ge require tclte
0200: 73 74 20 32 0a 20 20 20 20 6e 61 6d 65 73 70 61  st 2.    namespa
0210: 63 65 20 69 6d 70 6f 72 74 20 2d 66 6f 72 63 65  ce import -force
0220: 20 3a 3a 74 63 6c 74 65 73 74 3a 3a 2a 0a 7d 0a   ::tcltest::*.}.
0230: 0a 3a 3a 74 63 6c 74 65 73 74 3a 3a 6c 6f 61 64  .::tcltest::load
0240: 54 65 73 74 65 64 43 6f 6d 6d 61 6e 64 73 0a 63  TestedCommands.c
0250: 61 74 63 68 20 5b 6c 69 73 74 20 70 61 63 6b 61  atch [list packa
0260: 67 65 20 72 65 71 75 69 72 65 20 2d 65 78 61 63  ge require -exac
0270: 74 20 54 63 6c 74 65 73 74 20 5b 69 6e 66 6f 20  t Tcltest [info 
0280: 70 61 74 63 68 6c 65 76 65 6c 5d 5d 0a 0a 74 65  patchlevel]]..te
0290: 73 74 43 6f 6e 73 74 72 61 69 6e 74 20 74 65 73  stConstraint tes
02a0: 74 63 68 6d 6f 64 20 5b 6c 6c 65 6e 67 74 68 20  tchmod [llength 
02b0: 5b 69 6e 66 6f 20 63 6f 6d 6d 61 6e 64 73 20 74  [info commands t
02c0: 65 73 74 63 68 6d 6f 64 5d 5d 0a 0a 23 20 54 68  estchmod]]..# Th
02d0: 65 73 65 20 74 65 73 74 73 20 72 65 61 6c 6c 79  ese tests really
02e0: 20 6e 65 65 64 20 74 6f 20 62 65 20 72 75 6e 20   need to be run 
02f0: 66 72 6f 6d 20 61 20 77 72 69 74 61 62 6c 65 20  from a writable 
0300: 64 69 72 65 63 74 6f 72 79 2c 20 77 68 69 63 68  directory, which
0310: 0a 23 20 69 74 20 69 73 20 61 73 73 75 6d 65 64  .# it is assumed
0320: 20 5b 74 65 6d 70 6f 72 61 72 79 44 69 72 65 63   [temporaryDirec
0330: 74 6f 72 79 5d 20 69 73 2e 0a 73 65 74 20 6f 6c  tory] is..set ol
0340: 64 63 77 64 20 5b 70 77 64 5d 0a 63 64 20 5b 74  dcwd [pwd].cd [t
0350: 65 6d 70 6f 72 61 72 79 44 69 72 65 63 74 6f 72  emporaryDirector
0360: 79 5d 0a 0a 23 20 53 65 76 65 72 61 6c 20 74 65  y]..# Several te
0370: 73 74 73 20 72 65 71 75 69 72 65 20 6e 65 65 64  sts require need
0380: 20 74 6f 20 6d 61 74 63 68 20 72 65 73 75 6c 74   to match result
0390: 73 20 61 67 61 69 6e 73 74 20 74 68 65 20 75 6e  s against the un
03a0: 69 78 20 75 73 65 72 6e 61 6d 65 0a 73 65 74 20  ix username.set 
03b0: 75 73 65 72 20 7b 7d 0a 69 66 20 7b 5b 74 65 73  user {}.if {[tes
03c0: 74 43 6f 6e 73 74 72 61 69 6e 74 20 75 6e 69 78  tConstraint unix
03d0: 5d 7d 20 7b 0a 20 20 20 20 63 61 74 63 68 20 7b  ]} {.    catch {
03e0: 73 65 74 20 75 73 65 72 20 5b 65 78 65 63 20 77  set user [exec w
03f0: 68 6f 61 6d 69 5d 7d 0a 20 20 20 20 69 66 20 7b  hoami]}.    if {
0400: 24 75 73 65 72 20 3d 3d 20 22 22 7d 20 7b 0a 09  $user == ""} {..
0410: 63 61 74 63 68 20 7b 72 65 67 65 78 70 20 7b 5e  catch {regexp {^
0420: 5b 5e 28 5d 2a 5c 28 28 5b 5e 29 5d 2a 29 5c 29  [^(]*\(([^)]*)\)
0430: 7d 20 5b 65 78 65 63 20 69 64 5d 20 64 75 6d 6d  } [exec id] dumm
0440: 79 20 75 73 65 72 7d 0a 20 20 20 20 7d 0a 20 20  y user}.    }.  
0450: 20 20 69 66 20 7b 24 75 73 65 72 20 3d 3d 20 22    if {$user == "
0460: 22 7d 20 7b 0a 09 73 65 74 20 75 73 65 72 20 22  "} {..set user "
0470: 72 6f 6f 74 22 0a 20 20 20 20 7d 0a 7d 0a 0a 23  root".    }.}..#
0480: 20 46 69 6e 64 20 61 20 67 72 6f 75 70 20 74 68   Find a group th
0490: 61 74 20 65 78 69 73 74 73 20 6f 6e 20 74 68 69  at exists on thi
04a0: 73 20 73 79 73 74 65 6d 2c 20 6f 72 20 65 6c 73  s system, or els
04b0: 65 20 73 6b 69 70 20 74 65 73 74 73 20 74 68 61  e skip tests tha
04c0: 74 20 72 65 71 75 69 72 65 0a 23 20 67 72 6f 75  t require.# grou
04d0: 70 73 0a 74 65 73 74 43 6f 6e 73 74 72 61 69 6e  ps.testConstrain
04e0: 74 20 66 6f 75 6e 64 47 72 6f 75 70 20 30 0a 69  t foundGroup 0.i
04f0: 66 20 7b 5b 74 65 73 74 43 6f 6e 73 74 72 61 69  f {[testConstrai
0500: 6e 74 20 75 6e 69 78 5d 7d 20 7b 0a 20 20 20 20  nt unix]} {.    
0510: 63 61 74 63 68 20 7b 0a 09 73 65 74 20 67 72 6f  catch {..set gro
0520: 75 70 4c 69 73 74 20 5b 65 78 65 63 20 67 72 6f  upList [exec gro
0530: 75 70 73 5d 0a 09 73 65 74 20 67 72 6f 75 70 20  ups]..set group 
0540: 5b 6c 69 6e 64 65 78 20 24 67 72 6f 75 70 4c 69  [lindex $groupLi
0550: 73 74 20 30 5d 0a 09 74 65 73 74 43 6f 6e 73 74  st 0]..testConst
0560: 72 61 69 6e 74 20 66 6f 75 6e 64 47 72 6f 75 70  raint foundGroup
0570: 20 31 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 63 68   1.    }.}..# ch
0580: 65 63 6b 20 77 68 65 74 68 65 72 20 2d 72 65 61  eck whether -rea
0590: 64 6f 6e 6c 79 20 61 74 74 72 69 62 75 74 65 20  donly attribute 
05a0: 69 73 20 73 75 70 70 6f 72 74 65 64 0a 74 65 73  is supported.tes
05b0: 74 43 6f 6e 73 74 72 61 69 6e 74 20 72 65 61 64  tConstraint read
05c0: 6f 6e 6c 79 41 74 74 72 20 30 0a 69 66 20 7b 5b  onlyAttr 0.if {[
05d0: 74 65 73 74 43 6f 6e 73 74 72 61 69 6e 74 20 75  testConstraint u
05e0: 6e 69 78 5d 7d 20 7b 0a 20 20 20 20 73 65 74 20  nix]} {.    set 
05f0: 66 20 5b 6d 61 6b 65 46 69 6c 65 20 22 77 68 61  f [makeFile "wha
0600: 74 65 76 65 72 22 20 70 72 6f 62 65 5d 0a 20 20  tever" probe].  
0610: 20 20 63 61 74 63 68 20 7b 0a 09 66 69 6c 65 20    catch {..file 
0620: 61 74 74 72 69 62 75 74 65 73 20 24 66 20 2d 72  attributes $f -r
0630: 65 61 64 6f 6e 6c 79 0a 09 74 65 73 74 43 6f 6e  eadonly..testCon
0640: 73 74 72 61 69 6e 74 20 72 65 61 64 6f 6e 6c 79  straint readonly
0650: 41 74 74 72 20 31 0a 20 20 20 20 7d 0a 20 20 20  Attr 1.    }.   
0660: 20 72 65 6d 6f 76 65 46 69 6c 65 20 70 72 6f 62   removeFile prob
0670: 65 0a 7d 0a 0a 70 72 6f 63 20 6f 70 65 6e 75 70  e.}..proc openup
0680: 20 7b 70 61 74 68 7d 20 7b 0a 20 20 20 20 74 65   {path} {.    te
0690: 73 74 63 68 6d 6f 64 20 30 6f 37 37 37 20 24 70  stchmod 0o777 $p
06a0: 61 74 68 0a 20 20 20 20 69 66 20 7b 5b 66 69 6c  ath.    if {[fil
06b0: 65 20 69 73 64 69 72 65 63 74 6f 72 79 20 24 70  e isdirectory $p
06c0: 61 74 68 5d 7d 20 7b 0a 09 63 61 74 63 68 20 7b  ath]} {..catch {
06d0: 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 70 20  ..    foreach p 
06e0: 5b 67 6c 6f 62 20 2d 64 69 72 65 63 74 6f 72 79  [glob -directory
06f0: 20 24 70 61 74 68 20 2a 5d 20 7b 0a 09 09 6f 70   $path *] {...op
0700: 65 6e 75 70 20 24 70 0a 09 20 20 20 20 7d 0a 09  enup $p..    }..
0710: 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 70 72 6f 63 20  }.    }.}..proc 
0720: 63 6c 65 61 6e 75 70 20 7b 61 72 67 73 7d 20 7b  cleanup {args} {
0730: 0a 20 20 20 20 66 6f 72 65 61 63 68 20 70 20 22  .    foreach p "
0740: 2e 20 24 61 72 67 73 22 20 7b 0a 09 73 65 74 20  . $args" {..set 
0750: 78 20 22 22 0a 09 63 61 74 63 68 20 7b 0a 09 20  x ""..catch {.. 
0760: 20 20 20 73 65 74 20 78 20 5b 67 6c 6f 62 20 2d     set x [glob -
0770: 64 69 72 65 63 74 6f 72 79 20 24 70 20 74 66 2a  directory $p tf*
0780: 20 74 64 2a 5d 0a 09 7d 0a 09 66 6f 72 65 61 63   td*]..}..foreac
0790: 68 20 66 69 6c 65 20 24 78 20 7b 0a 09 20 20 20  h file $x {..   
07a0: 20 69 66 20 7b 0a 09 09 5b 63 61 74 63 68 20 7b   if {...[catch {
07b0: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
07c0: 63 65 20 2d 2d 20 24 66 69 6c 65 7d 5d 0a 09 09  ce -- $file}]...
07d0: 26 26 20 5b 74 65 73 74 43 6f 6e 73 74 72 61 69  && [testConstrai
07e0: 6e 74 20 74 65 73 74 63 68 6d 6f 64 5d 0a 09 20  nt testchmod].. 
07f0: 20 20 20 7d 20 74 68 65 6e 20 7b 0a 09 09 6f 70     } then {...op
0800: 65 6e 75 70 20 24 66 69 6c 65 0a 09 09 66 69 6c  enup $file...fil
0810: 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20  e delete -force 
0820: 2d 2d 20 24 66 69 6c 65 0a 09 20 20 20 20 7d 0a  -- $file..    }.
0830: 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 69 66 20 7b  .}.    }.}..if {
0840: 5b 74 65 73 74 43 6f 6e 73 74 72 61 69 6e 74 20  [testConstraint 
0850: 75 6e 69 78 5d 20 26 26 20 5b 74 65 73 74 43 6f  unix] && [testCo
0860: 6e 73 74 72 61 69 6e 74 20 6e 6f 74 52 6f 6f 74  nstraint notRoot
0870: 5d 7d 20 7b 0a 20 20 20 20 74 65 73 74 43 6f 6e  ]} {.    testCon
0880: 73 74 72 61 69 6e 74 20 65 78 65 63 4d 6b 6e 6f  straint execMkno
0890: 64 20 5b 65 78 70 72 20 7b 21 5b 63 61 74 63 68  d [expr {![catch
08a0: 20 7b 65 78 65 63 20 6d 6b 6e 6f 64 20 74 66 31   {exec mknod tf1
08b0: 20 70 7d 5d 7d 5d 0a 20 20 20 20 63 6c 65 61 6e   p}]}].    clean
08c0: 75 70 0a 7d 0a 0a 74 65 73 74 20 75 6e 69 78 46  up.}..test unixF
08d0: 43 6d 64 2d 31 2e 31 20 7b 54 63 6c 70 52 65 6e  Cmd-1.1 {TclpRen
08e0: 61 6d 65 46 69 6c 65 3a 20 45 41 43 43 45 53 7d  ameFile: EACCES}
08f0: 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20 63 6c   -setup {.    cl
0900: 65 61 6e 75 70 0a 7d 20 2d 63 6f 6e 73 74 72 61  eanup.} -constra
0910: 69 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f  ints {unix notRo
0920: 6f 74 7d 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20  ot} -body {.    
0930: 66 69 6c 65 20 6d 6b 64 69 72 20 74 64 31 2f 74  file mkdir td1/t
0940: 64 32 2f 74 64 33 0a 20 20 20 20 66 69 6c 65 20  d2/td3.    file 
0950: 61 74 74 72 69 62 75 74 65 73 20 74 64 31 2f 74  attributes td1/t
0960: 64 32 20 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20  d2 -permissions 
0970: 30 30 30 30 0a 20 20 20 20 66 69 6c 65 20 72 65  0000.    file re
0980: 6e 61 6d 65 20 74 64 31 2f 74 64 32 2f 74 64 33  name td1/td2/td3
0990: 20 74 64 32 0a 7d 20 2d 72 65 74 75 72 6e 43 6f   td2.} -returnCo
09a0: 64 65 73 20 65 72 72 6f 72 20 2d 63 6c 65 61 6e  des error -clean
09b0: 75 70 20 7b 0a 20 20 20 20 66 69 6c 65 20 61 74  up {.    file at
09c0: 74 72 69 62 75 74 65 73 20 74 64 31 2f 74 64 32  tributes td1/td2
09d0: 20 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20 30 37   -permissions 07
09e0: 35 35 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d  55.    cleanup.}
09f0: 20 2d 72 65 73 75 6c 74 20 7b 65 72 72 6f 72 20   -result {error 
0a00: 72 65 6e 61 6d 69 6e 67 20 22 74 64 31 2f 74 64  renaming "td1/td
0a10: 32 2f 74 64 33 22 3a 20 70 65 72 6d 69 73 73 69  2/td3": permissi
0a20: 6f 6e 20 64 65 6e 69 65 64 7d 0a 74 65 73 74 20  on denied}.test 
0a30: 75 6e 69 78 46 43 6d 64 2d 31 2e 32 20 7b 54 63  unixFCmd-1.2 {Tc
0a40: 6c 70 52 65 6e 61 6d 65 46 69 6c 65 3a 20 45 45  lpRenameFile: EE
0a50: 58 49 53 54 7d 20 2d 73 65 74 75 70 20 7b 0a 20  XIST} -setup {. 
0a60: 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20 2d 63 6f     cleanup.} -co
0a70: 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78 20  nstraints {unix 
0a80: 6e 6f 74 52 6f 6f 74 7d 20 2d 62 6f 64 79 20 7b  notRoot} -body {
0a90: 0a 20 20 20 20 66 69 6c 65 20 6d 6b 64 69 72 20  .    file mkdir 
0aa0: 74 64 31 2f 74 64 32 0a 20 20 20 20 66 69 6c 65  td1/td2.    file
0ab0: 20 6d 6b 64 69 72 20 74 64 32 0a 20 20 20 20 66   mkdir td2.    f
0ac0: 69 6c 65 20 72 65 6e 61 6d 65 20 74 64 32 20 74  ile rename td2 t
0ad0: 64 31 0a 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65  d1.} -returnCode
0ae0: 73 20 65 72 72 6f 72 20 2d 63 6c 65 61 6e 75 70  s error -cleanup
0af0: 20 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d   {.    cleanup.}
0b00: 20 2d 72 65 73 75 6c 74 20 7b 65 72 72 6f 72 20   -result {error 
0b10: 72 65 6e 61 6d 69 6e 67 20 22 74 64 32 22 20 74  renaming "td2" t
0b20: 6f 20 22 74 64 31 2f 74 64 32 22 3a 20 66 69 6c  o "td1/td2": fil
0b30: 65 20 61 6c 72 65 61 64 79 20 65 78 69 73 74 73  e already exists
0b40: 7d 0a 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d  }.test unixFCmd-
0b50: 31 2e 33 20 7b 54 63 6c 70 52 65 6e 61 6d 65 46  1.3 {TclpRenameF
0b60: 69 6c 65 3a 20 45 49 4e 56 41 4c 7d 20 2d 73 65  ile: EINVAL} -se
0b70: 74 75 70 20 7b 0a 20 20 20 20 63 6c 65 61 6e 75  tup {.    cleanu
0b80: 70 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73  p.} -constraints
0b90: 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20   {unix notRoot} 
0ba0: 2d 62 6f 64 79 20 7b 0a 20 20 20 20 66 69 6c 65  -body {.    file
0bb0: 20 6d 6b 64 69 72 20 74 64 31 0a 20 20 20 20 66   mkdir td1.    f
0bc0: 69 6c 65 20 72 65 6e 61 6d 65 20 74 64 31 20 74  ile rename td1 t
0bd0: 64 31 0a 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65  d1.} -returnCode
0be0: 73 20 65 72 72 6f 72 20 2d 63 6c 65 61 6e 75 70  s error -cleanup
0bf0: 20 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d   {.    cleanup.}
0c00: 20 2d 72 65 73 75 6c 74 20 7b 65 72 72 6f 72 20   -result {error 
0c10: 72 65 6e 61 6d 69 6e 67 20 22 74 64 31 22 20 74  renaming "td1" t
0c20: 6f 20 22 74 64 31 2f 74 64 31 22 3a 20 74 72 79  o "td1/td1": try
0c30: 69 6e 67 20 74 6f 20 72 65 6e 61 6d 65 20 61 20  ing to rename a 
0c40: 76 6f 6c 75 6d 65 20 6f 72 20 6d 6f 76 65 20 61  volume or move a
0c50: 20 64 69 72 65 63 74 6f 72 79 20 69 6e 74 6f 20   directory into 
0c60: 69 74 73 65 6c 66 7d 0a 74 65 73 74 20 75 6e 69  itself}.test uni
0c70: 78 46 43 6d 64 2d 31 2e 34 20 7b 54 63 6c 70 52  xFCmd-1.4 {TclpR
0c80: 65 6e 61 6d 65 46 69 6c 65 3a 20 45 49 53 44 49  enameFile: EISDI
0c90: 52 7d 20 7b 65 6d 70 74 79 54 65 73 74 20 75 6e  R} {emptyTest un
0ca0: 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a 20 20  ix notRoot} {.  
0cb0: 20 20 23 20 63 61 6e 27 74 20 6d 61 6b 65 20 69    # can't make i
0cc0: 74 20 68 61 70 70 65 6e 0a 7d 20 7b 7d 0a 74 65  t happen.} {}.te
0cd0: 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 2e 35 20  st unixFCmd-1.5 
0ce0: 7b 54 63 6c 70 52 65 6e 61 6d 65 46 69 6c 65 3a  {TclpRenameFile:
0cf0: 20 45 4e 4f 45 4e 54 7d 20 2d 73 65 74 75 70 20   ENOENT} -setup 
0d00: 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20  {.    cleanup.} 
0d10: 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e  -constraints {un
0d20: 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d 62 6f 64  ix notRoot} -bod
0d30: 79 20 7b 0a 20 20 20 20 66 69 6c 65 20 6d 6b 64  y {.    file mkd
0d40: 69 72 20 74 64 31 0a 20 20 20 20 66 69 6c 65 20  ir td1.    file 
0d50: 72 65 6e 61 6d 65 20 74 64 32 20 74 64 31 0a 7d  rename td2 td1.}
0d60: 20 2d 72 65 74 75 72 6e 43 6f 64 65 73 20 65 72   -returnCodes er
0d70: 72 6f 72 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 20  ror -cleanup {. 
0d80: 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20 2d 72 65     cleanup.} -re
0d90: 73 75 6c 74 20 7b 65 72 72 6f 72 20 72 65 6e 61  sult {error rena
0da0: 6d 69 6e 67 20 22 74 64 32 22 3a 20 6e 6f 20 73  ming "td2": no s
0db0: 75 63 68 20 66 69 6c 65 20 6f 72 20 64 69 72 65  uch file or dire
0dc0: 63 74 6f 72 79 7d 0a 74 65 73 74 20 75 6e 69 78  ctory}.test unix
0dd0: 46 43 6d 64 2d 31 2e 36 20 7b 54 63 6c 70 52 65  FCmd-1.6 {TclpRe
0de0: 6e 61 6d 65 46 69 6c 65 3a 20 45 4e 4f 54 44 49  nameFile: ENOTDI
0df0: 52 7d 20 7b 65 6d 70 74 79 54 65 73 74 20 75 6e  R} {emptyTest un
0e00: 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a 20 20  ix notRoot} {.  
0e10: 20 20 23 20 63 61 6e 27 74 20 6d 61 6b 65 20 69    # can't make i
0e20: 74 20 68 61 70 70 65 6e 0a 7d 20 7b 7d 0a 74 65  t happen.} {}.te
0e30: 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 2e 37 20  st unixFCmd-1.7 
0e40: 7b 54 63 6c 70 52 65 6e 61 6d 65 46 69 6c 65 3a  {TclpRenameFile:
0e50: 20 45 58 44 45 56 7d 20 2d 73 65 74 75 70 20 7b   EXDEV} -setup {
0e60: 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20 2d  .    cleanup.} -
0e70: 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69  constraints {uni
0e80: 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d 62 6f 64 79  x notRoot} -body
0e90: 20 7b 0a 20 20 20 20 66 69 6c 65 20 6d 6b 64 69   {.    file mkdi
0ea0: 72 20 66 6f 6f 2f 62 61 72 0a 20 20 20 20 66 69  r foo/bar.    fi
0eb0: 6c 65 20 61 74 74 72 20 66 6f 6f 20 2d 70 65 72  le attr foo -per
0ec0: 6d 20 30 34 30 35 35 35 0a 20 20 20 20 66 69 6c  m 040555.    fil
0ed0: 65 20 72 65 6e 61 6d 65 20 66 6f 6f 2f 62 61 72  e rename foo/bar
0ee0: 20 2f 74 6d 70 0a 7d 20 2d 72 65 74 75 72 6e 43   /tmp.} -returnC
0ef0: 6f 64 65 73 20 65 72 72 6f 72 20 2d 63 6c 65 61  odes error -clea
0f00: 6e 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68 20  nup {.    catch 
0f10: 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2f 74 6d  {file delete /tm
0f20: 70 2f 62 61 72 7d 0a 20 20 20 20 63 61 74 63 68  p/bar}.    catch
0f30: 20 7b 66 69 6c 65 20 61 74 74 72 20 66 6f 6f 20   {file attr foo 
0f40: 2d 70 65 72 6d 20 30 34 30 37 37 37 7d 0a 20 20  -perm 040777}.  
0f50: 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20 64 65    catch {file de
0f60: 6c 65 74 65 20 2d 66 6f 72 63 65 20 66 6f 6f 7d  lete -force foo}
0f70: 0a 7d 20 2d 6d 61 74 63 68 20 67 6c 6f 62 20 2d  .} -match glob -
0f80: 72 65 73 75 6c 74 20 7b 2a 3a 20 70 65 72 6d 69  result {*: permi
0f90: 73 73 69 6f 6e 20 64 65 6e 69 65 64 7d 0a 74 65  ssion denied}.te
0fa0: 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 2e 38 20  st unixFCmd-1.8 
0fb0: 7b 43 68 65 63 6b 69 6e 67 20 45 49 4e 54 52 20  {Checking EINTR 
0fc0: 42 75 67 7d 20 7b 75 6e 69 78 20 6e 6f 74 52 6f  Bug} {unix notRo
0fd0: 6f 74 20 6e 6f 6e 50 6f 72 74 61 62 6c 65 7d 20  ot nonPortable} 
0fe0: 7b 0a 20 20 20 20 74 65 73 74 61 6c 61 72 6d 0a  {.    testalarm.
0ff0: 20 20 20 20 61 66 74 65 72 20 32 30 30 30 0a 20      after 2000. 
1000: 20 20 20 6c 69 73 74 20 5b 74 65 73 74 67 6f 74     list [testgot
1010: 73 69 67 5d 20 5b 74 65 73 74 67 6f 74 73 69 67  sig] [testgotsig
1020: 5d 0a 7d 20 7b 31 20 30 7d 0a 74 65 73 74 20 75  ].} {1 0}.test u
1030: 6e 69 78 46 43 6d 64 2d 31 2e 39 20 7b 43 68 65  nixFCmd-1.9 {Che
1040: 63 6b 69 6e 67 20 45 49 4e 54 52 20 42 75 67 7d  cking EINTR Bug}
1050: 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75   -constraints {u
1060: 6e 69 78 20 6e 6f 74 52 6f 6f 74 20 6e 6f 6e 50  nix notRoot nonP
1070: 6f 72 74 61 62 6c 65 7d 20 2d 73 65 74 75 70 20  ortable} -setup 
1080: 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 20 20  {.    cleanup.  
1090: 20 20 73 65 74 20 66 20 5b 6f 70 65 6e 20 74 66    set f [open tf
10a0: 61 6c 61 72 6d 20 77 5d 0a 20 20 20 20 70 75 74  alarm w].    put
10b0: 73 20 24 66 20 7b 0a 09 61 66 74 65 72 20 32 30  s $f {..after 20
10c0: 30 30 0a 09 70 75 74 73 20 22 68 65 6c 6c 6f 20  00..puts "hello 
10d0: 77 6f 72 6c 64 22 0a 09 65 78 69 74 20 30 0a 20  world"..exit 0. 
10e0: 20 20 20 7d 0a 20 20 20 20 63 6c 6f 73 65 20 24     }.    close $
10f0: 66 0a 7d 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20  f.} -body {.    
1100: 74 65 73 74 61 6c 61 72 6d 0a 20 20 20 20 73 65  testalarm.    se
1110: 74 20 70 69 70 65 20 5b 6f 70 65 6e 20 22 7c 5b  t pipe [open "|[
1120: 69 6e 66 6f 20 6e 61 6d 65 6f 66 65 78 65 63 75  info nameofexecu
1130: 74 61 62 6c 65 5d 20 74 66 61 6c 61 72 6d 22 20  table] tfalarm" 
1140: 72 2b 5d 0a 20 20 20 20 73 65 74 20 6c 69 6e 65  r+].    set line
1150: 20 5b 72 65 61 64 20 24 70 69 70 65 20 31 5d 0a   [read $pipe 1].
1160: 20 20 20 20 63 61 74 63 68 20 7b 63 6c 6f 73 65      catch {close
1170: 20 24 70 69 70 65 7d 0a 20 20 20 20 6c 69 73 74   $pipe}.    list
1180: 20 24 6c 69 6e 65 20 5b 74 65 73 74 67 6f 74 73   $line [testgots
1190: 69 67 5d 0a 7d 20 2d 63 6c 65 61 6e 75 70 20 7b  ig].} -cleanup {
11a0: 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20 2d  .    cleanup.} -
11b0: 72 65 73 75 6c 74 20 7b 68 20 31 7d 0a 0a 74 65  result {h 1}..te
11c0: 73 74 20 75 6e 69 78 46 43 6d 64 2d 32 2e 31 20  st unixFCmd-2.1 
11d0: 7b 54 63 6c 70 43 6f 70 79 46 69 6c 65 3a 20 74  {TclpCopyFile: t
11e0: 61 72 67 65 74 20 65 78 69 73 74 73 3a 20 6c 73  arget exists: ls
11f0: 74 61 74 28 64 73 74 29 20 3d 3d 20 30 7d 20 2d  tat(dst) == 0} -
1200: 73 65 74 75 70 20 7b 0a 20 20 20 20 63 6c 65 61  setup {.    clea
1210: 6e 75 70 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e  nup.} -constrain
1220: 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74  ts {unix notRoot
1230: 7d 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 63 6c  } -body {.    cl
1240: 6f 73 65 20 5b 6f 70 65 6e 20 74 66 31 20 61 5d  ose [open tf1 a]
1250: 0a 20 20 20 20 63 6c 6f 73 65 20 5b 6f 70 65 6e  .    close [open
1260: 20 74 66 32 20 61 5d 0a 20 20 20 20 66 69 6c 65   tf2 a].    file
1270: 20 63 6f 70 79 20 2d 66 6f 72 63 65 20 74 66 31   copy -force tf1
1280: 20 74 66 32 0a 7d 20 2d 63 6c 65 61 6e 75 70 20   tf2.} -cleanup 
1290: 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20  {.    cleanup.} 
12a0: 2d 72 65 73 75 6c 74 20 7b 7d 0a 74 65 73 74 20  -result {}.test 
12b0: 75 6e 69 78 46 43 6d 64 2d 32 2e 32 2e 31 20 7b  unixFCmd-2.2.1 {
12c0: 54 63 6c 70 43 6f 70 79 46 69 6c 65 3a 20 73 72  TclpCopyFile: sr
12d0: 63 20 69 73 20 73 79 6d 6c 69 6e 6b 7d 20 2d 73  c is symlink} -s
12e0: 65 74 75 70 20 7b 0a 20 20 20 20 63 6c 65 61 6e  etup {.    clean
12f0: 75 70 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74  up.} -constraint
1300: 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 20  s {unix notRoot 
1310: 64 6f 6e 74 43 6f 70 79 4c 69 6e 6b 73 7d 20 2d  dontCopyLinks} -
1320: 62 6f 64 79 20 7b 0a 20 20 20 20 23 20 63 6f 70  body {.    # cop
1330: 79 69 6e 67 20 6c 69 6e 6b 73 20 73 68 6f 75 6c  ying links shoul
1340: 64 20 65 6e 64 20 75 70 20 77 69 74 68 20 72 65  d end up with re
1350: 61 6c 20 66 69 6c 65 73 0a 20 20 20 20 63 6c 6f  al files.    clo
1360: 73 65 20 5b 6f 70 65 6e 20 74 66 31 20 61 5d 0a  se [open tf1 a].
1370: 20 20 20 20 66 69 6c 65 20 6c 69 6e 6b 20 2d 73      file link -s
1380: 79 6d 62 6f 6c 69 63 20 74 66 32 20 74 66 31 0a  ymbolic tf2 tf1.
1390: 20 20 20 20 66 69 6c 65 20 63 6f 70 79 20 74 66      file copy tf
13a0: 32 20 74 66 33 0a 20 20 20 20 66 69 6c 65 20 74  2 tf3.    file t
13b0: 79 70 65 20 74 66 33 0a 7d 20 2d 63 6c 65 61 6e  ype tf3.} -clean
13c0: 75 70 20 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70  up {.    cleanup
13d0: 0a 7d 20 2d 72 65 73 75 6c 74 20 66 69 6c 65 0a  .} -result file.
13e0: 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d 32 2e  test unixFCmd-2.
13f0: 32 2e 32 20 7b 54 63 6c 70 43 6f 70 79 46 69 6c  2.2 {TclpCopyFil
1400: 65 3a 20 73 72 63 20 69 73 20 73 79 6d 6c 69 6e  e: src is symlin
1410: 6b 7d 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20  k} -setup {.    
1420: 63 6c 65 61 6e 75 70 0a 7d 20 2d 63 6f 6e 73 74  cleanup.} -const
1430: 72 61 69 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74  raints {unix not
1440: 52 6f 6f 74 7d 20 2d 62 6f 64 79 20 7b 0a 20 20  Root} -body {.  
1450: 20 20 23 20 63 6f 70 79 69 6e 67 20 6c 69 6e 6b    # copying link
1460: 73 20 73 68 6f 75 6c 64 20 65 6e 64 20 75 70 20  s should end up 
1470: 77 69 74 68 20 74 68 65 20 6c 69 6e 6b 73 20 63  with the links c
1480: 6f 70 69 65 64 0a 20 20 20 20 63 6c 6f 73 65 20  opied.    close 
1490: 5b 6f 70 65 6e 20 74 66 31 20 61 5d 0a 20 20 20  [open tf1 a].   
14a0: 20 66 69 6c 65 20 6c 69 6e 6b 20 2d 73 79 6d 62   file link -symb
14b0: 6f 6c 69 63 20 74 66 32 20 74 66 31 0a 20 20 20  olic tf2 tf1.   
14c0: 20 66 69 6c 65 20 63 6f 70 79 20 74 66 32 20 74   file copy tf2 t
14d0: 66 33 0a 20 20 20 20 66 69 6c 65 20 74 79 70 65  f3.    file type
14e0: 20 74 66 33 0a 7d 20 2d 63 6c 65 61 6e 75 70 20   tf3.} -cleanup 
14f0: 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20  {.    cleanup.} 
1500: 2d 72 65 73 75 6c 74 20 6c 69 6e 6b 0a 74 65 73  -result link.tes
1510: 74 20 75 6e 69 78 46 43 6d 64 2d 32 2e 33 20 7b  t unixFCmd-2.3 {
1520: 54 63 6c 70 43 6f 70 79 46 69 6c 65 3a 20 73 72  TclpCopyFile: sr
1530: 63 20 69 73 20 62 6c 6f 63 6b 7d 20 2d 73 65 74  c is block} -set
1540: 75 70 20 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70  up {.    cleanup
1550: 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20  .} -constraints 
1560: 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d  {unix notRoot} -
1570: 62 6f 64 79 20 7b 0a 20 20 20 20 73 65 74 20 6e  body {.    set n
1580: 75 6c 6c 20 22 2f 64 65 76 2f 6e 75 6c 6c 22 0a  ull "/dev/null".
1590: 20 20 20 20 77 68 69 6c 65 20 7b 5b 66 69 6c 65      while {[file
15a0: 20 74 79 70 65 20 24 6e 75 6c 6c 5d 20 21 3d 20   type $null] != 
15b0: 22 63 68 61 72 61 63 74 65 72 53 70 65 63 69 61  "characterSpecia
15c0: 6c 22 7d 20 7b 0a 09 73 65 74 20 6e 75 6c 6c 20  l"} {..set null 
15d0: 5b 66 69 6c 65 20 6a 6f 69 6e 20 5b 66 69 6c 65  [file join [file
15e0: 20 64 69 72 6e 61 6d 65 20 24 6e 75 6c 6c 5d 20   dirname $null] 
15f0: 5b 66 69 6c 65 20 72 65 61 64 6c 69 6e 6b 20 24  [file readlink $
1600: 6e 75 6c 6c 5d 5d 0a 20 20 20 20 7d 0a 20 20 20  null]].    }.   
1610: 20 23 20 66 69 6c 65 20 63 6f 70 79 20 24 6e 75   # file copy $nu
1620: 6c 6c 20 74 66 31 0a 7d 20 2d 72 65 73 75 6c 74  ll tf1.} -result
1630: 20 7b 7d 0a 74 65 73 74 20 75 6e 69 78 46 43 6d   {}.test unixFCm
1640: 64 2d 32 2e 34 20 7b 54 63 6c 70 43 6f 70 79 46  d-2.4 {TclpCopyF
1650: 69 6c 65 3a 20 73 72 63 20 69 73 20 66 69 66 6f  ile: src is fifo
1660: 7d 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20 63  } -setup {.    c
1670: 6c 65 61 6e 75 70 0a 7d 20 2d 63 6f 6e 73 74 72  leanup.} -constr
1680: 61 69 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52  aints {unix notR
1690: 6f 6f 74 20 65 78 65 63 4d 6b 6e 6f 64 7d 20 2d  oot execMknod} -
16a0: 62 6f 64 79 20 7b 0a 20 20 20 20 65 78 65 63 20  body {.    exec 
16b0: 6d 6b 6e 6f 64 20 74 66 31 20 70 0a 20 20 20 20  mknod tf1 p.    
16c0: 66 69 6c 65 20 63 6f 70 79 20 74 66 31 20 74 66  file copy tf1 tf
16d0: 32 0a 20 20 20 20 6c 69 73 74 20 5b 66 69 6c 65  2.    list [file
16e0: 20 74 79 70 65 20 74 66 31 5d 20 5b 66 69 6c 65   type tf1] [file
16f0: 20 74 79 70 65 20 74 66 32 5d 0a 7d 20 2d 63 6c   type tf2].} -cl
1700: 65 61 6e 75 70 20 7b 0a 20 20 20 20 63 6c 65 61  eanup {.    clea
1710: 6e 75 70 0a 7d 20 2d 72 65 73 75 6c 74 20 7b 66  nup.} -result {f
1720: 69 66 6f 20 66 69 66 6f 7d 0a 74 65 73 74 20 75  ifo fifo}.test u
1730: 6e 69 78 46 43 6d 64 2d 32 2e 35 20 7b 54 63 6c  nixFCmd-2.5 {Tcl
1740: 70 43 6f 70 79 46 69 6c 65 3a 20 63 6f 70 79 20  pCopyFile: copy 
1750: 61 74 74 72 69 62 75 74 65 73 7d 20 2d 73 65 74  attributes} -set
1760: 75 70 20 7b 0a 20 20 20 20 63 6c 65 61 6e 75 70  up {.    cleanup
1770: 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20  .} -constraints 
1780: 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d  {unix notRoot} -
1790: 62 6f 64 79 20 7b 0a 20 20 20 20 63 6c 6f 73 65  body {.    close
17a0: 20 5b 6f 70 65 6e 20 74 66 31 20 61 5d 0a 20 20   [open tf1 a].  
17b0: 20 20 66 69 6c 65 20 61 74 74 72 69 62 75 74 65    file attribute
17c0: 73 20 74 66 31 20 2d 70 65 72 6d 69 73 73 69 6f  s tf1 -permissio
17d0: 6e 73 20 30 6f 34 37 32 0a 20 20 20 20 66 69 6c  ns 0o472.    fil
17e0: 65 20 63 6f 70 79 20 74 66 31 20 74 66 32 0a 20  e copy tf1 tf2. 
17f0: 20 20 20 66 69 6c 65 20 61 74 74 72 69 62 75 74     file attribut
1800: 65 73 20 74 66 32 20 2d 70 65 72 6d 69 73 73 69  es tf2 -permissi
1810: 6f 6e 73 0a 7d 20 2d 63 6c 65 61 6e 75 70 20 7b  ons.} -cleanup {
1820: 0a 20 20 20 20 63 6c 65 61 6e 75 70 0a 7d 20 2d  .    cleanup.} -
1830: 72 65 73 75 6c 74 20 30 6f 34 37 32 20 3b 23 20  result 0o472 ;# 
1840: 69 2e 65 2e 20 70 65 72 6d 73 20 66 69 65 6c 64  i.e. perms field
1850: 20 6f 66 20 5b 65 78 65 63 20 6c 73 20 2d 6c 20   of [exec ls -l 
1860: 74 66 32 5d 20 69 73 20 2d 72 2d 2d 72 77 78 2d  tf2] is -r--rwx-
1870: 77 2d 0a 0a 74 65 73 74 20 75 6e 69 78 46 43 6d  w-..test unixFCm
1880: 64 2d 33 2e 31 20 7b 43 6f 70 79 46 69 6c 65 20  d-3.1 {CopyFile 
1890: 6e 6f 74 20 64 6f 6e 65 7d 20 7b 65 6d 70 74 79  not done} {empty
18a0: 54 65 73 74 20 75 6e 69 78 20 6e 6f 74 52 6f 6f  Test unix notRoo
18b0: 74 7d 20 7b 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20  t} {.} {}..test 
18c0: 75 6e 69 78 46 43 6d 64 2d 34 2e 31 20 7b 54 63  unixFCmd-4.1 {Tc
18d0: 6c 70 44 65 6c 65 74 65 46 69 6c 65 20 6e 6f 74  lpDeleteFile not
18e0: 20 64 6f 6e 65 7d 20 7b 65 6d 70 74 79 54 65 73   done} {emptyTes
18f0: 74 20 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20  t unix notRoot} 
1900: 7b 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20 75 6e 69  {.} {}..test uni
1910: 78 46 43 6d 64 2d 35 2e 31 20 7b 54 63 6c 70 43  xFCmd-5.1 {TclpC
1920: 72 65 61 74 65 44 69 72 65 63 74 6f 72 79 20 6e  reateDirectory n
1930: 6f 74 20 64 6f 6e 65 7d 20 7b 65 6d 70 74 79 54  ot done} {emptyT
1940: 65 73 74 20 75 6e 69 78 20 6e 6f 74 52 6f 6f 74  est unix notRoot
1950: 7d 20 7b 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20 75  } {.} {}..test u
1960: 6e 69 78 46 43 6d 64 2d 36 2e 31 20 7b 54 63 6c  nixFCmd-6.1 {Tcl
1970: 70 43 6f 70 79 44 69 72 65 63 74 6f 72 79 20 6e  pCopyDirectory n
1980: 6f 74 20 64 6f 6e 65 7d 20 7b 65 6d 70 74 79 54  ot done} {emptyT
1990: 65 73 74 20 75 6e 69 78 20 6e 6f 74 52 6f 6f 74  est unix notRoot
19a0: 7d 20 7b 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20 75  } {.} {}..test u
19b0: 6e 69 78 46 43 6d 64 2d 37 2e 31 20 7b 54 63 6c  nixFCmd-7.1 {Tcl
19c0: 70 52 65 6d 6f 76 65 44 69 72 65 63 74 6f 72 79  pRemoveDirectory
19d0: 20 6e 6f 74 20 64 6f 6e 65 7d 20 7b 65 6d 70 74   not done} {empt
19e0: 79 54 65 73 74 20 75 6e 69 78 20 6e 6f 74 52 6f  yTest unix notRo
19f0: 6f 74 7d 20 7b 0a 7d 20 7b 7d 0a 0a 74 65 73 74  ot} {.} {}..test
1a00: 20 75 6e 69 78 46 43 6d 64 2d 38 2e 31 20 7b 54   unixFCmd-8.1 {T
1a10: 72 61 76 65 72 73 65 55 6e 69 78 54 72 65 65 20  raverseUnixTree 
1a20: 6e 6f 74 20 64 6f 6e 65 7d 20 7b 65 6d 70 74 79  not done} {empty
1a30: 54 65 73 74 20 75 6e 69 78 20 6e 6f 74 52 6f 6f  Test unix notRoo
1a40: 74 7d 20 7b 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20  t} {.} {}..test 
1a50: 75 6e 69 78 46 43 6d 64 2d 39 2e 31 20 7b 54 72  unixFCmd-9.1 {Tr
1a60: 61 76 65 72 73 61 6c 43 6f 70 79 20 6e 6f 74 20  aversalCopy not 
1a70: 64 6f 6e 65 7d 20 7b 65 6d 70 74 79 54 65 73 74  done} {emptyTest
1a80: 20 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 7b   unix notRoot} {
1a90: 0a 7d 20 7b 7d 0a 0a 74 65 73 74 20 75 6e 69 78  .} {}..test unix
1aa0: 46 43 6d 64 2d 31 30 2e 31 20 7b 54 72 61 76 65  FCmd-10.1 {Trave
1ab0: 72 73 61 6c 44 65 6c 65 74 65 20 6e 6f 74 20 64  rsalDelete not d
1ac0: 6f 6e 65 7d 20 7b 65 6d 70 74 79 54 65 73 74 20  one} {emptyTest 
1ad0: 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a  unix notRoot} {.
1ae0: 7d 20 7b 7d 0a 0a 74 65 73 74 20 75 6e 69 78 46  } {}..test unixF
1af0: 43 6d 64 2d 31 31 2e 31 20 7b 43 6f 70 79 46 69  Cmd-11.1 {CopyFi
1b00: 6c 65 41 74 74 72 73 20 6e 6f 74 20 64 6f 6e 65  leAttrs not done
1b10: 7d 20 7b 65 6d 70 74 79 54 65 73 74 20 75 6e 69  } {emptyTest uni
1b20: 78 20 6e 6f 74 52 6f 6f 74 7d 20 7b 0a 7d 20 7b  x notRoot} {.} {
1b30: 7d 0a 0a 74 65 73 74 20 75 6e 69 78 46 43 6d 64  }..test unixFCmd
1b40: 2d 31 32 2e 31 20 7b 47 65 74 47 72 6f 75 70 41  -12.1 {GetGroupA
1b50: 74 74 72 69 62 75 74 65 20 2d 20 66 69 6c 65 20  ttribute - file 
1b60: 6e 6f 74 20 66 6f 75 6e 64 7d 20 2d 73 65 74 75  not found} -setu
1b70: 70 20 7b 0a 20 20 20 20 63 61 74 63 68 20 7b 66  p {.    catch {f
1b80: 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63  ile delete -forc
1b90: 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 7d 0a 7d  e -- foo.test}.}
1ba0: 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75   -constraints {u
1bb0: 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d 72 65  nix notRoot} -re
1bc0: 74 75 72 6e 43 6f 64 65 73 20 65 72 72 6f 72 20  turnCodes error 
1bd0: 2d 62 6f 64 79 20 7b 0a 20 20 20 20 66 69 6c 65  -body {.    file
1be0: 20 61 74 74 72 69 62 75 74 65 73 20 66 6f 6f 2e   attributes foo.
1bf0: 74 65 73 74 20 2d 67 72 6f 75 70 0a 7d 20 2d 72  test -group.} -r
1c00: 65 73 75 6c 74 20 7b 63 6f 75 6c 64 20 6e 6f 74  esult {could not
1c10: 20 72 65 61 64 20 22 66 6f 6f 2e 74 65 73 74 22   read "foo.test"
1c20: 3a 20 6e 6f 20 73 75 63 68 20 66 69 6c 65 20 6f  : no such file o
1c30: 72 20 64 69 72 65 63 74 6f 72 79 7d 0a 74 65 73  r directory}.tes
1c40: 74 20 75 6e 69 78 46 43 6d 64 2d 31 32 2e 32 20  t unixFCmd-12.2 
1c50: 7b 47 65 74 47 72 6f 75 70 41 74 74 72 69 62 75  {GetGroupAttribu
1c60: 74 65 20 2d 20 66 69 6c 65 20 66 6f 75 6e 64 7d  te - file found}
1c70: 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20 63 61   -setup {.    ca
1c80: 74 63 68 20 7b 66 69 6c 65 20 64 65 6c 65 74 65  tch {file delete
1c90: 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74   -force -- foo.t
1ca0: 65 73 74 7d 0a 7d 20 2d 63 6f 6e 73 74 72 61 69  est}.} -constrai
1cb0: 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f  nts {unix notRoo
1cc0: 74 7d 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 63  t} -body {.    c
1cd0: 6c 6f 73 65 20 5b 6f 70 65 6e 20 66 6f 6f 2e 74  lose [open foo.t
1ce0: 65 73 74 20 77 5d 0a 20 20 20 20 66 69 6c 65 20  est w].    file 
1cf0: 61 74 74 72 69 62 75 74 65 73 20 66 6f 6f 2e 74  attributes foo.t
1d00: 65 73 74 20 2d 67 72 6f 75 70 0a 7d 20 2d 63 6c  est -group.} -cl
1d10: 65 61 6e 75 70 20 7b 0a 20 20 20 20 66 69 6c 65  eanup {.    file
1d20: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d   delete -force -
1d30: 2d 20 66 6f 6f 2e 74 65 73 74 0a 7d 20 2d 6d 61  - foo.test.} -ma
1d40: 74 63 68 20 67 6c 6f 62 20 2d 72 65 73 75 6c 74  tch glob -result
1d50: 20 2a 0a 0a 74 65 73 74 20 75 6e 69 78 46 43 6d   *..test unixFCm
1d60: 64 2d 31 33 2e 31 20 7b 47 65 74 4f 77 6e 65 72  d-13.1 {GetOwner
1d70: 41 74 74 72 69 62 75 74 65 20 2d 20 66 69 6c 65  Attribute - file
1d80: 20 6e 6f 74 20 66 6f 75 6e 64 7d 20 2d 73 65 74   not found} -set
1d90: 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68 20 7b  up {.    catch {
1da0: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
1db0: 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 7d 0a  ce -- foo.test}.
1dc0: 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b  } -constraints {
1dd0: 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d 72  unix notRoot} -r
1de0: 65 74 75 72 6e 43 6f 64 65 73 20 65 72 72 6f 72  eturnCodes error
1df0: 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 66 69 6c   -body {.    fil
1e00: 65 20 61 74 74 72 69 62 75 74 65 73 20 66 6f 6f  e attributes foo
1e10: 2e 74 65 73 74 20 2d 67 72 6f 75 70 0a 7d 20 2d  .test -group.} -
1e20: 72 65 73 75 6c 74 20 7b 63 6f 75 6c 64 20 6e 6f  result {could no
1e30: 74 20 72 65 61 64 20 22 66 6f 6f 2e 74 65 73 74  t read "foo.test
1e40: 22 3a 20 6e 6f 20 73 75 63 68 20 66 69 6c 65 20  ": no such file 
1e50: 6f 72 20 64 69 72 65 63 74 6f 72 79 7d 0a 74 65  or directory}.te
1e60: 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 33 2e 32  st unixFCmd-13.2
1e70: 20 7b 47 65 74 4f 77 6e 65 72 41 74 74 72 69 62   {GetOwnerAttrib
1e80: 75 74 65 7d 20 2d 73 65 74 75 70 20 7b 0a 20 20  ute} -setup {.  
1e90: 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20 64 65    catch {file de
1ea0: 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 66  lete -force -- f
1eb0: 6f 6f 2e 74 65 73 74 7d 0a 7d 20 2d 63 6f 6e 73  oo.test}.} -cons
1ec0: 74 72 61 69 6e 74 73 20 7b 75 6e 69 78 20 6e 6f  traints {unix no
1ed0: 74 52 6f 6f 74 7d 20 2d 62 6f 64 79 20 7b 0a 20  tRoot} -body {. 
1ee0: 20 20 20 63 6c 6f 73 65 20 5b 6f 70 65 6e 20 66     close [open f
1ef0: 6f 6f 2e 74 65 73 74 20 77 5d 0a 20 20 20 20 66  oo.test w].    f
1f00: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 66  ile attributes f
1f10: 6f 6f 2e 74 65 73 74 20 2d 6f 77 6e 65 72 0a 7d  oo.test -owner.}
1f20: 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 20 20 20 20   -cleanup {.    
1f30: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
1f40: 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 0a 7d  ce -- foo.test.}
1f50: 20 2d 72 65 73 75 6c 74 20 24 75 73 65 72 0a 0a   -result $user..
1f60: 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 34  test unixFCmd-14
1f70: 2e 31 20 7b 47 65 74 50 65 72 6d 69 73 73 69 6f  .1 {GetPermissio
1f80: 6e 73 41 74 74 72 69 62 75 74 65 20 2d 20 66 69  nsAttribute - fi
1f90: 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 7d 20 2d 73  le not found} -s
1fa0: 65 74 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68  etup {.    catch
1fb0: 20 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66   {file delete -f
1fc0: 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74  orce -- foo.test
1fd0: 7d 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73  }.} -constraints
1fe0: 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20   {unix notRoot} 
1ff0: 2d 72 65 74 75 72 6e 43 6f 64 65 73 20 65 72 72  -returnCodes err
2000: 6f 72 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 66  or -body {.    f
2010: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 66  ile attributes f
2020: 6f 6f 2e 74 65 73 74 20 2d 70 65 72 6d 69 73 73  oo.test -permiss
2030: 69 6f 6e 73 0a 7d 20 2d 72 65 73 75 6c 74 20 7b  ions.} -result {
2040: 63 6f 75 6c 64 20 6e 6f 74 20 72 65 61 64 20 22  could not read "
2050: 66 6f 6f 2e 74 65 73 74 22 3a 20 6e 6f 20 73 75  foo.test": no su
2060: 63 68 20 66 69 6c 65 20 6f 72 20 64 69 72 65 63  ch file or direc
2070: 74 6f 72 79 7d 0a 74 65 73 74 20 75 6e 69 78 46  tory}.test unixF
2080: 43 6d 64 2d 31 34 2e 32 20 7b 47 65 74 50 65 72  Cmd-14.2 {GetPer
2090: 6d 69 73 73 69 6f 6e 73 41 74 74 72 69 62 75 74  missionsAttribut
20a0: 65 7d 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20  e} -setup {.    
20b0: 63 61 74 63 68 20 7b 66 69 6c 65 20 64 65 6c 65  catch {file dele
20c0: 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f  te -force -- foo
20d0: 2e 74 65 73 74 7d 0a 7d 20 2d 63 6f 6e 73 74 72  .test}.} -constr
20e0: 61 69 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52  aints {unix notR
20f0: 6f 6f 74 7d 20 2d 62 6f 64 79 20 7b 0a 20 20 20  oot} -body {.   
2100: 20 63 6c 6f 73 65 20 5b 6f 70 65 6e 20 66 6f 6f   close [open foo
2110: 2e 74 65 73 74 20 77 5d 0a 20 20 20 20 66 69 6c  .test w].    fil
2120: 65 20 61 74 74 72 69 62 75 74 65 20 66 6f 6f 2e  e attribute foo.
2130: 74 65 73 74 20 2d 70 65 72 6d 69 73 73 69 6f 6e  test -permission
2140: 73 0a 7d 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 20  s.} -cleanup {. 
2150: 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65 20 2d     file delete -
2160: 66 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73  force -- foo.tes
2170: 74 0a 7d 20 2d 6d 61 74 63 68 20 67 6c 6f 62 20  t.} -match glob 
2180: 2d 72 65 73 75 6c 74 20 2a 0a 0a 23 67 72 6f 75  -result *..#grou
2190: 70 73 20 68 61 72 64 20 74 6f 20 74 65 73 74 0a  ps hard to test.
21a0: 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 35  test unixFCmd-15
21b0: 2e 31 20 7b 53 65 74 47 72 6f 75 70 41 74 74 72  .1 {SetGroupAttr
21c0: 69 62 75 74 65 20 2d 20 69 6e 76 61 6c 69 64 20  ibute - invalid 
21d0: 67 72 6f 75 70 7d 20 2d 73 65 74 75 70 20 7b 0a  group} -setup {.
21e0: 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20      catch {file 
21f0: 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d  delete -force --
2200: 20 66 6f 6f 2e 74 65 73 74 7d 0a 7d 20 2d 63 6f   foo.test}.} -co
2210: 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78 20  nstraints {unix 
2220: 6e 6f 74 52 6f 6f 74 7d 20 2d 62 6f 64 79 20 7b  notRoot} -body {
2230: 0a 20 20 20 20 66 69 6c 65 20 61 74 74 72 69 62  .    file attrib
2240: 75 74 65 73 20 66 6f 6f 2e 74 65 73 74 20 2d 67  utes foo.test -g
2250: 72 6f 75 70 20 66 6f 6f 7a 7a 7a 0a 7d 20 2d 72  roup foozzz.} -r
2260: 65 74 75 72 6e 43 6f 64 65 73 20 65 72 72 6f 72  eturnCodes error
2270: 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 20 20 20 20   -cleanup {.    
2280: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
2290: 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 0a 7d  ce -- foo.test.}
22a0: 20 2d 72 65 73 75 6c 74 20 7b 63 6f 75 6c 64 20   -result {could 
22b0: 6e 6f 74 20 73 65 74 20 67 72 6f 75 70 20 66 6f  not set group fo
22c0: 72 20 66 69 6c 65 20 22 66 6f 6f 2e 74 65 73 74  r file "foo.test
22d0: 22 3a 20 67 72 6f 75 70 20 22 66 6f 6f 7a 7a 7a  ": group "foozzz
22e0: 22 20 64 6f 65 73 20 6e 6f 74 20 65 78 69 73 74  " does not exist
22f0: 7d 0a 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d  }.test unixFCmd-
2300: 31 35 2e 32 20 7b 53 65 74 47 72 6f 75 70 41 74  15.2 {SetGroupAt
2310: 74 72 69 62 75 74 65 20 2d 20 69 6e 76 61 6c 69  tribute - invali
2320: 64 20 66 69 6c 65 7d 20 2d 73 65 74 75 70 20 7b  d file} -setup {
2330: 0a 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65  .    catch {file
2340: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d   delete -force -
2350: 2d 20 66 6f 6f 2e 74 65 73 74 7d 0a 7d 20 2d 63  - foo.test}.} -c
2360: 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78  onstraints {unix
2370: 20 6e 6f 74 52 6f 6f 74 20 66 6f 75 6e 64 47 72   notRoot foundGr
2380: 6f 75 70 7d 20 2d 72 65 74 75 72 6e 43 6f 64 65  oup} -returnCode
2390: 73 20 65 72 72 6f 72 20 2d 62 6f 64 79 20 7b 0a  s error -body {.
23a0: 20 20 20 20 66 69 6c 65 20 61 74 74 72 69 62 75      file attribu
23b0: 74 65 73 20 66 6f 6f 2e 74 65 73 74 20 2d 67 72  tes foo.test -gr
23c0: 6f 75 70 20 24 67 72 6f 75 70 0a 7d 20 2d 72 65  oup $group.} -re
23d0: 73 75 6c 74 20 7b 63 6f 75 6c 64 20 6e 6f 74 20  sult {could not 
23e0: 73 65 74 20 67 72 6f 75 70 20 66 6f 72 20 66 69  set group for fi
23f0: 6c 65 20 22 66 6f 6f 2e 74 65 73 74 22 3a 20 6e  le "foo.test": n
2400: 6f 20 73 75 63 68 20 66 69 6c 65 20 6f 72 20 64  o such file or d
2410: 69 72 65 63 74 6f 72 79 7d 0a 0a 23 63 68 61 6e  irectory}..#chan
2420: 67 69 6e 67 20 6f 77 6e 65 72 73 20 68 61 72 64  ging owners hard
2430: 20 74 6f 20 64 6f 0a 74 65 73 74 20 75 6e 69 78   to do.test unix
2440: 46 43 6d 64 2d 31 36 2e 31 20 7b 53 65 74 4f 77  FCmd-16.1 {SetOw
2450: 6e 65 72 41 74 74 72 69 62 75 74 65 20 2d 20 63  nerAttribute - c
2460: 75 72 72 65 6e 74 20 6f 77 6e 65 72 7d 20 2d 73  urrent owner} -s
2470: 65 74 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68  etup {.    catch
2480: 20 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66   {file delete -f
2490: 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74  orce -- foo.test
24a0: 7d 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73  }.} -constraints
24b0: 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20   {unix notRoot} 
24c0: 2d 62 6f 64 79 20 7b 0a 20 20 20 20 63 6c 6f 73  -body {.    clos
24d0: 65 20 5b 6f 70 65 6e 20 66 6f 6f 2e 74 65 73 74  e [open foo.test
24e0: 20 77 5d 0a 20 20 20 20 6c 69 73 74 20 5b 66 69   w].    list [fi
24f0: 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 66 6f  le attributes fo
2500: 6f 2e 74 65 73 74 20 2d 6f 77 6e 65 72 20 24 75  o.test -owner $u
2510: 73 65 72 5d 20 5c 0a 09 5b 66 69 6c 65 20 61 74  ser] \..[file at
2520: 74 72 69 62 75 74 65 73 20 66 6f 6f 2e 74 65 73  tributes foo.tes
2530: 74 20 2d 6f 77 6e 65 72 5d 0a 7d 20 2d 63 6c 65  t -owner].} -cle
2540: 61 6e 75 70 20 7b 0a 20 20 20 20 66 69 6c 65 20  anup {.    file 
2550: 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d  delete -force --
2560: 20 66 6f 6f 2e 74 65 73 74 0a 7d 20 2d 72 65 73   foo.test.} -res
2570: 75 6c 74 20 5b 6c 69 73 74 20 7b 7d 20 24 75 73  ult [list {} $us
2580: 65 72 5d 0a 74 65 73 74 20 75 6e 69 78 46 43 6d  er].test unixFCm
2590: 64 2d 31 36 2e 32 20 7b 53 65 74 4f 77 6e 65 72  d-16.2 {SetOwner
25a0: 41 74 74 72 69 62 75 74 65 20 2d 20 69 6e 76 61  Attribute - inva
25b0: 6c 69 64 20 66 69 6c 65 7d 20 2d 73 65 74 75 70  lid file} -setup
25c0: 20 7b 0a 20 20 20 20 63 61 74 63 68 20 7b 66 69   {.    catch {fi
25d0: 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65  le delete -force
25e0: 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 7d 0a 7d 20   -- foo.test}.} 
25f0: 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e  -constraints {un
2600: 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d 72 65 74  ix notRoot} -ret
2610: 75 72 6e 43 6f 64 65 73 20 65 72 72 6f 72 20 2d  urnCodes error -
2620: 62 6f 64 79 20 7b 0a 20 20 20 20 66 69 6c 65 20  body {.    file 
2630: 61 74 74 72 69 62 75 74 65 73 20 66 6f 6f 2e 74  attributes foo.t
2640: 65 73 74 20 2d 6f 77 6e 65 72 20 24 75 73 65 72  est -owner $user
2650: 0a 7d 20 2d 72 65 73 75 6c 74 20 7b 63 6f 75 6c  .} -result {coul
2660: 64 20 6e 6f 74 20 73 65 74 20 6f 77 6e 65 72 20  d not set owner 
2670: 66 6f 72 20 66 69 6c 65 20 22 66 6f 6f 2e 74 65  for file "foo.te
2680: 73 74 22 3a 20 6e 6f 20 73 75 63 68 20 66 69 6c  st": no such fil
2690: 65 20 6f 72 20 64 69 72 65 63 74 6f 72 79 7d 0a  e or directory}.
26a0: 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 36  test unixFCmd-16
26b0: 2e 33 20 7b 53 65 74 4f 77 6e 65 72 41 74 74 72  .3 {SetOwnerAttr
26c0: 69 62 75 74 65 20 2d 20 69 6e 76 61 6c 69 64 20  ibute - invalid 
26d0: 6f 77 6e 65 72 7d 20 2d 73 65 74 75 70 20 7b 0a  owner} -setup {.
26e0: 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20      catch {file 
26f0: 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d  delete -force --
2700: 20 66 6f 6f 2e 74 65 73 74 7d 0a 7d 20 2d 63 6f   foo.test}.} -co
2710: 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78 20  nstraints {unix 
2720: 6e 6f 74 52 6f 6f 74 7d 20 2d 72 65 74 75 72 6e  notRoot} -return
2730: 43 6f 64 65 73 20 65 72 72 6f 72 20 2d 62 6f 64  Codes error -bod
2740: 79 20 7b 0a 20 20 20 20 66 69 6c 65 20 61 74 74  y {.    file att
2750: 72 69 62 75 74 65 73 20 66 6f 6f 2e 74 65 73 74  ributes foo.test
2760: 20 2d 6f 77 6e 65 72 20 66 6f 6f 7a 7a 7a 0a 7d   -owner foozzz.}
2770: 20 2d 72 65 73 75 6c 74 20 7b 63 6f 75 6c 64 20   -result {could 
2780: 6e 6f 74 20 73 65 74 20 6f 77 6e 65 72 20 66 6f  not set owner fo
2790: 72 20 66 69 6c 65 20 22 66 6f 6f 2e 74 65 73 74  r file "foo.test
27a0: 22 3a 20 75 73 65 72 20 22 66 6f 6f 7a 7a 7a 22  ": user "foozzz"
27b0: 20 64 6f 65 73 20 6e 6f 74 20 65 78 69 73 74 7d   does not exist}
27c0: 0a 0a 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d  ..test unixFCmd-
27d0: 31 37 2e 31 20 7b 53 65 74 50 65 72 6d 69 73 73  17.1 {SetPermiss
27e0: 69 6f 6e 73 41 74 74 72 69 62 75 74 65 7d 20 2d  ionsAttribute} -
27f0: 73 65 74 75 70 20 7b 0a 20 20 20 20 63 61 74 63  setup {.    catc
2800: 68 20 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2d  h {file delete -
2810: 66 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73  force -- foo.tes
2820: 74 7d 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74  t}.} -constraint
2830: 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d  s {unix notRoot}
2840: 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 63 6c 6f   -body {.    clo
2850: 73 65 20 5b 6f 70 65 6e 20 66 6f 6f 2e 74 65 73  se [open foo.tes
2860: 74 20 77 5d 0a 20 20 20 20 6c 69 73 74 20 5b 66  t w].    list [f
2870: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 66  ile attributes f
2880: 6f 6f 2e 74 65 73 74 20 2d 70 65 72 6d 69 73 73  oo.test -permiss
2890: 69 6f 6e 73 20 30 30 30 30 5d 20 5c 0a 09 5b 66  ions 0000] \..[f
28a0: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 66  ile attributes f
28b0: 6f 6f 2e 74 65 73 74 20 2d 70 65 72 6d 69 73 73  oo.test -permiss
28c0: 69 6f 6e 73 5d 0a 7d 20 2d 63 6c 65 61 6e 75 70  ions].} -cleanup
28d0: 20 7b 0a 20 20 20 20 66 69 6c 65 20 64 65 6c 65   {.    file dele
28e0: 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f  te -force -- foo
28f0: 2e 74 65 73 74 0a 7d 20 2d 72 65 73 75 6c 74 20  .test.} -result 
2900: 7b 7b 7d 20 30 30 30 30 30 7d 0a 74 65 73 74 20  {{} 00000}.test 
2910: 75 6e 69 78 46 43 6d 64 2d 31 37 2e 32 20 7b 53  unixFCmd-17.2 {S
2920: 65 74 50 65 72 6d 69 73 73 69 6f 6e 73 41 74 74  etPermissionsAtt
2930: 72 69 62 75 74 65 7d 20 2d 73 65 74 75 70 20 7b  ribute} -setup {
2940: 0a 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65  .    catch {file
2950: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d   delete -force -
2960: 2d 20 66 6f 6f 2e 74 65 73 74 7d 0a 7d 20 2d 63  - foo.test}.} -c
2970: 6f 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78  onstraints {unix
2980: 20 6e 6f 74 52 6f 6f 74 7d 20 2d 72 65 74 75 72   notRoot} -retur
2990: 6e 43 6f 64 65 73 20 65 72 72 6f 72 20 2d 62 6f  nCodes error -bo
29a0: 64 79 20 7b 0a 20 20 20 20 66 69 6c 65 20 61 74  dy {.    file at
29b0: 74 72 69 62 75 74 65 73 20 66 6f 6f 2e 74 65 73  tributes foo.tes
29c0: 74 20 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20 30  t -permissions 0
29d0: 30 30 30 0a 7d 20 2d 72 65 73 75 6c 74 20 7b 63  000.} -result {c
29e0: 6f 75 6c 64 20 6e 6f 74 20 73 65 74 20 70 65 72  ould not set per
29f0: 6d 69 73 73 69 6f 6e 73 20 66 6f 72 20 66 69 6c  missions for fil
2a00: 65 20 22 66 6f 6f 2e 74 65 73 74 22 3a 20 6e 6f  e "foo.test": no
2a10: 20 73 75 63 68 20 66 69 6c 65 20 6f 72 20 64 69   such file or di
2a20: 72 65 63 74 6f 72 79 7d 0a 74 65 73 74 20 75 6e  rectory}.test un
2a30: 69 78 46 43 6d 64 2d 31 37 2e 33 20 7b 53 65 74  ixFCmd-17.3 {Set
2a40: 50 65 72 6d 69 73 73 69 6f 6e 73 41 74 74 72 69  PermissionsAttri
2a50: 62 75 74 65 7d 20 2d 73 65 74 75 70 20 7b 0a 20  bute} -setup {. 
2a60: 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20 64     catch {file d
2a70: 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20  elete -force -- 
2a80: 66 6f 6f 2e 74 65 73 74 7d 0a 7d 20 2d 63 6f 6e  foo.test}.} -con
2a90: 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78 20 6e  straints {unix n
2aa0: 6f 74 52 6f 6f 74 7d 20 2d 62 6f 64 79 20 7b 0a  otRoot} -body {.
2ab0: 20 20 20 20 63 6c 6f 73 65 20 5b 6f 70 65 6e 20      close [open 
2ac0: 66 6f 6f 2e 74 65 73 74 20 77 5d 0a 20 20 20 20  foo.test w].    
2ad0: 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20  file attributes 
2ae0: 66 6f 6f 2e 74 65 73 74 20 2d 70 65 72 6d 69 73  foo.test -permis
2af0: 73 69 6f 6e 73 20 66 6f 6f 0a 7d 20 2d 63 6c 65  sions foo.} -cle
2b00: 61 6e 75 70 20 7b 0a 20 20 20 20 66 69 6c 65 20  anup {.    file 
2b10: 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d  delete -force --
2b20: 20 66 6f 6f 2e 74 65 73 74 0a 7d 20 2d 72 65 74   foo.test.} -ret
2b30: 75 72 6e 43 6f 64 65 73 20 65 72 72 6f 72 20 2d  urnCodes error -
2b40: 72 65 73 75 6c 74 20 7b 75 6e 6b 6e 6f 77 6e 20  result {unknown 
2b50: 70 65 72 6d 69 73 73 69 6f 6e 20 73 74 72 69 6e  permission strin
2b60: 67 20 66 6f 72 6d 61 74 20 22 66 6f 6f 22 7d 0a  g format "foo"}.
2b70: 74 65 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 37  test unixFCmd-17
2b80: 2e 34 20 7b 53 65 74 50 65 72 6d 69 73 73 69 6f  .4 {SetPermissio
2b90: 6e 73 41 74 74 72 69 62 75 74 65 7d 20 2d 73 65  nsAttribute} -se
2ba0: 74 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68 20  tup {.    catch 
2bb0: 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f  {file delete -fo
2bc0: 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 7d  rce -- foo.test}
2bd0: 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20  .} -constraints 
2be0: 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 7d 20 2d  {unix notRoot} -
2bf0: 62 6f 64 79 20 7b 0a 20 20 20 20 63 6c 6f 73 65  body {.    close
2c00: 20 5b 6f 70 65 6e 20 66 6f 6f 2e 74 65 73 74 20   [open foo.test 
2c10: 77 5d 0a 20 20 20 20 66 69 6c 65 20 61 74 74 72  w].    file attr
2c20: 69 62 75 74 65 73 20 66 6f 6f 2e 74 65 73 74 20  ibutes foo.test 
2c30: 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20 2d 2d 2d  -permissions ---
2c40: 72 77 78 0a 7d 20 2d 63 6c 65 61 6e 75 70 20 7b  rwx.} -cleanup {
2c50: 0a 20 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65  .    file delete
2c60: 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74   -force -- foo.t
2c70: 65 73 74 0a 7d 20 2d 72 65 74 75 72 6e 43 6f 64  est.} -returnCod
2c80: 65 73 20 65 72 72 6f 72 20 2d 72 65 73 75 6c 74  es error -result
2c90: 20 7b 75 6e 6b 6e 6f 77 6e 20 70 65 72 6d 69 73   {unknown permis
2ca0: 73 69 6f 6e 20 73 74 72 69 6e 67 20 66 6f 72 6d  sion string form
2cb0: 61 74 20 22 2d 2d 2d 72 77 78 22 7d 0a 0a 63 6c  at "---rwx"}..cl
2cc0: 6f 73 65 20 5b 6f 70 65 6e 20 66 6f 6f 2e 74 65  ose [open foo.te
2cd0: 73 74 20 77 5d 0a 73 65 74 20 3a 3a 69 20 34 0a  st w].set ::i 4.
2ce0: 70 72 6f 63 20 70 65 72 6d 63 68 65 63 6b 20 7b  proc permcheck {
2cf0: 74 65 73 74 6e 75 6d 20 70 65 72 6d 4c 69 73 74  testnum permList
2d00: 20 65 78 70 65 63 74 65 64 7d 20 7b 0a 20 20 20   expected} {.   
2d10: 20 74 65 73 74 20 24 74 65 73 74 6e 75 6d 20 7b   test $testnum {
2d20: 53 65 74 50 65 72 6d 69 73 73 69 6f 6e 73 41 74  SetPermissionsAt
2d30: 74 72 69 62 75 74 65 7d 20 7b 75 6e 69 78 20 6e  tribute} {unix n
2d40: 6f 74 52 6f 6f 74 7d 20 7b 0a 20 20 20 20 20 20  otRoot} {.      
2d50: 73 65 74 20 72 65 73 75 6c 74 20 7b 7d 0a 20 20  set result {}.  
2d60: 20 20 20 20 66 6f 72 65 61 63 68 20 70 65 72 6d      foreach perm
2d70: 73 74 72 20 24 70 65 72 6d 4c 69 73 74 20 7b 0a  str $permList {.
2d80: 09 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73  .file attributes
2d90: 20 66 6f 6f 2e 74 65 73 74 20 2d 70 65 72 6d 69   foo.test -permi
2da0: 73 73 69 6f 6e 73 20 24 70 65 72 6d 73 74 72 0a  ssions $permstr.
2db0: 09 6c 61 70 70 65 6e 64 20 72 65 73 75 6c 74 20  .lappend result 
2dc0: 5b 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73  [file attributes
2dd0: 20 66 6f 6f 2e 74 65 73 74 20 2d 70 65 72 6d 69   foo.test -permi
2de0: 73 73 69 6f 6e 73 5d 0a 20 20 20 20 20 20 7d 0a  ssions].      }.
2df0: 20 20 20 20 20 20 73 65 74 20 72 65 73 75 6c 74        set result
2e00: 0a 20 20 20 20 7d 20 24 65 78 70 65 63 74 65 64  .    } $expected
2e10: 0a 7d 0a 70 65 72 6d 63 68 65 63 6b 20 75 6e 69  .}.permcheck uni
2e20: 78 46 43 6d 64 2d 31 37 2e 35 20 20 20 72 77 78  xFCmd-17.5   rwx
2e30: 72 77 78 72 77 78 09 30 6f 37 37 37 0a 70 65 72  rwxrwx.0o777.per
2e40: 6d 63 68 65 63 6b 20 75 6e 69 78 46 43 6d 64 2d  mcheck unixFCmd-
2e50: 31 37 2e 36 20 20 20 72 2d 2d 72 2d 2d 2d 77 2d  17.6   r--r---w-
2e60: 09 30 6f 34 34 32 0a 70 65 72 6d 63 68 65 63 6b  .0o442.permcheck
2e70: 20 75 6e 69 78 46 43 6d 64 2d 31 37 2e 37 20 20   unixFCmd-17.7  
2e80: 20 7b 30 20 75 2b 72 77 78 2c 67 2b 72 20 75 2d   {0 u+rwx,g+r u-
2e90: 77 20 6f 2b 72 77 78 7d 20 7b 30 30 30 30 30 20  w o+rwx} {00000 
2ea0: 30 6f 37 34 30 20 30 6f 35 34 30 20 30 6f 35 34  0o740 0o540 0o54
2eb0: 37 7d 0a 70 65 72 6d 63 68 65 63 6b 20 75 6e 69  7}.permcheck uni
2ec0: 78 46 43 6d 64 2d 31 37 2e 31 31 20 20 2d 2d 78  xFCmd-17.11  --x
2ed0: 2d 2d 78 2d 2d 78 09 30 6f 31 31 31 0a 70 65 72  --x--x.0o111.per
2ee0: 6d 63 68 65 63 6b 20 75 6e 69 78 46 43 6d 64 2d  mcheck unixFCmd-
2ef0: 31 37 2e 31 32 20 20 7b 30 20 61 2b 72 77 78 7d  17.12  {0 a+rwx}
2f00: 20 7b 30 30 30 30 30 20 30 6f 37 37 37 7d 0a 66   {00000 0o777}.f
2f10: 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63  ile delete -forc
2f20: 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 0a 0a 74  e -- foo.test..t
2f30: 65 73 74 20 75 6e 69 78 46 43 6d 64 2d 31 38 2e  est unixFCmd-18.
2f40: 31 20 7b 55 6e 69 78 20 70 77 64 7d 20 2d 63 6f  1 {Unix pwd} -co
2f50: 6e 73 74 72 61 69 6e 74 73 20 7b 75 6e 69 78 20  nstraints {unix 
2f60: 6e 6f 74 52 6f 6f 74 20 6e 6f 6e 50 6f 72 74 61  notRoot nonPorta
2f70: 62 6c 65 7d 20 2d 73 65 74 75 70 20 7b 0a 20 20  ble} -setup {.  
2f80: 20 20 73 65 74 20 63 64 20 5b 70 77 64 5d 0a 7d    set cd [pwd].}
2f90: 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 23 20 54   -body {.    # T
2fa0: 68 69 73 20 74 65 73 74 20 69 73 20 6e 6f 6e 50  his test is nonP
2fb0: 6f 72 74 61 62 6c 65 20 62 65 63 61 75 73 65 20  ortable because 
2fc0: 53 75 6e 4f 53 20 67 65 6e 65 72 61 74 65 73 20  SunOS generates 
2fd0: 61 20 77 65 69 72 64 20 65 72 72 6f 72 0a 20 20  a weird error.  
2fe0: 20 20 23 20 6d 65 73 73 61 67 65 20 77 68 65 6e    # message when
2ff0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 64 69 72   the current dir
3000: 65 63 74 6f 72 79 20 69 73 6e 27 74 20 72 65 61  ectory isn't rea
3010: 64 61 62 6c 65 2e 0a 20 20 20 20 73 65 74 20 6e  dable..    set n
3020: 64 20 24 63 64 2f 74 73 74 64 69 72 0a 20 20 20  d $cd/tstdir.   
3030: 20 66 69 6c 65 20 6d 6b 64 69 72 20 24 6e 64 0a   file mkdir $nd.
3040: 20 20 20 20 63 64 20 24 6e 64 0a 20 20 20 20 66      cd $nd.    f
3050: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 24  ile attributes $
3060: 6e 64 20 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20  nd -permissions 
3070: 30 30 30 30 0a 20 20 20 20 70 77 64 0a 7d 20 2d  0000.    pwd.} -
3080: 72 65 74 75 72 6e 43 6f 64 65 73 20 65 72 72 6f  returnCodes erro
3090: 72 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 20 20 20  r -cleanup {.   
30a0: 20 63 64 20 24 63 64 0a 20 20 20 20 66 69 6c 65   cd $cd.    file
30b0: 20 61 74 74 72 69 62 75 74 65 73 20 24 6e 64 20   attributes $nd 
30c0: 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20 30 37 35  -permissions 075
30d0: 35 0a 20 20 20 20 66 69 6c 65 20 64 65 6c 65 74  5.    file delet
30e0: 65 20 24 6e 64 0a 7d 20 2d 6d 61 74 63 68 20 67  e $nd.} -match g
30f0: 6c 6f 62 20 2d 72 65 73 75 6c 74 20 7b 65 72 72  lob -result {err
3100: 6f 72 20 67 65 74 74 69 6e 67 20 77 6f 72 6b 69  or getting worki
3110: 6e 67 20 64 69 72 65 63 74 6f 72 79 20 6e 61 6d  ng directory nam
3120: 65 3a 2a 7d 0a 0a 74 65 73 74 20 75 6e 69 78 46  e:*}..test unixF
3130: 43 6d 64 2d 31 39 2e 31 20 7b 47 65 74 52 65 61  Cmd-19.1 {GetRea
3140: 64 4f 6e 6c 79 41 74 74 72 69 62 75 74 65 20 2d  dOnlyAttribute -
3150: 20 66 69 6c 65 20 6e 6f 74 20 66 6f 75 6e 64 7d   file not found}
3160: 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20 63 61   -setup {.    ca
3170: 74 63 68 20 7b 66 69 6c 65 20 64 65 6c 65 74 65  tch {file delete
3180: 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e 74   -force -- foo.t
3190: 65 73 74 7d 0a 7d 20 2d 63 6f 6e 73 74 72 61 69  est}.} -constrai
31a0: 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f  nts {unix notRoo
31b0: 74 20 72 65 61 64 6f 6e 6c 79 41 74 74 72 7d 20  t readonlyAttr} 
31c0: 2d 72 65 74 75 72 6e 43 6f 64 65 73 20 65 72 72  -returnCodes err
31d0: 6f 72 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20 66  or -body {.    f
31e0: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 66  ile attributes f
31f0: 6f 6f 2e 74 65 73 74 20 2d 72 65 61 64 6f 6e 6c  oo.test -readonl
3200: 79 0a 7d 20 2d 72 65 73 75 6c 74 20 7b 63 6f 75  y.} -result {cou
3210: 6c 64 20 6e 6f 74 20 72 65 61 64 20 22 66 6f 6f  ld not read "foo
3220: 2e 74 65 73 74 22 3a 20 6e 6f 20 73 75 63 68 20  .test": no such 
3230: 66 69 6c 65 20 6f 72 20 64 69 72 65 63 74 6f 72  file or director
3240: 79 7d 0a 74 65 73 74 20 75 6e 69 78 46 43 6d 64  y}.test unixFCmd
3250: 2d 31 39 2e 32 20 7b 47 65 74 52 65 61 64 4f 6e  -19.2 {GetReadOn
3260: 6c 79 41 74 74 72 69 62 75 74 65 7d 20 2d 73 65  lyAttribute} -se
3270: 74 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68 20  tup {.    catch 
3280: 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f  {file delete -fo
3290: 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 7d  rce -- foo.test}
32a0: 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20  .} -constraints 
32b0: 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 20 72 65  {unix notRoot re
32c0: 61 64 6f 6e 6c 79 41 74 74 72 7d 20 2d 62 6f 64  adonlyAttr} -bod
32d0: 79 20 7b 0a 20 20 20 20 63 6c 6f 73 65 20 5b 6f  y {.    close [o
32e0: 70 65 6e 20 66 6f 6f 2e 74 65 73 74 20 77 5d 0a  pen foo.test w].
32f0: 20 20 20 20 66 69 6c 65 20 61 74 74 72 69 62 75      file attribu
3300: 74 65 20 66 6f 6f 2e 74 65 73 74 20 2d 72 65 61  te foo.test -rea
3310: 64 6f 6e 6c 79 0a 7d 20 2d 63 6c 65 61 6e 75 70  donly.} -cleanup
3320: 20 7b 0a 20 20 20 20 66 69 6c 65 20 64 65 6c 65   {.    file dele
3330: 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f  te -force -- foo
3340: 2e 74 65 73 74 0a 7d 20 2d 72 65 73 75 6c 74 20  .test.} -result 
3350: 30 0a 0a 74 65 73 74 20 75 6e 69 78 46 43 6d 64  0..test unixFCmd
3360: 2d 32 30 2e 31 20 7b 53 65 74 52 65 61 64 4f 6e  -20.1 {SetReadOn
3370: 6c 79 41 74 74 72 69 62 75 74 65 7d 20 2d 73 65  lyAttribute} -se
3380: 74 75 70 20 7b 0a 20 20 20 20 63 61 74 63 68 20  tup {.    catch 
3390: 7b 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f  {file delete -fo
33a0: 72 63 65 20 2d 2d 20 66 6f 6f 2e 74 65 73 74 7d  rce -- foo.test}
33b0: 0a 7d 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20  .} -constraints 
33c0: 7b 75 6e 69 78 20 6e 6f 74 52 6f 6f 74 20 72 65  {unix notRoot re
33d0: 61 64 6f 6e 6c 79 41 74 74 72 7d 20 2d 62 6f 64  adonlyAttr} -bod
33e0: 79 20 7b 0a 20 20 20 20 63 6c 6f 73 65 20 5b 6f  y {.    close [o
33f0: 70 65 6e 20 66 6f 6f 2e 74 65 73 74 20 77 5d 0a  pen foo.test w].
3400: 20 20 20 20 6c 69 73 74 20 5b 63 61 74 63 68 20      list [catch 
3410: 7b 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73  {file attributes
3420: 20 66 6f 6f 2e 74 65 73 74 20 2d 72 65 61 64 6f   foo.test -reado
3430: 6e 6c 79 20 31 7d 20 6d 73 67 5d 20 24 6d 73 67  nly 1} msg] $msg
3440: 20 5c 0a 09 20 20 20 20 5b 63 61 74 63 68 20 7b   \..    [catch {
3450: 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 20 66  file attribute f
3460: 6f 6f 2e 74 65 73 74 20 2d 72 65 61 64 6f 6e 6c  oo.test -readonl
3470: 79 7d 20 6d 73 67 5d 20 24 6d 73 67 20 5c 0a 09  y} msg] $msg \..
3480: 20 20 20 20 5b 63 61 74 63 68 20 7b 66 69 6c 65      [catch {file
3490: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d   delete -force -
34a0: 2d 20 66 6f 6f 2e 74 65 73 74 7d 5d 20 5c 0a 09  - foo.test}] \..
34b0: 20 20 20 20 5b 63 61 74 63 68 20 7b 66 69 6c 65      [catch {file
34c0: 20 61 74 74 72 69 62 75 74 65 73 20 66 6f 6f 2e   attributes foo.
34d0: 74 65 73 74 20 2d 72 65 61 64 6f 6e 6c 79 20 30  test -readonly 0
34e0: 7d 20 6d 73 67 5d 20 24 6d 73 67 20 5c 0a 09 20  } msg] $msg \.. 
34f0: 20 20 20 5b 63 61 74 63 68 20 7b 66 69 6c 65 20     [catch {file 
3500: 61 74 74 72 69 62 75 74 65 20 66 6f 6f 2e 74 65  attribute foo.te
3510: 73 74 20 2d 72 65 61 64 6f 6e 6c 79 7d 20 6d 73  st -readonly} ms
3520: 67 5d 20 24 6d 73 67 0a 7d 20 2d 63 6c 65 61 6e  g] $msg.} -clean
3530: 75 70 20 7b 0a 20 20 20 20 66 69 6c 65 20 64 65  up {.    file de
3540: 6c 65 74 65 20 2d 66 6f 72 63 65 20 2d 2d 20 66  lete -force -- f
3550: 6f 6f 2e 74 65 73 74 0a 7d 20 2d 72 65 73 75 6c  oo.test.} -resul
3560: 74 20 7b 30 20 7b 7d 20 30 20 31 20 31 20 30 20  t {0 {} 0 1 1 0 
3570: 7b 7d 20 30 20 30 7d 0a 74 65 73 74 20 75 6e 69  {} 0 0}.test uni
3580: 78 46 43 6d 64 2d 32 30 2e 32 20 7b 53 65 74 52  xFCmd-20.2 {SetR
3590: 65 61 64 4f 6e 6c 79 41 74 74 72 69 62 75 74 65  eadOnlyAttribute
35a0: 7d 20 2d 73 65 74 75 70 20 7b 0a 20 20 20 20 63  } -setup {.    c
35b0: 61 74 63 68 20 7b 66 69 6c 65 20 64 65 6c 65 74  atch {file delet
35c0: 65 20 2d 66 6f 72 63 65 20 2d 2d 20 66 6f 6f 2e  e -force -- foo.
35d0: 74 65 73 74 7d 0a 7d 20 2d 63 6f 6e 73 74 72 61  test}.} -constra
35e0: 69 6e 74 73 20 7b 75 6e 69 78 20 6e 6f 74 52 6f  ints {unix notRo
35f0: 6f 74 20 72 65 61 64 6f 6e 6c 79 41 74 74 72 7d  ot readonlyAttr}
3600: 20 2d 72 65 74 75 72 6e 43 6f 64 65 73 20 65 72   -returnCodes er
3610: 72 6f 72 20 2d 62 6f 64 79 20 7b 0a 20 20 20 20  ror -body {.    
3620: 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20  file attributes 
3630: 66 6f 6f 2e 74 65 73 74 20 2d 72 65 61 64 6f 6e  foo.test -readon
3640: 6c 79 20 31 0a 7d 20 2d 72 65 73 75 6c 74 20 7b  ly 1.} -result {
3650: 63 6f 75 6c 64 20 6e 6f 74 20 72 65 61 64 20 22  could not read "
3660: 66 6f 6f 2e 74 65 73 74 22 3a 20 6e 6f 20 73 75  foo.test": no su
3670: 63 68 20 66 69 6c 65 20 6f 72 20 64 69 72 65 63  ch file or direc
3680: 74 6f 72 79 7d 0a 0a 23 20 63 6c 65 61 6e 75 70  tory}..# cleanup
3690: 0a 63 6c 65 61 6e 75 70 0a 63 64 20 24 6f 6c 64  .cleanup.cd $old
36a0: 63 77 64 0a 3a 3a 74 63 6c 74 65 73 74 3a 3a 63  cwd.::tcltest::c
36b0: 6c 65 61 6e 75 70 54 65 73 74 73 0a 72 65 74 75  leanupTests.retu
36c0: 72 6e 0a 0a 23 20 4c 6f 63 61 6c 20 56 61 72 69  rn..# Local Vari
36d0: 61 62 6c 65 73 3a 0a 23 20 6d 6f 64 65 3a 20 74  ables:.# mode: t
36e0: 63 6c 0a 23 20 45 6e 64 3a 0a                    cl.# End:.