diff options
| author | patthoyts <patthoyts@users.sourceforge.net> | 2008-07-21 21:51:35 (GMT) | 
|---|---|---|
| committer | patthoyts <patthoyts@users.sourceforge.net> | 2008-07-21 21:51:35 (GMT) | 
| commit | 0cfbc1cfc7ced06308d425a94a7eb780cd0a0909 (patch) | |
| tree | 2a7835f5541e525a83093d05ec605d331239fd96 | |
| parent | 45fca6378191844231368026abfba87f18334f39 (diff) | |
| download | tcl-0cfbc1cfc7ced06308d425a94a7eb780cd0a0909.zip tcl-0cfbc1cfc7ced06308d425a94a7eb780cd0a0909.tar.gz tcl-0cfbc1cfc7ced06308d425a94a7eb780cd0a0909.tar.bz2 | |
Added test for file rename with inode collision on windows
| -rw-r--r-- | ChangeLog | 1 | ||||
| -rw-r--r-- | tests/winFCmd.test | 40 | 
2 files changed, 40 insertions, 1 deletions
| @@ -13,6 +13,7 @@  2008-07-21  Pat Thoyts  <patthoyts@users.sourceforge.net>  	* generic/tclFCmd.c: Inodes on windows are unreliable [Bug 2015723] +	* tests/winFCmd.test: test rename with inode collision  2008-07-21  Miguel Sofer  <msofer@users.sf.net> diff --git a/tests/winFCmd.test b/tests/winFCmd.test index f434516..d9598b1 100644 --- a/tests/winFCmd.test +++ b/tests/winFCmd.test @@ -10,7 +10,7 @@  # See the file "license.terms" for information on usage and redistribution  # of this file, and for a DISCLAIMER OF ALL WARRANTIES.  # -# RCS: @(#) $Id: winFCmd.test,v 1.43 2008/04/10 00:21:02 dkf Exp $ +# RCS: @(#) $Id: winFCmd.test,v 1.44 2008/07/21 21:51:36 patthoyts Exp $  #  if {[lsearch [namespace children] ::tcltest] == -1} { @@ -387,6 +387,44 @@ test winFCmd-1.37 {TclpRenameFile: need to restore temp file} {win emptyTest} {      # Need a file that can't be copied.  } {} +# If the native filesystem produces 0 for inodes numbers there is no point +# doing the following test. +testConstraint winNonZeroInodes [eval { +    file stat [info nameofexecutable] statExe +    expr {$statExe(ino) != 0} +}] + +proc MakeFiles {dirname} { +    set inodes {} +    set ndx -1 +    while {1} { +        if {$ndx > 10000} { +            return -code error "limit reached without finding a collistion." +        } +        set filename [file join $dirname Test[incr ndx]] +        set f [open $filename w] +        close $f +        file stat $filename stat +        if {[set n [lsearch -exact -integer $inodes $stat(ino)]] != -1} { +            return [list [file join $dirname Test$n] $filename] +        } +        lappend inodes $stat(ino) +        unset stat +    } +} + +test winFCmd-1.38 {TclpRenameFile: check rename of conflicting inodes} -setup { +    cleanup +} -constraints {win winNonZeroInodes} -body { +    file mkdir td1 +    foreach {a b} [MakeFiles td1] break +    file rename -force $a $b +    file exists $a +} -cleanup { +    cleanup +} -result {0} + +  test winFCmd-2.1 {TclpCopyFile: errno: EACCES} -setup {      cleanup  } -constraints {win cdrom testfile} -body { | 
