Debian Codegraph @

tests/winFCmd.test

raw
1 # This file tests the tclWinFCmd.c file.
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) 1996-1997 Sun Microsystems, Inc.
8 # Copyright (c) 1998-1999 Scriptics Corporation.
9 #
10 # See the file "license.terms" for information on usage and redistribution
11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
13 if {"::tcltest" ni [namespace children]} {
14 package require tcltest 2.5
15 namespace import -force ::tcltest::*
16 }
17
18 ::tcltest::loadTestedCommands
19 catch [list package require -exact Tcltest [info patchlevel]]
20
21 # Initialise the test constraints
22
23 testConstraint winVista 0
24 testConstraint win2000orXP 0
25 testConstraint winOlderThan2000 0
26 testConstraint testvolumetype [llength [info commands testvolumetype]]
27 testConstraint testfile [llength [info commands testfile]]
28 testConstraint testchmod [llength [info commands testchmod]]
29 testConstraint cdrom 0
30 testConstraint exdev 0
31 testConstraint longFileNames 0
32 # Some things fail under all Continuous Integration systems for subtle reasons
33 # such as CI often running with elevated privileges in a container.
34 testConstraint notInCIenv [expr {![info exists ::env(CI)]}]
35
36 proc createfile {file {string a}} {
37 set f [open $file w]
38 puts -nonewline $f $string
39 close $f
40 return $string
41 }
42
43 proc contents {file} {
44 set f [open $file r]
45 set r [read $f]
46 close $f
47 set r
48 }
49
50 proc cleanupRecurse {args} {
51 # Assumes no loops via links!
52 # Need to change permissions BEFORE deletion
53 catch {testchmod 0o777 {*}$args}
54 foreach victim $args {
55 if {[file isdirectory $victim]} {
56 cleanupRecurse {*}[glob -nocomplain -directory $victim td* tf* Test*]
57 }
58 file delete -force $victim
59 }
60 }
61 proc cleanup {args} {
62 foreach p [list [pwd] {*}$args] {
63 cleanupRecurse {*}[glob -nocomplain -directory $p tf* td*]
64 }
65 }
66
67 if {[testConstraint winOnly]} {
68 if {[testConstraint nt] && $::tcl_platform(osVersion) >= 5.0} {
69 if {$::tcl_platform(osVersion) >= 6.0} {
70 testConstraint winVista 1
71 } else {
72 testConstraint win2000orXP 1
73 }
74 } else {
75 testConstraint winOlderThan2000 1
76 }
77 }
78
79 # find a CD-ROM so we can test read-only filesystems.
80
81 proc findfile {dir} {
82 foreach p [glob -nocomplain -type f -directory $dir *] {
83 return $p
84 }
85 foreach p [glob -nocomplain -type d -directory $dir *] {
86 set f [findfile $p]
87 if {$f ne ""} {
88 return $f
89 }
90 }
91 return ""
92 }
93
94 if {[testConstraint testvolumetype]} {
95 foreach p {d e f g h i j k l m n o p q r s t u v w x y z} {
96 if {![catch {testvolumetype ${p}:} result] && $result in {CDFS UDF}} {
97 set cdrom ${p}:
98 set cdfile [findfile $cdrom]
99 testConstraint cdrom 1
100 break
101 }
102 }
103 }
104
105 # NB: filename is chosen to be short but unlikely to clash with other apps
106 if {[file exists c:/] && [file exists d:/]} {
107 catch {file delete d:/TclTmpF.1}
108 catch {file delete d:/TclTmpD.1}
109 catch {file delete c:/TclTmpC.1}
110 if {![catch {createfile d:/TclTmpF.1 {}}] && [file isfile d:/TclTmpF.1]
111 && ![catch {file mkdir d:/TclTmpD.1}] && [file isdirectory d:/TclTmpD.1]
112 && ![catch {file mkdir c:/TclTmpC.1}] && [file isdirectory c:/TclTmpC.1]
113 } {
114 file delete d:/TclTmpF.1 d:/TclTmpD.1 c:/TclTmpC.1
115 testConstraint exdev 1
116 }
117 }
118
119 file delete -force -- td1
120 if {![catch {open td1 w} testfile]} {
121 close $testfile
122 testConstraint longFileNames 1
123 file delete -force -- td1
124 }
125
126 # A really long file name
127 # length of longname is 1216 chars, which should be greater than any static
128 # buffer or allowable filename.
129
130 set longname "abcdefghihjllmnopqrstuvwxyz01234567890"
131 append longname $longname
132 append longname $longname
133 append longname $longname
134 append longname $longname
135 append longname $longname
136
137 # Uses the "testfile" command instead of the "file" command. The "file"
138 # command provides several layers of sanity checks on the arguments and
139 # it can be difficult to actually forward "insane" arguments to the
140 # low-level Posix emulation layer.
141
142 test winFCmd-1.1 {TclpRenameFile: errno: EACCES} -body {
143 testfile mv $cdfile $cdrom/dummy~~.fil
144 } -constraints {win cdrom testfile} -returnCodes error -result EACCES
145 test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} -setup {
146 cleanup
147 } -constraints {win testfile} -body {
148 file mkdir td1/td2/td3
149 file mkdir td2
150 testfile mv td2 td1/td2
151 } -returnCodes error -result EEXIST
152 test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} -setup {
153 cleanup
154 } -constraints {win testfile} -body {
155 testfile mv / td1
156 } -returnCodes error -result EINVAL
157 test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} -setup {
158 cleanup
159 } -constraints {win testfile} -body {
160 file mkdir td1
161 testfile mv td1 td1/td2
162 } -returnCodes error -result EINVAL
163 test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} -setup {
164 cleanup
165 } -constraints {win testfile} -body {
166 file mkdir td1
167 createfile tf1
168 testfile mv tf1 td1
169 } -returnCodes error -result EISDIR
170 test winFCmd-1.6 {TclpRenameFile: errno: ENOENT} -setup {
171 cleanup
172 } -constraints {win testfile} -body {
173 testfile mv tf1 tf2
174 } -returnCodes error -result ENOENT
175 test winFCmd-1.7 {TclpRenameFile: errno: ENOENT} -setup {
176 cleanup
177 } -constraints {win testfile} -body {
178 testfile mv "" tf2
179 } -returnCodes error -result ENOENT
180 test winFCmd-1.8 {TclpRenameFile: errno: ENOENT} -setup {
181 cleanup
182 } -constraints {win testfile} -body {
183 createfile tf1
184 testfile mv tf1 ""
185 } -returnCodes error -result ENOENT
186 test winFCmd-1.9 {TclpRenameFile: errno: ENOTDIR} -setup {
187 cleanup
188 } -constraints {win testfile} -body {
189 file mkdir td1
190 createfile tf1
191 testfile mv td1 tf1
192 } -returnCodes error -result ENOTDIR
193 test winFCmd-1.10 {TclpRenameFile: errno: EXDEV} -setup {
194 file delete -force d:/TclTmpD.1
195 } -constraints {win exdev testfile} -body {
196 file mkdir c:/TclTmpC.1
197 testfile mv c:/TclTmpC.1 d:/TclTmpD.1
198 } -cleanup {
199 file delete -force c:/TclTmpC.1
200 } -returnCodes error -result EXDEV
201 test winFCmd-1.11 {TclpRenameFile: errno: EACCES} -setup {
202 cleanup
203 } -constraints {win testfile} -body {
204 set fd [open tf1 w]
205 testfile mv tf1 tf2
206 } -cleanup {
207 catch {close $fd}
208 } -returnCodes error -result EACCES
209 test winFCmd-1.12 {TclpRenameFile: errno: EACCES} -setup {
210 cleanup
211 } -constraints {win testfile} -body {
212 createfile tf1
213 set fd [open tf2 w]
214 testfile mv tf1 tf2
215 } -cleanup {
216 catch {close $fd}
217 } -returnCodes error -result EACCES
218 test winFCmd-1.13 {TclpRenameFile: errno: EACCES} -setup {
219 cleanup
220 } -constraints {win win2000orXP testfile} -body {
221 testfile mv nul tf1
222 } -returnCodes error -result EINVAL
223 test winFCmd-1.14 {TclpRenameFile: errno: EACCES} -setup {
224 cleanup
225 } -constraints {win nt winOlderThan2000 testfile} -body {
226 testfile mv nul tf1
227 } -returnCodes error -result EACCES
228 test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} -setup {
229 cleanup
230 } -constraints {win nt testfile} -body {
231 createfile tf1
232 testfile mv tf1 nul
233 } -returnCodes error -result EEXIST
234 test winFCmd-1.16 {TclpRenameFile: MoveFile() != FALSE} -setup {
235 cleanup
236 } -constraints {win testfile} -body {
237 createfile tf1 tf1
238 testfile mv tf1 tf2
239 list [file exists tf1] [contents tf2]
240 } -result {0 tf1}
241 test winFCmd-1.17 {TclpRenameFile: MoveFile() == FALSE} -setup {
242 cleanup
243 } -constraints {win testfile} -body {
244 testfile mv tf1 tf2
245 } -returnCodes error -result ENOENT
246 test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} -setup {
247 cleanup
248 } -constraints {win testfile} -body {
249 testfile mv tf1 tf2
250 } -returnCodes error -result ENOENT
251 test winFCmd-1.19 {TclpRenameFile: errno == EACCES} -setup {
252 cleanup
253 } -constraints {win win2000orXP testfile} -body {
254 testfile mv nul tf1
255 } -returnCodes error -result EINVAL
256 test winFCmd-1.19.1 {TclpRenameFile: errno == EACCES} -setup {
257 cleanup
258 } -constraints {win nt winOlderThan2000 testfile} -body {
259 testfile mv nul tf1
260 } -returnCodes error -result EACCES
261 test winFCmd-1.20 {TclpRenameFile: src is dir} -setup {
262 cleanup
263 } -constraints {win nt testfile} -body {
264 # under 95, this would actually succeed and move the current dir out from
265 # under the current process!
266 file delete /tf1
267 testfile mv [pwd] /tf1
268 } -returnCodes error -result EACCES
269 test winFCmd-1.21 {TclpRenameFile: long src} -setup {
270 cleanup
271 } -constraints {win testfile} -body {
272 testfile mv $longname tf1
273 } -returnCodes error -result ENAMETOOLONG
274 test winFCmd-1.22 {TclpRenameFile: long dst} -setup {
275 cleanup
276 } -constraints {win testfile} -body {
277 createfile tf1
278 testfile mv tf1 $longname
279 } -returnCodes error -result ENAMETOOLONG
280 test winFCmd-1.23 {TclpRenameFile: move dir into self} -setup {
281 cleanup
282 } -constraints {win testfile} -body {
283 file mkdir td1
284 testfile mv [pwd]/td1 td1/td2
285 } -returnCodes error -result EINVAL
286 test winFCmd-1.24 {TclpRenameFile: move a root dir} -setup {
287 cleanup
288 } -constraints {win testfile} -body {
289 # Error code depends on Windows version
290 testfile mv / c:/
291 } -returnCodes error -result {^(EINVAL|ENOENT)$} -match regexp
292 test winFCmd-1.25 {TclpRenameFile: cross file systems} -setup {
293 cleanup
294 } -constraints {win cdrom testfile} -body {
295 file mkdir td1
296 testfile mv td1 $cdrom/td1
297 } -returnCodes error -result EXDEV
298 test winFCmd-1.26 {TclpRenameFile: readonly fs} -setup {
299 cleanup
300 } -constraints {win cdrom testfile} -body {
301 testfile mv $cdfile $cdrom/dummy~~.fil
302 } -returnCodes error -result EACCES
303 test winFCmd-1.27 {TclpRenameFile: open file} -setup {
304 cleanup
305 } -constraints {win testfile} -body {
306 set fd [open tf1 w]
307 testfile mv tf1 tf2
308 } -cleanup {
309 catch {close $fd}
310 } -returnCodes error -result EACCES
311 test winFCmd-1.28 {TclpRenameFile: errno == EEXIST} -setup {
312 cleanup
313 } -constraints {win testfile} -body {
314 createfile tf1
315 createfile tf2
316 testfile mv tf1 tf2
317 list [file exists tf1] [file exists tf2]
318 } -result {0 1}
319 test winFCmd-1.29 {TclpRenameFile: src is dir} -setup {
320 cleanup
321 } -constraints {win testfile} -body {
322 file mkdir td1
323 createfile tf1
324 testfile mv td1 tf1
325 } -returnCodes error -result ENOTDIR
326 test winFCmd-1.30 {TclpRenameFile: dst is dir} -setup {
327 cleanup
328 } -constraints {win testfile} -body {
329 file mkdir td1
330 file mkdir td2/td2
331 testfile mv td1 td2
332 } -returnCodes error -result EEXIST
333 test winFCmd-1.31 {TclpRenameFile: TclpRemoveDirectory fails} -setup {
334 cleanup
335 } -constraints {win testfile} -body {
336 file mkdir td1
337 file mkdir td2/td2
338 testfile mv td1 td2
339 } -returnCodes error -result EEXIST
340 test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory succeeds} -setup {
341 cleanup
342 } -constraints {win testfile} -body {
343 file mkdir td1/td2
344 file mkdir td2
345 testfile mv td1 td2
346 list [file exists td1] [file exists td2] [file exists td2/td2]
347 } -result {0 1 1}
348 test winFCmd-1.33 {TclpRenameFile: After removing dst dir, MoveFile fails} \
349 -constraints {win exdev testfile testchmod} -body {
350 file mkdir d:/TclTmpD.1
351 testchmod 0 d:/TclTmpD.1
352 file mkdir c:/TclTmpC.1
353 catch {testfile mv c:/TclTmpC.1 d:/TclTmpD.1} msg
354 list $msg [file writable d:/TclTmpD.1]
355 } -cleanup {
356 catch {testchmod 0o666 d:/TclTmpD.1}
357 file delete d:/TclTmpD.1
358 file delete -force c:/TclTmpC.1
359 } -result {EXDEV 0}
360 test winFCmd-1.34 {TclpRenameFile: src is dir, dst is not} -setup {
361 cleanup
362 } -constraints {win testfile} -body {
363 file mkdir td1
364 createfile tf1
365 testfile mv td1 tf1
366 } -cleanup {
367 cleanup
368 } -returnCodes error -result ENOTDIR
369 test winFCmd-1.35 {TclpRenameFile: src is not dir, dst is} -setup {
370 cleanup
371 } -constraints {win testfile} -body {
372 file mkdir td1
373 createfile tf1
374 testfile mv tf1 td1
375 } -cleanup {
376 cleanup
377 } -returnCodes error -result EISDIR
378 test winFCmd-1.36 {TclpRenameFile: src and dst not dir} -setup {
379 cleanup
380 } -constraints {win testfile} -body {
381 createfile tf1 tf1
382 createfile tf2 tf2
383 testfile mv tf1 tf2
384 contents tf2
385 } -cleanup {
386 cleanup
387 } -result {tf1}
388 test winFCmd-1.37 {TclpRenameFile: need to restore temp file} {win emptyTest} {
389 # Can't figure out how to cause this.
390 # Need a file that can't be copied.
391 } {}
392
393 # If the native filesystem produces 0 for inodes numbers there is no point
394 # doing the following test.
395 testConstraint winNonZeroInodes [eval {
396 file stat [info nameofexecutable] statExe
397 expr {$statExe(ino) != 0}
398 }]
399
400 proc MakeFiles {dirname} {
401 set inodes {}
402 set ndx -1
403 while {1} {
404 # upped to 50K for 64bit Server 2008
405 if {$ndx > 50000} {
406 tcltest::Skip "limit-reached:no-collistion"
407 }
408 set filename [file join $dirname Test[incr ndx]]
409 set f [open $filename w]
410 close $f
411 file stat $filename stat
412 if {[set n [lsearch -exact -integer $inodes $stat(ino)]] >= 0} {
413 return [list [file join $dirname Test$n] $filename]
414 }
415 lappend inodes $stat(ino)
416 unset stat
417 }
418 }
419
420 test winFCmd-1.38 {TclpRenameFile: check rename of conflicting inodes} -setup {
421 cleanup
422 } -constraints {win winNonZeroInodes notInCIenv extensive} -body {
423 file mkdir td1
424 lassign [MakeFiles td1] a b
425 file rename -force $a $b
426 file exists $a
427 } -cleanup {
428 cleanup
429 } -result 0
430
431
432 test winFCmd-2.1 {TclpCopyFile: errno: EACCES} -setup {
433 cleanup
434 } -constraints {win cdrom testfile} -body {
435 testfile cp $cdfile $cdrom/dummy~~.fil
436 } -returnCodes error -result EACCES
437 test winFCmd-2.2 {TclpCopyFile: errno: EISDIR} -setup {
438 cleanup
439 } -constraints {win testfile} -body {
440 file mkdir td1
441 testfile cp td1 tf1
442 } -cleanup {
443 cleanup
444 } -returnCodes error -result EISDIR
445 test winFCmd-2.3 {TclpCopyFile: errno: EISDIR} -setup {
446 cleanup
447 } -constraints {win testfile} -body {
448 createfile tf1
449 file mkdir td1
450 testfile cp tf1 td1
451 } -cleanup {
452 cleanup
453 } -returnCodes error -result EISDIR
454 test winFCmd-2.4 {TclpCopyFile: errno: ENOENT} -setup {
455 cleanup
456 } -constraints {win testfile} -body {
457 testfile cp tf1 tf2
458 } -returnCodes error -result ENOENT
459 test winFCmd-2.5 {TclpCopyFile: errno: ENOENT} -setup {
460 cleanup
461 } -constraints {win testfile} -body {
462 testfile cp "" tf2
463 } -returnCodes error -result ENOENT
464 test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} -setup {
465 cleanup
466 } -constraints {win testfile} -body {
467 createfile tf1
468 testfile cp tf1 ""
469 } -cleanup {
470 cleanup
471 } -returnCodes error -result ENOENT
472 test winFCmd-2.7 {TclpCopyFile: errno: EACCES} -setup {
473 cleanup
474 } -constraints {win win2000orXP testfile} -body {
475 testfile cp nul tf1
476 } -returnCodes error -result EINVAL
477 test winFCmd-2.8 {TclpCopyFile: errno: EACCES} -setup {
478 cleanup
479 } -constraints {win nt winOlderThan2000 testfile} -body {
480 testfile cp nul tf1
481 } -returnCodes error -result EACCES
482 test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} -setup {
483 cleanup
484 } -constraints {win testfile} -body {
485 createfile tf1 tf1
486 testfile cp tf1 tf2
487 list [contents tf1] [contents tf2]
488 } -cleanup {
489 cleanup
490 } -result {tf1 tf1}
491 test winFCmd-2.11 {TclpCopyFile: CopyFile succeeds} -setup {
492 cleanup
493 } -constraints {win testfile} -body {
494 createfile tf1 tf1
495 createfile tf2 tf2
496 testfile cp tf1 tf2
497 list [contents tf1] [contents tf2]
498 } -cleanup {
499 cleanup
500 } -result {tf1 tf1}
501 test winFCmd-2.12 {TclpCopyFile: CopyFile succeeds} -setup {
502 cleanup
503 } -constraints {win testfile testchmod} -body {
504 createfile tf1 tf1
505 file attribute tf1 -readonly 1
506 testfile cp tf1 tf2
507 list [contents tf2] [file writable tf2]
508 } -cleanup {
509 testchmod 0o660 tf1
510 cleanup
511 } -result {tf1 0}
512 test winFCmd-2.13 {TclpCopyFile: CopyFile fails} -setup {
513 cleanup
514 } -constraints {win testfile} -body {
515 createfile tf1
516 file mkdir td1
517 testfile cp tf1 td1
518 } -cleanup {
519 cleanup
520 } -returnCodes error -result EISDIR
521 test winFCmd-2.14 {TclpCopyFile: errno == EACCES} -setup {
522 cleanup
523 } -constraints {win testfile} -body {
524 file mkdir td1
525 testfile cp td1 tf1
526 } -cleanup {
527 cleanup
528 } -returnCodes error -result EISDIR
529 test winFCmd-2.15 {TclpCopyFile: src is directory} -setup {
530 cleanup
531 } -constraints {win testfile} -body {
532 file mkdir td1
533 testfile cp td1 tf1
534 } -cleanup {
535 cleanup
536 } -returnCodes error -result EISDIR
537 test winFCmd-2.16 {TclpCopyFile: dst is directory} -setup {
538 cleanup
539 } -constraints {win testfile} -body {
540 createfile tf1
541 file mkdir td1
542 testfile cp tf1 td1
543 } -cleanup {
544 cleanup
545 } -returnCodes error -result EISDIR
546 test winFCmd-2.17 {TclpCopyFile: dst is readonly} -setup {
547 cleanup
548 } -constraints {win testfile testchmod} -body {
549 createfile tf1 tf1
550 createfile tf2 tf2
551 file attribute tf2 -readonly 1
552 testfile cp tf1 tf2
553 list [file writable tf2] [contents tf2]
554 } -cleanup {
555 cleanup
556 } -result {1 tf1}
557
558 test winFCmd-3.1 {TclpDeleteFile: errno: EACCES} -body {
559 testfile rm $cdfile $cdrom/dummy~~.fil
560 } -constraints {win cdrom testfile} -returnCodes error -result EACCES
561 test winFCmd-3.2 {TclpDeleteFile: errno: EISDIR} -setup {
562 cleanup
563 } -constraints {win testfile} -body {
564 file mkdir td1
565 testfile rm td1
566 } -cleanup {
567 cleanup
568 } -returnCodes error -result EISDIR
569 test winFCmd-3.3 {TclpDeleteFile: errno: ENOENT} -setup {
570 cleanup
571 } -constraints {win testfile} -body {
572 testfile rm tf1
573 } -returnCodes error -result ENOENT
574 test winFCmd-3.4 {TclpDeleteFile: errno: ENOENT} -setup {
575 cleanup
576 } -constraints {win testfile} -body {
577 testfile rm ""
578 } -returnCodes error -result ENOENT
579 test winFCmd-3.5 {TclpDeleteFile: errno: EACCES} -setup {
580 cleanup
581 } -constraints {win testfile} -body {
582 set fd [open tf1 w]
583 testfile rm tf1
584 } -cleanup {
585 close $fd
586 cleanup
587 } -returnCodes error -result EACCES
588 test winFCmd-3.6 {TclpDeleteFile: errno: EACCES} -setup {
589 cleanup
590 } -constraints {win testfile} -body {
591 testfile rm nul
592 } -returnCodes error -result EACCES
593 test winFCmd-3.7 {TclpDeleteFile: DeleteFile succeeds} -setup {
594 cleanup
595 } -constraints {win testfile} -body {
596 createfile tf1
597 testfile rm tf1
598 file exists tf1
599 } -result {0}
600 test winFCmd-3.8 {TclpDeleteFile: DeleteFile fails} -setup {
601 cleanup
602 } -constraints {win testfile} -body {
603 file mkdir td1
604 testfile rm td1
605 } -cleanup {
606 cleanup
607 } -returnCodes error -result EISDIR
608 test winFCmd-3.9 {TclpDeleteFile: errno == EACCES} -setup {
609 cleanup
610 } -constraints {win testfile} -body {
611 set fd [open tf1 w]
612 testfile rm tf1
613 } -cleanup {
614 close $fd
615 } -returnCodes error -result EACCES
616 test winFCmd-3.10 {TclpDeleteFile: path is readonly} -setup {
617 cleanup
618 } -constraints {win testfile testchmod} -body {
619 createfile tf1
620 testchmod 0 tf1
621 testfile rm tf1
622 file exists tf1
623 } -result {0}
624 test winFCmd-3.11 {TclpDeleteFile: still can't remove path} -setup {
625 cleanup
626 } -constraints {win testfile testchmod} -body {
627 set fd [open tf1 w]
628 testchmod 0 tf1
629 testfile rm tf1
630 } -cleanup {
631 close $fd
632 cleanup
633 } -returnCodes error -result EACCES
634
635 test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} -body {
636 testfile mkdir $cdrom/dummy~~.dir
637 } -constraints {win nt cdrom testfile} -returnCodes error -result EACCES
638 test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} -setup {
639 cleanup
640 } -constraints {win testfile} -body {
641 file mkdir td1
642 testfile mkdir td1
643 } -cleanup {
644 cleanup
645 } -returnCodes error -result EEXIST
646 test winFCmd-4.4 {TclpCreateDirectory: errno: ENOENT} -setup {
647 cleanup
648 } -constraints {win testfile} -body {
649 testfile mkdir td1/td2
650 } -returnCodes error -result ENOENT
651 test winFCmd-4.5 {TclpCreateDirectory: CreateDirectory succeeds} -setup {
652 cleanup
653 } -constraints {win testfile} -body {
654 testfile mkdir td1
655 file type td1
656 } -cleanup cleanup -result directory
657
658 test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} -setup {
659 cleanup
660 } -constraints {win testfile} -body {
661 file mkdir td1
662 testfile cpdir td1 td2
663 list [file type td1] [file type td2]
664 } -cleanup {
665 cleanup
666 } -result {directory directory}
667
668 test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} -setup {
669 cleanup
670 } -constraints {winVista testfile testchmod notInCIenv} -body {
671 # Parent's FILE_DELETE_CHILD setting permits deletion of subdir
672 # even when subdir DELETE mask is clear. So we need an intermediate
673 # parent td0 with FILE_DELETE_CHILD turned off while allowing R/W.
674 file mkdir td0/td1
675 testchmod 0o777 td0
676 testchmod 0 td0/td1
677 testfile rmdir td0/td1
678 file exists td0/td1
679 } -returnCodes error -cleanup {
680 cleanup
681 } -result {td0/td1 EACCES}
682 # This next test has a very hokey way of matching...
683 test winFCmd-6.2 {TclpRemoveDirectory: errno: EEXIST} -setup {
684 cleanup
685 } -constraints {win testfile} -body {
686 file mkdir td1/td2
687 list [catch {testfile rmdir td1} msg] [file tail $msg]
688 } -result {1 {td1 EEXIST}}
689 test winFCmd-6.3 {TclpRemoveDirectory: errno: EACCES} {win emptyTest trashSystem} {
690 # can't test this w/o removing everything on your hard disk first!
691 # testfile rmdir /
692 } {}
693 # This next test has a very hokey way of matching...
694 test winFCmd-6.4 {TclpRemoveDirectory: errno: ENOENT} -setup {
695 cleanup
696 } -constraints {win testfile} -body {
697 list [catch {testfile rmdir td1} msg] [file tail $msg]
698 } -result {1 {td1 ENOENT}}
699 test winFCmd-6.5 {TclpRemoveDirectory: errno: ENOENT} -setup {
700 cleanup
701 } -constraints {win testfile} -body {
702 testfile rmdir ""
703 } -returnCodes error -result ENOENT
704 # This next test has a very hokey way of matching...
705 test winFCmd-6.6 {TclpRemoveDirectory: errno: ENOTDIR} -setup {
706 cleanup
707 } -constraints {win testfile} -body {
708 createfile tf1
709 list [catch {testfile rmdir tf1} msg] [file tail $msg]
710 } -result {1 {tf1 ENOTDIR}}
711 test winFCmd-6.7 {TclpRemoveDirectory: RemoveDirectory succeeds} -setup {
712 cleanup
713 } -constraints {win testfile} -body {
714 file mkdir td1
715 testfile rmdir td1
716 file exists td1
717 } -result {0}
718 # This next test has a very hokey way of matching...
719 test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} -setup {
720 cleanup
721 } -constraints {win testfile} -body {
722 createfile tf1
723 list [catch {testfile rmdir tf1} msg] [file tail $msg]
724 } -result {1 {tf1 ENOTDIR}}
725 # winFCmd-6.9 removed - was exact dup of winFCmd-6.1
726 test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} -setup {
727 cleanup
728 } -constraints {win nt testfile} -body {
729 testfile rmdir /
730 # WinXP returns EEXIST, WinNT seems to return EACCES. No policy
731 # decision has been made as to which is correct.
732 } -returnCodes error -match regexp -result {^/ E(ACCES|EXIST)$}
733 test winFCmd-6.13 {TclpRemoveDirectory: write-protected} -setup {
734 cleanup
735 } -constraints {winVista testfile testchmod notInCIenv} -body {
736 # Parent's FILE_DELETE_CHILD setting permits deletion of subdir
737 # even when subdir DELETE mask is clear. So we need an intermediate
738 # parent td0 with FILE_DELETE_CHILD turned off while allowing R/W.
739 file mkdir td0/td1
740 testchmod 0o770 td0
741 testchmod 0o444 td0/td1
742 testfile rmdir td0/td1
743 file exists td0/td1
744 } -cleanup {
745 testchmod 0o770 td0/td1
746 cleanup
747 } -returnCodes error -result {td0/td1 EACCES}
748 # This next test has a very hokey way of matching...
749 test winFCmd-6.15 {TclpRemoveDirectory: !recursive} -setup {
750 cleanup
751 } -constraints {win testfile} -body {
752 file mkdir td1/td2
753 list [catch {testfile rmdir td1} msg] [file tail $msg]
754 } -result {1 {td1 EEXIST}}
755 test winFCmd-6.16 {TclpRemoveDirectory: recursive, but errno != EEXIST} -setup {
756 cleanup
757 } -constraints {win testfile} -body {
758 createfile tf1
759 testfile rmdir -force tf1
760 } -returnCodes error -result {tf1 ENOTDIR}
761 test winFCmd-6.17 {TclpRemoveDirectory: calls TraverseWinTree} -setup {
762 cleanup
763 } -constraints {win testfile} -body {
764 file mkdir td1/td2
765 testfile rmdir -force td1
766 file exists td1
767 } -result {0}
768
769 test winFCmd-7.1 {TraverseWinTree: targetPtr == NULL} -setup {
770 cleanup
771 } -constraints {win testfile} -body {
772 file mkdir td1/td2/td3
773 testfile rmdir -force td1
774 file exists td1
775 } -result {0}
776 test winFCmd-7.2 {TraverseWinTree: targetPtr != NULL} -setup {
777 cleanup
778 } -constraints {win testfile} -body {
779 file mkdir td1/td2/td3
780 testfile cpdir td1 td2
781 list [file exists td1] [file exists td2]
782 } -cleanup {
783 cleanup
784 } -result {1 1}
785 test winFCmd-7.3 {TraverseWinTree: sourceAttr == -1} -setup {
786 cleanup
787 } -constraints {win testfile} -body {
788 testfile cpdir td1 td2
789 } -returnCodes error -result {td1 ENOENT}
790 test winFCmd-7.4 {TraverseWinTree: source isn't directory} -setup {
791 cleanup
792 } -constraints {win testfile} -body {
793 file mkdir td1
794 createfile td1/tf1 tf1
795 testfile cpdir td1 td2
796 contents td2/tf1
797 } -cleanup {
798 cleanup
799 } -result {tf1}
800 test winFCmd-7.5 {TraverseWinTree: call TraversalCopy: DOTREE_F} -setup {
801 cleanup
802 } -constraints {win testfile} -body {
803 file mkdir td1
804 createfile td1/tf1 tf1
805 testfile cpdir td1 td2
806 contents td2/tf1
807 } -cleanup {
808 cleanup
809 } -result {tf1}
810 test winFCmd-7.6 {TraverseWinTree: call TraversalDelete: DOTREE_F} -setup {
811 cleanup
812 } -constraints {win testfile} -body {
813 file mkdir td1
814 createfile td1/tf1 tf1
815 testfile rmdir -force td1
816 file exists td1
817 } -result {0}
818 test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} -setup {
819 cleanup
820 } -constraints {win testfile} -body {
821 file mkdir td1
822 createfile td1/tf1 tf1
823 testfile cpdir td1 td2
824 contents td2/tf1
825 } -cleanup {
826 cleanup
827 } -result {tf1}
828 test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} -body {
829 testfile rmdir $cdrom/
830 } -constraints {win nt cdrom testfile} -returnCodes error -match glob \
831 -result {* EACCES}
832 test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} \
833 {win emptyTest} {
834 # can't make it happen
835 } {}
836 test winFCmd-7.11 {TraverseWinTree: call TraversalCopy: DOTREE_PRED} -setup {
837 cleanup
838 } -constraints {win testfile testchmod} -body {
839 file mkdir td1
840 createfile td1/tf1 tf1
841 testchmod 0o770 td1/tf1; # Else tf2 will have no ACL after td1 testchmod
842 testchmod 0o400 td1
843 testfile cpdir td1 td2
844 list [file exists td2] [file writable td2]
845 } -cleanup {
846 testchmod 0o660 td1
847 cleanup
848 } -result {1 1}
849 test winFCmd-7.12 {TraverseWinTree: call TraversalDelete: DOTREE_PRED} -setup {
850 cleanup
851 } -constraints {win testfile} -body {
852 file mkdir td1
853 createfile td1/tf1 tf1
854 testfile rmdir -force td1
855 file exists td1
856 } -result {0}
857 test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} -setup {
858 cleanup
859 } -constraints {win testfile} -body {
860 file mkdir td1
861 createfile td1/tf1 tf1
862 testfile cpdir td1 td2
863 contents td2/tf1
864 } -cleanup {
865 cleanup
866 } -result {tf1}
867 test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} -setup {
868 cleanup
869 } -constraints {win nt testfile} -body {
870 file mkdir td1
871 testfile cpdir td1 /
872 } -cleanup {
873 cleanup
874 # Windows7 returns EEXIST, XP returns EACCES
875 } -returnCodes error -match regexp -result {^/ E(ACCES|EXIST)$}
876 test winFCmd-7.16 {TraverseWinTree: recurse on files: no files} -setup {
877 cleanup
878 } -constraints {win testfile} -body {
879 file mkdir td1
880 testfile cpdir td1 td2
881 } -cleanup {
882 cleanup
883 } -result {}
884 test winFCmd-7.17 {TraverseWinTree: recurse on files: one file} -setup {
885 cleanup
886 } -constraints {win testfile} -body {
887 file mkdir td1
888 createfile td1/td2
889 testfile cpdir td1 td2
890 glob td2/*
891 } -cleanup {
892 cleanup
893 } -result {td2/td2}
894 test winFCmd-7.18 {TraverseWinTree: recurse on files: several files and dir} -setup {
895 cleanup
896 } -constraints {win testfile} -body {
897 file mkdir td1
898 createfile td1/tf1
899 createfile td1/tf2
900 file mkdir td1/td2/td3
901 createfile td1/tf3
902 createfile td1/tf4
903 testfile cpdir td1 td2
904 lsort [glob td2/*]
905 } -cleanup {
906 cleanup
907 } -result {td2/td2 td2/tf1 td2/tf2 td2/tf3 td2/tf4}
908 test winFCmd-7.19 {TraverseWinTree: call TraversalCopy: DOTREE_POSTD} -setup {
909 cleanup
910 } -constraints {win testfile testchmod} -body {
911 file mkdir td1
912 createfile td1/tf1 tf1
913 testchmod 0o770 td1/tf1; # Else tf2 will have no ACL after td1 testchmod
914 testchmod 0o400 td1
915 testfile cpdir td1 td2
916 list [file exists td2] [file writable td2]
917 } -cleanup {
918 testchmod 0o660 td1
919 cleanup
920 } -result {1 1}
921 test winFCmd-7.20 {TraverseWinTree: call TraversalDelete: DOTREE_POSTD} -setup {
922 cleanup
923 } -constraints {win testfile} -body {
924 file mkdir td1
925 createfile td1/tf1 tf1
926 testfile rmdir -force td1
927 file exists td1
928 } -result {0}
929 test winFCmd-7.21 {TraverseWinTree: fill errorPtr} -setup {
930 cleanup
931 } -constraints {win testfile} -body {
932 testfile cpdir td1 td2
933 } -returnCodes error -result {td1 ENOENT}
934
935 test winFCmd-8.1 {TraversalCopy: DOTREE_F} -setup {
936 cleanup
937 } -constraints {win testfile} -body {
938 file mkdir td1
939 testfile cpdir td1 td1
940 } -returnCodes error -result {td1 EEXIST}
941 test winFCmd-8.2 {TraversalCopy: DOTREE_PRED} -setup {
942 cleanup
943 } -constraints {win testfile testchmod} -body {
944 file mkdir td1/td2
945 testchmod 0o770 td1/td2; # Else td2 will have no ACL after td1 testchmod
946 testchmod 0o400 td1
947 testfile cpdir td1 td2
948 list [file writable td1] [file writable td1/td2]
949 } -cleanup {
950 testchmod 0o660 td1
951 cleanup
952 } -result {0 1}
953 test winFCmd-8.3 {TraversalCopy: DOTREE_POSTD} -setup {
954 cleanup
955 } -constraints {win testfile} -body {
956 file mkdir td1
957 testfile cpdir td1 td2
958 } -cleanup {
959 cleanup
960 } -result {}
961
962 test winFCmd-9.1 {TraversalDelete: DOTREE_F} -setup {
963 cleanup
964 } -constraints {win testfile} -body {
965 file mkdir td1
966 createfile td1/tf1
967 testfile rmdir -force td1
968 } -result {}
969 test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} -setup {
970 cleanup
971 } -constraints {winVista testfile testchmod notInCIenv} -body {
972 # Parent's FILE_DELETE_CHILD setting permits deletion of subdir
973 # even when subdir DELETE mask is clear. So we need an intermediate
974 # parent td0 with FILE_DELETE_CHILD turned off while allowing R/W.
975 file mkdir td0/td1/td2
976 testchmod 0o770 td0
977 testchmod 0o400 td0/td1
978 testfile rmdir -force td0/td1
979 file exists td1
980 } -cleanup {
981 testchmod 0o770 td0/td1
982 cleanup
983 } -returnCodes error -result {td0/td1 EACCES}
984 test winFCmd-9.4 {TraversalDelete: DOTREE_POSTD} -setup {
985 cleanup
986 } -constraints {win testfile} -body {
987 file mkdir td1/td1/td3/td4/td5
988 testfile rmdir -force td1
989 } -result {}
990
991 test winFCmd-10.1 {AttributesPosixError - get} -constraints {win} -setup {
992 cleanup
993 } -body {
994 file attributes td1 -archive
995 } -returnCodes error -result {could not read "td1": no such file or directory}
996 test winFCmd-10.2 {AttributesPosixError - set} -constraints {win} -setup {
997 cleanup
998 } -body {
999 file attributes td1 -archive 0
1000 } -returnCodes error -result {could not read "td1": no such file or directory}
1001
1002 test winFCmd-11.1 {GetWinFileAttributes} -constraints {win} -setup {
1003 cleanup
1004 } -body {
1005 createfile td1 {}
1006 file attributes td1 -archive
1007 } -cleanup {
1008 cleanup
1009 } -result 1
1010 test winFCmd-11.2 {GetWinFileAttributes} -constraints {win} -setup {
1011 cleanup
1012 } -body {
1013 createfile td1 {}
1014 file attributes td1 -readonly
1015 } -cleanup {
1016 cleanup
1017 } -result 0
1018 test winFCmd-11.3 {GetWinFileAttributes} -constraints {win} -setup {
1019 cleanup
1020 } -body {
1021 createfile td1 {}
1022 file attributes td1 -hidden
1023 } -cleanup {
1024 cleanup
1025 } -result 0
1026 test winFCmd-11.4 {GetWinFileAttributes} -constraints {win} -setup {
1027 cleanup
1028 } -body {
1029 createfile td1 {}
1030 file attributes td1 -system
1031 } -cleanup {
1032 cleanup
1033 } -result 0
1034 test winFCmd-11.5 {GetWinFileAttributes} -constraints {win} -setup {
1035 set old [pwd]
1036 } -body {
1037 # Attr of relative paths that resolve to root was failing don't care about
1038 # answer, just that test runs.
1039 cd c:/
1040 file attr c:
1041 file attr c:.
1042 file attr .
1043 } -cleanup {
1044 cd $old
1045 } -match glob -result *
1046 test winFCmd-11.6 {GetWinFileAttributes} -constraints {win} -body {
1047 file attr c:/ -hidden
1048 } -result {0}
1049
1050 test winFCmd-12.1 {ConvertFileNameFormat} -constraints {win} -setup {
1051 cleanup
1052 } -body {
1053 createfile td1 {}
1054 string tolower [file attributes td1 -longname]
1055 } -cleanup {
1056 cleanup
1057 } -result {td1}
1058 test winFCmd-12.2 {ConvertFileNameFormat} -constraints {win} -setup {
1059 cleanup
1060 } -body {
1061 file mkdir td1
1062 createfile td1/td1 {}
1063 string tolower [file attributes td1/td1 -longname]
1064 } -cleanup {
1065 cleanup
1066 } -result {td1/td1}
1067 test winFCmd-12.3 {ConvertFileNameFormat} -constraints {win} -setup {
1068 cleanup
1069 } -body {
1070 file mkdir td1
1071 file mkdir td1/td2
1072 createfile td1/td3 {}
1073 string tolower [file attributes td1/td2/../td3 -longname]
1074 } -cleanup {
1075 cleanup
1076 } -result {td1/td2/../td3}
1077 test winFCmd-12.4 {ConvertFileNameFormat} -constraints {win} -setup {
1078 cleanup
1079 } -body {
1080 createfile td1 {}
1081 string tolower [file attributes ./td1 -longname]
1082 } -cleanup {
1083 cleanup
1084 } -result {./td1}
1085 test winFCmd-12.5 {ConvertFileNameFormat: absolute path} -body {
1086 list [file attributes / -longname] [file attributes \\ -longname]
1087 } -constraints {win} -result {/ /}
1088 test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive} -setup {
1089 catch {file delete -force -- c:/TclTmpC.1}
1090 } -constraints {win win2000orXP} -body {
1091 createfile c:/TclTmpC.1 {}
1092 string tolower [file attributes c:/TclTmpC.1 -longname]
1093 } -cleanup {
1094 file delete -force -- c:/TclTmpC.1
1095 } -result [string tolower {c:/TclTmpC.1}]
1096 test winFCmd-12.6.2 {ConvertFileNameFormat: absolute path with drive (in temp folder)} -setup {
1097 catch {file delete -force -- $::env(TEMP)/td1}
1098 } -constraints {win} -body {
1099 createfile $::env(TEMP)/td1 {}
1100 string equal [string tolower [file attributes $::env(TEMP)/td1 -longname]] \
1101 [string tolower [file normalize $::env(TEMP)]/td1]
1102 } -cleanup {
1103 file delete -force -- $::env(TEMP)/td1
1104 } -result 1
1105 test winFCmd-12.7 {ConvertFileNameFormat} -body {
1106 string tolower [file attributes //bisque/tcl/ws -longname]
1107 } -constraints {nonPortable win} -result {//bisque/tcl/ws}
1108 test winFCmd-12.8 {ConvertFileNameFormat} -setup {
1109 cleanup
1110 } -constraints {win longFileNames} -body {
1111 createfile td1 {}
1112 string tolower [file attributes td1 -longname]
1113 } -cleanup {
1114 cleanup
1115 } -result {td1}
1116 test winFCmd-12.10 {ConvertFileNameFormat} -setup {
1117 cleanup
1118 } -constraints {longFileNames win} -body {
1119 createfile td1td1td1 {}
1120 file attributes td1td1td1 -shortname
1121 } -cleanup {
1122 cleanup
1123 } -match glob -result *
1124 test winFCmd-12.11 {ConvertFileNameFormat} -setup {
1125 cleanup
1126 } -constraints {longFileNames win} -body {
1127 createfile td1 {}
1128 string tolower [file attributes td1 -shortname]
1129 } -cleanup {
1130 cleanup
1131 } -result {td1}
1132
1133 test winFCmd-13.1 {GetWinFileLongName} -constraints {win} -setup {
1134 cleanup
1135 } -body {
1136 createfile td1 {}
1137 string tolower [file attributes td1 -longname]
1138 } -cleanup {
1139 cleanup
1140 } -result td1
1141
1142 test winFCmd-14.1 {GetWinFileShortName} -constraints {win} -setup {
1143 cleanup
1144 } -body {
1145 createfile td1 {}
1146 string tolower [file attributes td1 -shortname]
1147 } -cleanup {
1148 cleanup
1149 } -result td1
1150
1151 test winFCmd-15.1 {SetWinFileAttributes} -constraints {win} -setup {
1152 cleanup
1153 } -body {
1154 file attributes td1 -archive 0
1155 } -returnCodes error -result {could not read "td1": no such file or directory}
1156 test winFCmd-15.2 {SetWinFileAttributes - archive} -constraints {win} -setup {
1157 cleanup
1158 } -body {
1159 createfile td1 {}
1160 list [file attributes td1 -archive 1] [file attributes td1 -archive]
1161 } -cleanup {
1162 cleanup
1163 } -result {{} 1}
1164 test winFCmd-15.3 {SetWinFileAttributes - archive} -constraints {win} -setup {
1165 cleanup
1166 } -body {
1167 createfile td1 {}
1168 list [file attributes td1 -archive 0] [file attributes td1 -archive]
1169 } -cleanup {
1170 cleanup
1171 } -result {{} 0}
1172 test winFCmd-15.4 {SetWinFileAttributes - hidden} -constraints {win} -setup {
1173 cleanup
1174 } -body {
1175 createfile td1 {}
1176 list [file attributes td1 -hidden 1] [file attributes td1 -hidden] \
1177 [file attributes td1 -hidden 0]
1178 } -cleanup {
1179 cleanup
1180 } -result {{} 1 {}}
1181 test winFCmd-15.5 {SetWinFileAttributes - hidden} -constraints {win} -setup {
1182 cleanup
1183 } -body {
1184 createfile td1 {}
1185 list [file attributes td1 -hidden 0] [file attributes td1 -hidden]
1186 } -cleanup {
1187 cleanup
1188 } -result {{} 0}
1189 test winFCmd-15.6 {SetWinFileAttributes - readonly} -setup {
1190 cleanup
1191 } -constraints {win} -body {
1192 createfile td1 {}
1193 list [file attributes td1 -readonly 1] [file attributes td1 -readonly]
1194 } -cleanup {
1195 cleanup
1196 } -result {{} 1}
1197 test winFCmd-15.7 {SetWinFileAttributes - readonly} -setup {
1198 cleanup
1199 } -constraints {win} -body {
1200 createfile td1 {}
1201 list [file attributes td1 -readonly 0] [file attributes td1 -readonly]
1202 } -cleanup {
1203 cleanup
1204 } -result {{} 0}
1205 test winFCmd-15.8 {SetWinFileAttributes - system} -constraints {win} -setup {
1206 cleanup
1207 } -body {
1208 createfile td1 {}
1209 list [file attributes td1 -system 1] [file attributes td1 -system]
1210 } -cleanup {
1211 cleanup
1212 } -result {{} 1}
1213 test winFCmd-15.9 {SetWinFileAttributes - system} -constraints {win} -setup {
1214 cleanup
1215 } -body {
1216 createfile td1 {}
1217 list [file attributes td1 -system 0] [file attributes td1 -system]
1218 } -cleanup {
1219 cleanup
1220 } -result {{} 0}
1221 test winFCmd-15.10 {SetWinFileAttributes - failing} -setup {
1222 cleanup
1223 } -constraints {win cdrom} -body {
1224 file attributes $cdfile -archive 1
1225 } -returnCodes error -match glob -result *
1226
1227 test winFCmd-16.1 {Windows file normalization} -constraints {win} -body {
1228 list [file normalize c:/] [file normalize C:/]
1229 } -result {C:/ C:/}
1230 test winFCmd-16.2 {Windows file normalization} -constraints {win} -body {
1231 createfile td1... {}
1232 file tail [file normalize td1]
1233 } -cleanup {
1234 file delete td1...
1235 } -result {td1}
1236 set pwd [pwd]
1237 set d [string index $pwd 0]
1238 test winFCmd-16.3 {Windows file normalization} -constraints {win} -body {
1239 file norm ${d}:foo
1240 } -result [file join $pwd foo]
1241 test winFCmd-16.4 {Windows file normalization} -constraints {win} -body {
1242 file norm [string tolower ${d}]:foo
1243 } -result [file join $pwd foo]
1244 test winFCmd-16.5 {Windows file normalization} -constraints {win} -body {
1245 file norm ${d}:foo/bar
1246 } -result [file join $pwd foo/bar]
1247 test winFCmd-16.6 {Windows file normalization} -constraints {win} -body {
1248 file norm ${d}:foo\\bar
1249 } -result [file join $pwd foo/bar]
1250 test winFCmd-16.7 {Windows file normalization} -constraints {win} -body {
1251 file norm /bar
1252 } -result "${d}:/bar"
1253 test winFCmd-16.8 {Windows file normalization} -constraints {win} -body {
1254 file norm ///bar
1255 } -result "${d}:/bar"
1256 test winFCmd-16.9 {Windows file normalization} -constraints {win} -body {
1257 file norm /bar/foo
1258 } -result "${d}:/bar/foo"
1259 if {$d eq "C"} { set dd "D" } else { set dd "C" }
1260 test winFCmd-16.10 {Windows file normalization} -constraints {win} -body {
1261 file norm ${dd}:foo
1262 } -result "${dd}:/foo"
1263 test winFCmd-16.11 {Windows file normalization} -body {
1264 cd ${d}:
1265 cd $cdrom
1266 cd ${d}:
1267 cd $cdrom
1268 # Must not crash
1269 set result "no crash"
1270 } -constraints {win cdrom} -cleanup {
1271 cd $pwd
1272 } -result {no crash}
1273 test winFCmd-16.12 {Windows file normalization - no crash} \
1274 -constraints win -setup {
1275 set oldhome ""
1276 catch {set oldhome $::env(HOME)}
1277 } -body {
1278 set expectedResult [file normalize ${d}:]
1279 set ::env(HOME) ${d}:
1280 cd
1281 # At one point this led to an infinite recursion in Tcl
1282 set result [pwd]; # <- Must not crash
1283 set result "no crash"
1284 } -cleanup {
1285 set ::env(HOME) $oldhome
1286 cd $pwd
1287 } -result {no crash}
1288 test winFCmd-16.13 {Windows file normalization - absolute HOME} -setup {
1289 set oldhome ""
1290 catch {set oldhome $::env(HOME)}
1291 } -constraints win -body {
1292 # Test 'cd' normalization when HOME is absolute
1293 set ::env(HOME) ${d}:/
1294 cd
1295 pwd
1296 } -cleanup {
1297 set ::env(HOME) $oldhome
1298 cd $pwd
1299 } -result [file normalize ${d}:/]
1300 test winFCmd-16.14 {Windows file normalization - relative HOME} -setup {
1301 set oldhome ""
1302 catch {set oldhome $::env(HOME)}
1303 } -constraints win -body {
1304 # Test 'cd' normalization when HOME is relative
1305 set ::env(HOME) ${d}:
1306 cd
1307 pwd
1308 } -cleanup {
1309 set ::env(HOME) $oldhome
1310 cd $pwd
1311 } -result $pwd
1312
1313 test winFCmd-17.1 {Windows bad permissions cd} -constraints win -body {
1314 set d {}
1315 foreach dd {c:/ d:/ e:/} {
1316 eval lappend d [glob -nocomplain \
1317 -types hidden -dir $dd "System Volume Information"]
1318 }
1319 # Old versions of Tcl gave a misleading error that the
1320 # directory in question didn't exist.
1321 if {[llength $d] && [catch {cd [lindex $d 0]} err]} {
1322 regsub ".*: " $err "" err
1323 set err
1324 } else {
1325 set err "permission denied"
1326 }
1327 } -cleanup {
1328 cd $pwd
1329 } -result "permission denied"
1330
1331 cd $pwd
1332 unset d dd pwd
1333
1334 test winFCmd-18.1 {Windows reserved path names} -constraints win -body {
1335 file pathtype com1
1336 } -result "absolute"
1337 test winFCmd-18.1.2 {Windows reserved path names} -constraints win -body {
1338 file pathtype com4
1339 } -result "absolute"
1340 test winFCmd-18.1.3 {Windows reserved path names} -constraints win -body {
1341 file pathtype com9
1342 } -result "absolute"
1343 test winFCmd-18.1.4 {Windows reserved path names} -constraints win -body {
1344 file pathtype lpt3
1345 } -result "absolute"
1346 test winFCmd-18.1.5 {Windows reserved path names} -constraints win -body {
1347 file pathtype lpt9
1348 } -result "absolute"
1349 test winFCmd-18.1.6 {Windows reserved path names} -constraints win -body {
1350 file pathtype nul
1351 } -result "absolute"
1352 test winFCmd-18.1.7 {Windows reserved path names} -constraints win -body {
1353 file pathtype null
1354 } -result "relative"
1355 test winFCmd-18.2 {Windows reserved path names} -constraints win -body {
1356 file pathtype com1:
1357 } -result "absolute"
1358 test winFCmd-18.3 {Windows reserved path names} -constraints win -body {
1359 file pathtype COM1
1360 } -result "absolute"
1361 test winFCmd-18.4 {Windows reserved path names} -constraints win -body {
1362 file pathtype CoM1:
1363 } -result "absolute"
1364 test winFCmd-18.5 {Windows reserved path names} -constraints win -body {
1365 file normalize com1:
1366 } -result COM1
1367 test winFCmd-18.6 {Windows reserved path names} -constraints win -body {
1368 file normalize COM1:
1369 } -result COM1
1370 test winFCmd-18.7 {Windows reserved path names} -constraints win -body {
1371 file normalize cOm1
1372 } -result COM1
1373 test winFCmd-18.8 {Windows reserved path names} -constraints win -body {
1374 file normalize cOm1:
1375 } -result COM1
1376
1377 test winFCmd-19.1 {Windows extended path names} -constraints nt -body {
1378 file normalize //?/c:/windows/win.ini
1379 } -result //?/c:/windows/win.ini
1380 test winFCmd-19.2 {Windows extended path names} -constraints nt -body {
1381 file normalize //?/c:/windows/../windows/win.ini
1382 } -result //?/c:/windows/win.ini
1383 test winFCmd-19.3 {Windows extended path names} -constraints nt -setup {
1384 set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp]
1385 set tmpfile [file normalize $tmpfile]
1386 } -body {
1387 list [catch {
1388 set f [open $tmpfile [list WRONLY CREAT]]
1389 close $f
1390 } res] $res
1391 } -cleanup {
1392 catch {file delete $tmpfile}
1393 } -result [list 0 {}]
1394 test winFCmd-19.4 {Windows extended path names} -constraints {win nt} -setup {
1395 set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp]
1396 set tmpfile //?/[file normalize $tmpfile]
1397 } -body {
1398 list [catch {
1399 set f [open $tmpfile [list WRONLY CREAT]]
1400 close $f
1401 } res] $res
1402 } -cleanup {
1403 catch {file delete $tmpfile}
1404 } -result [list 0 {}]
1405 test winFCmd-19.5 {Windows extended path names} -constraints nt -setup {
1406 set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp]
1407 set tmpfile [file normalize $tmpfile]
1408 } -body {
1409 list [catch {
1410 set f [open $tmpfile [list WRONLY CREAT]]
1411 close $f
1412 } res] $res
1413 } -cleanup {
1414 catch {file delete $tmpfile}
1415 } -result [list 0 {}]
1416 test winFCmd-19.6 {Windows extended path names} -constraints {win nt} -setup {
1417 set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp]
1418 set tmpfile //?/[file normalize $tmpfile]
1419 } -body {
1420 list [catch {
1421 set f [open $tmpfile [list WRONLY CREAT]]
1422 close $f
1423 } res] $res
1424 } -cleanup {
1425 catch {file delete $tmpfile}
1426 } -result [list 0 {}]
1427 test winFCmd-19.7 {Windows extended path names} -constraints {win nt} -setup {
1428 set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "]
1429 set tmpfile [file normalize $tmpfile]
1430 } -body {
1431 list [catch {
1432 set f [open $tmpfile [list WRONLY CREAT]]
1433 close $f
1434 } res] $res [glob -directory $::env(TEMP) -tails tcl[pid].*]
1435 } -cleanup {
1436 catch {file delete $tmpfile}
1437 } -result [list 0 {} [list tcl[pid].tmp]]
1438 test winFCmd-19.8 {Windows extended path names} -constraints {win nt} -setup {
1439 set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "]
1440 set tmpfile //?/[file normalize $tmpfile]
1441 } -body {
1442 list [catch {
1443 set f [open $tmpfile [list WRONLY CREAT]]
1444 close $f
1445 } res] $res [glob -directory $::env(TEMP) -tails tcl[pid].*]
1446 } -cleanup {
1447 catch {file delete $tmpfile}
1448 } -result [list 0 {} [list "tcl[pid].tmp "]]
1449
1450 test winFCmd-19.9 {Windows devices path names} -constraints {win nt} -body {
1451 file normalize //./com1
1452 } -result //./com1
1453
1454
1455 # This block of code used to occur after the "return" call, so I'm
1456 # commenting it out and assuming that this code is still under construction.
1457 #foreach source {tef ted tnf tnd "" nul com1} {
1458 # foreach chmodsrc {000 755} {
1459 # foreach dest "tfn tfe tdn tdempty tdfull td1/td2 $p $p/td1 {} nul" {
1460 # foreach chmoddst {000 755} {
1461 # puts hi
1462 # cleanup
1463 # file delete -force ted tef
1464 # file mkdir ted
1465 # createfile tef
1466 # createfile tfe
1467 # file mkdir tdempty
1468 # file mkdir tdfull/td1/td2
1469 #
1470 # catch {testchmod $chmodsrc $source}
1471 # catch {testchmod $chmoddst $dest}
1472 #
1473 # if [catch {file rename $source $dest} msg] {
1474 # puts "file rename $source ($chmodsrc) $dest ($chmoddst)"
1475 # puts $msg
1476 # }
1477 # }
1478 # }
1479 # }
1480 #}
1481
1482 cleanup
1483 ::tcltest::cleanupTests
1484 return
1485
1486 # Local Variables:
1487 # mode: tcl
1488 # End: