Tcl Source Code

Check-in [a7e00a0e02]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:3519357 Use randomized subdir of /tmp in xdev tests to reduce chance of conflict
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a7e00a0e0255e7204839bcc64b618c798de0b396
User & Date: dgp 2012-06-01 19:34:03
References
2012-06-15
09:39
alternative fix for [a7e00a0e02] breakage: just make sure that the variable $tmpspace is always set check-in: 1581f9beac user: jan.nijtmans tags: trunk
2012-06-14
13:56
fix fCmd-6.19 on win32, which was broken by [a7e00a0e02] check-in: 8992b49011 user: jan.nijtmans tags: trunk
Context
2012-06-01
22:01
[Bug 3530536]: zlib-7.4 fails on IRIX64 check-in: 4427cf5dcc user: jan.nijtmans tags: trunk
21:09
bug-3530536 check-in: b7606a8e7c user: jan.nijtmans tags: bug-3530536
19:34
3519357 Use randomized subdir of /tmp in xdev tests to reduce chance of conflict check-in: a7e00a0e02 user: dgp tags: trunk
19:25
3519357 Use randomized subdir of /tmp in xdev tests to reduce chance of conflict check-in: a4511ae802 user: dgp tags: core-8-5-branch
2012-05-31
14:52
[Bug 3531089] Added test to stop this from happening again check-in: e35f4db709 user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/fCmd.test.

10
11
12
13
14
15
16


17
18
19
20
21
22
23
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {"::tcltest" ni [namespace children]} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}



testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testchmod [llength [info commands testchmod]]
testConstraint winVista 0
testConstraint win2000orXP 0
# Don't know how to determine this constraint correctly
testConstraint notNetworkFilesystem 0







>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.

if {"::tcltest" ni [namespace children]} {
    package require tcltest 2
    namespace import -force ::tcltest::*
}

cd [temporaryDirectory]

testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testchmod [llength [info commands testchmod]]
testConstraint winVista 0
testConstraint win2000orXP 0
# Don't know how to determine this constraint correctly
testConstraint notNetworkFilesystem 0
42
43
44
45
46
47
48









49
50
51
52
53
54
55
testConstraint foundGroup [expr {![testConstraint unix]}]
if {[testConstraint unix]} {
    catch {
	set groupList [exec groups]
	set group [lindex $groupList 0]
	testConstraint foundGroup 1
    }









}

# Also used in winFCmd...
if {[testConstraint win]} {
    set major [string index $tcl_platform(osVersion) 0]
    if {[testConstraint nt] && $major > 4} {
        if {$major > 5} {







>
>
>
>
>
>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
testConstraint foundGroup [expr {![testConstraint unix]}]
if {[testConstraint unix]} {
    catch {
	set groupList [exec groups]
	set group [lindex $groupList 0]
	testConstraint foundGroup 1
    }

    proc dev dir {
	file stat $dir stat
	return $stat(dev)
    }

    if {[catch {makeDirectory tcl[pid] /tmp} tmpspace] == 0} {
	testConstraint xdev [expr {([dev .] != [dev $tmpspace])}]
    }
}

# Also used in winFCmd...
if {[testConstraint win]} {
    set major [string index $tcl_platform(osVersion) 0]
    if {[testConstraint nt] && $major > 4} {
        if {$major > 5} {
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
proc contents {file} {
    set f [open $file]
    set r [read $f]
    close $f
    return $r
}

cd [temporaryDirectory]

proc dev dir {
    file stat $dir stat
    return $stat(dev)
}
testConstraint xdev [expr {[testConstraint unix] && ([dev .] != [dev /tmp])}]

set root [lindex [file split [pwd]] 0]

# A really long file name.
# Length of long is 1216 chars, which should be greater than any static buffer
# or allowable filename.








<
<
<
<
<
<
<







156
157
158
159
160
161
162







163
164
165
166
167
168
169
proc contents {file} {
    set f [open $file]
    set r [read $f]
    close $f
    return $r
}









set root [lindex [file split [pwd]] 0]

# A really long file name.
# Length of long is 1216 chars, which should be greater than any static buffer
# or allowable filename.

582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628

629
630
631
632
633
634
635
636
    file mkdir [file join td1 td2]
    createfile [file join td1 td2 tf1]
    file mkdir td2
    file rename -force td2 td1
} -returnCodes error -match glob -result \
    [subst {error renaming "td2" to "[file join td1 td2]": file *}]
test fCmd-6.19 {CopyRenameOneFile: errno == EXDEV} -setup {
    cleanup /tmp
} -constraints {unix notRoot} -body {
    createfile tf1
    file rename tf1 /tmp
    glob -nocomplain tf* /tmp/tf1
} -result {/tmp/tf1}
test fCmd-6.20 {CopyRenameOneFile: errno == EXDEV} -constraints {win} -setup {
    catch {file delete -force c:/tcl8975@ d:/tcl8975@}
} -body {
    file mkdir c:/tcl8975@
    if {[catch {file rename c:/tcl8975@ d:/}]} {
	return d:/tcl8975@
    }
    glob c:/tcl8975@ d:/tcl8975@
} -cleanup {
    file delete -force c:/tcl8975@
    catch {file delete -force d:/tcl8975@}
} -result {d:/tcl8975@}
test fCmd-6.21 {CopyRenameOneFile: copy/rename: S_ISDIR(source)} -setup {
    cleanup /tmp
} -constraints {unix notRoot} -body {
    file mkdir td1
    file rename td1 /tmp
    glob -nocomplain td* /tmp/td*
} -result {/tmp/td1}
test fCmd-6.22 {CopyRenameOneFile: copy/rename: !S_ISDIR(source)} -setup {
    cleanup /tmp
} -constraints {unix notRoot} -body {
    createfile tf1
    file rename tf1 /tmp
    glob -nocomplain tf* /tmp/tf*
} -result {/tmp/tf1}
test fCmd-6.23 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
    cleanup /tmp
} -constraints {unix notRoot xdev} -body {
    file mkdir td1/td2/td3
    file attributes td1 -permissions 0000
    file rename td1 /tmp
} -returnCodes error -cleanup {
    file attributes td1 -permissions 0755

} -match regexp -result {^error renaming "td1"( to "/tmp/td1")?: permission denied$}
test fCmd-6.24 {CopyRenameOneFile: error uses original name} -setup {
    cleanup
} -constraints {unix notRoot} -body {
    file mkdir ~/td1/td2
    set td1name [file join [file dirname ~] [file tail ~] td1]
    file attributes $td1name -permissions 0000
    file copy ~/td1 td1







|
|

|
|
|













|
|

|
|
|

|
|

|
|
|

|
|


|


>
|







586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
    file mkdir [file join td1 td2]
    createfile [file join td1 td2 tf1]
    file mkdir td2
    file rename -force td2 td1
} -returnCodes error -match glob -result \
    [subst {error renaming "td2" to "[file join td1 td2]": file *}]
test fCmd-6.19 {CopyRenameOneFile: errno == EXDEV} -setup {
    cleanup $tmpspace
} -constraints {xdev notRoot} -body {
    createfile tf1
    file rename tf1 $tmpspace
    glob -nocomplain tf* [file join $tmpspace tf1]
} -result [file join $tmpspace tf1]
test fCmd-6.20 {CopyRenameOneFile: errno == EXDEV} -constraints {win} -setup {
    catch {file delete -force c:/tcl8975@ d:/tcl8975@}
} -body {
    file mkdir c:/tcl8975@
    if {[catch {file rename c:/tcl8975@ d:/}]} {
	return d:/tcl8975@
    }
    glob c:/tcl8975@ d:/tcl8975@
} -cleanup {
    file delete -force c:/tcl8975@
    catch {file delete -force d:/tcl8975@}
} -result {d:/tcl8975@}
test fCmd-6.21 {CopyRenameOneFile: copy/rename: S_ISDIR(source)} -setup {
    cleanup $tmpspace
} -constraints {xdev notRoot} -body {
    file mkdir td1
    file rename td1 $tmpspace
    glob -nocomplain td* [file join $tmpspace td*]
} -result [file join $tmpspace td1]
test fCmd-6.22 {CopyRenameOneFile: copy/rename: !S_ISDIR(source)} -setup {
    cleanup $tmpspace
} -constraints {xdev notRoot} -body {
    createfile tf1
    file rename tf1 $tmpspace
    glob -nocomplain tf* [file join $tmpspace tf*]
} -result [file join $tmpspace tf1]
test fCmd-6.23 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
    cleanup $tmpspace
} -constraints {notRoot xdev} -body {
    file mkdir td1/td2/td3
    file attributes td1 -permissions 0000
    file rename td1 $tmpspace
} -returnCodes error -cleanup {
    file attributes td1 -permissions 0755
    cleanup
} -match regexp -result {^error renaming "td1"( to "/tmp/tcl\d+/td1")?: permission denied$}
test fCmd-6.24 {CopyRenameOneFile: error uses original name} -setup {
    cleanup
} -constraints {unix notRoot} -body {
    file mkdir ~/td1/td2
    set td1name [file join [file dirname ~] [file tail ~] td1]
    file attributes $td1name -permissions 0000
    file copy ~/td1 td1
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679

680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
    file attributes $td2name -permissions 0000
    file copy ~/td1 td1
} -returnCodes error -cleanup {
    file attributes $td2name -permissions 0755
    file delete -force ~/td1
} -result "error copying \"~/td1\" to \"td1\": \"[file join $::env(HOME) td1 td2]\": permission denied"
test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
    cleanup /tmp
} -constraints {unix notRoot xdev} -returnCodes error -body {
    file mkdir td1/td2/td3
    file mkdir /tmp/td1
    createfile /tmp/td1/tf1
    file rename -force td1 /tmp
} -result {error renaming "td1" to "/tmp/td1": file already exists}
test fCmd-6.28 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
    cleanup /tmp
} -constraints {unix notRoot xdev} -body {
    file mkdir td1/td2/td3
    file attributes td1/td2/td3 -permissions 0000
    file rename td1 /tmp
} -returnCodes error -cleanup {
    file attributes td1/td2/td3 -permissions 0755

} -result {error renaming "td1" to "/tmp/td1": "td1/td2/td3": permission denied}
test fCmd-6.29 {CopyRenameOneFile: TclpCopyDirectory passed} -setup {
    cleanup /tmp
} -constraints {unix notRoot xdev} -body {
    file mkdir td1/td2/td3
    file rename td1 /tmp
    glob td* /tmp/td1/t*
} -result {/tmp/td1/td2}
test fCmd-6.30 {CopyRenameOneFile: TclpRemoveDirectory failed} -setup {
    cleanup
} -constraints {unix notRoot} -body {
    file mkdir foo/bar
    file attr foo -perm 040555
    file rename foo/bar /tmp
} -returnCodes error -cleanup {
    catch {file delete /tmp/bar}
    catch {file attr foo -perm 040777}
    catch {file delete -force foo}
} -match glob -result {*: permission denied}
test fCmd-6.31 {CopyRenameOneFile: TclpDeleteFile passed} -setup {
    catch {cleanup /tmp}
} -constraints {unix notRoot xdev} -body {
    file mkdir /tmp/td1
    createfile /tmp/td1/tf1
    file rename /tmp/td1/tf1 tf1
    list [file exists /tmp/td1/tf1] [file exists tf1]
} -result {0 1}
test fCmd-6.32 {CopyRenameOneFile: copy} -constraints {notRoot} -setup {
    cleanup
} -returnCodes error -body {
    file copy tf1 tf2
} -result {error copying "tf1": no such file or directory}
catch {cleanup /tmp}

test fCmd-7.1 {FileForceOption: none} -constraints {notRoot} -setup {
    cleanup
} -returnCodes error -body {
    file mkdir [file join tf1 tf2]
    file delete tf1
} -result {error deleting "tf1": directory not empty}







|
|

|
|
|
|

|
|


|


>
|

|
|

|
|
|

|
|


|

|




|
|
|
|
|
|






<







663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717

718
719
720
721
722
723
724
    file attributes $td2name -permissions 0000
    file copy ~/td1 td1
} -returnCodes error -cleanup {
    file attributes $td2name -permissions 0755
    file delete -force ~/td1
} -result "error copying \"~/td1\" to \"td1\": \"[file join $::env(HOME) td1 td2]\": permission denied"
test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
    cleanup $tmpspace
} -constraints {notRoot xdev} -returnCodes error -body {
    file mkdir td1/td2/td3
    file mkdir [file join $tmpspace td1]
    createfile [file join $tmpspace td1 tf1]
    file rename -force td1 $tmpspace
} -match glob -result {error renaming "td1" to "/tmp/tcl*/td1": file already exists}
test fCmd-6.28 {CopyRenameOneFile: TclpCopyDirectory failed} -setup {
    cleanup $tmpspace
} -constraints {notRoot xdev} -body {
    file mkdir td1/td2/td3
    file attributes td1/td2/td3 -permissions 0000
    file rename td1 $tmpspace
} -returnCodes error -cleanup {
    file attributes td1/td2/td3 -permissions 0755
    cleanup $tmpspace
} -match glob -result {error renaming "td1" to "/tmp/tcl*/td1": "td1/td2/td3": permission denied}
test fCmd-6.29 {CopyRenameOneFile: TclpCopyDirectory passed} -setup {
    cleanup $tmpspace
} -constraints {notRoot xdev} -body {
    file mkdir td1/td2/td3
    file rename td1 $tmpspace
    glob td* [file join $tmpspace td1 t*]
} -result [file join $tmpspace td1 td2]
test fCmd-6.30 {CopyRenameOneFile: TclpRemoveDirectory failed} -setup {
    cleanup $tmpspace
} -constraints {xdev notRoot} -body {
    file mkdir foo/bar
    file attr foo -perm 040555
    file rename foo/bar $tmpspace
} -returnCodes error -cleanup {
    catch {file delete [file join $tmpspace bar]}
    catch {file attr foo -perm 040777}
    catch {file delete -force foo}
} -match glob -result {*: permission denied}
test fCmd-6.31 {CopyRenameOneFile: TclpDeleteFile passed} -setup {
    cleanup $tmpspace
} -constraints {notRoot xdev} -body {
    file mkdir [file join $tmpspace td1]
    createfile [file join $tmpspace td1 tf1]
    file rename [file join $tmpspace td1 tf1] tf1
    list [file exists [file join $tmpspace td1 tf1]] [file exists tf1]
} -result {0 1}
test fCmd-6.32 {CopyRenameOneFile: copy} -constraints {notRoot} -setup {
    cleanup
} -returnCodes error -body {
    file copy tf1 tf2
} -result {error copying "tf1": no such file or directory}


test fCmd-7.1 {FileForceOption: none} -constraints {notRoot} -setup {
    cleanup
} -returnCodes error -body {
    file mkdir [file join tf1 tf2]
    file delete tf1
} -result {error deleting "tf1": directory not empty}
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
    file attributes tfa -permissions 0555
    catch {file rename tfa/dir tfa2}
} -cleanup {
    catch {file attributes tfa -permissions 0777}
    file delete -force tfa
} -result {1}
test fCmd-12.9 {renamefile: moving a file across volumes} -setup {
    catch {file delete -force -- tfa /tmp/tfa}
} -constraints {unix notRoot} -body {
    set s [createfile tfa]
    file rename tfa /tmp
    list [checkcontent /tmp/tfa $s] [file exists tfa]
} -cleanup {
    file delete /tmp/tfa
} -result {1 0}
test fCmd-12.10 {renamefile: moving a directory across volumes} -setup {
    catch {file delete -force -- tfad /tmp/tfad}
} -constraints {unix notRoot} -body {
    file mkdir tfad
    set s [createfile tfad/a]
    file rename tfad /tmp
    list [checkcontent /tmp/tfad/a $s] [file exists tfad]
} -cleanup {
    file delete -force /tmp/tfad
} -result {1 0}

#
# Coverage tests for TclCopyFilesCmd()
#
test fCmd-13.1 {TclCopyFilesCmd: -force option} -constraints notRoot -setup {
    catch {file delete -force -- tfa1}







|
|

|
|

|


|
|


|
|

|







1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
    file attributes tfa -permissions 0555
    catch {file rename tfa/dir tfa2}
} -cleanup {
    catch {file attributes tfa -permissions 0777}
    file delete -force tfa
} -result {1}
test fCmd-12.9 {renamefile: moving a file across volumes} -setup {
    cleanup $tmpspace
} -constraints {xdev notRoot} -body {
    set s [createfile tfa]
    file rename tfa $tmpspace
    list [checkcontent [file join $tmpspace tfa] $s] [file exists tfa]
} -cleanup {
    cleanup $tmpspace
} -result {1 0}
test fCmd-12.10 {renamefile: moving a directory across volumes} -setup {
    cleanup $tmpspace
} -constraints {xdev notRoot} -body {
    file mkdir tfad
    set s [createfile tfad/a]
    file rename tfad $tmpspace
    list [checkcontent [file join $tmpspace tfad a] $s] [file exists tfad]
} -cleanup {
    cleanup $tmpspace
} -result {1 0}

#
# Coverage tests for TclCopyFilesCmd()
#
test fCmd-13.1 {TclCopyFilesCmd: -force option} -constraints notRoot -setup {
    catch {file delete -force -- tfa1}
2579
2580
2581
2582
2583
2584
2585



2586
2587
2588
2589
2590
2591
2592
        lappend r stat [catch {file stat $path a} e] $e
    }
    return $r
} -result {exists 1 readable 0 stat 0 {}}

# cleanup
cleanup



::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# fill-column: 78
# End:







>
>
>







2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
        lappend r stat [catch {file stat $path a} e] $e
    }
    return $r
} -result {exists 1 readable 0 stat 0 {}}

# cleanup
cleanup
if {[testConstraint unix]} {
    removeDirectory tcl[pid] /tmp
}
::tcltest::cleanupTests
return

# Local Variables:
# mode: tcl
# fill-column: 78
# End: