OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [tests/] [winFCmd.test] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# 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
#
9
# See the file "license.terms" for information on usage and redistribution
10
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
#
12
# RCS: @(#) $Id: winFCmd.test,v 1.1.1.1 2002-01-16 10:25:36 markom Exp $
13
#
14
 
15
if {[string compare test [info procs test]] == 1} then {source defs}
16
 
17
if {$tcl_platform(platform) != "windows"} {
18
    return
19
}
20
 
21
proc createfile {file {string a}} {
22
    set f [open $file w]
23
    puts -nonewline $f $string
24
    close $f
25
    return $string
26
}
27
 
28
proc contents {file} {
29
    set f [open $file r]
30
    set r [read $f]
31
    close $f
32
    set r
33
}
34
 
35
proc cleanup {args} {
36
    foreach p ". $args" {
37
        set x ""
38
        catch {
39
            set x [glob [file join $p tf*] [file join $p td*]]
40
        }
41
        if {$x != ""} {
42
            catch {eval file delete -force -- $x}
43
        }
44
    }
45
}
46
 
47
set testConfig(cdrom) 0
48
set testConfig(exdev) 0
49
set testConfig(UNCPath} 0
50
 
51
# find a CD-ROM so we can test read-only filesystems.
52
 
53
set cdrom {}
54
set nodrive x:
55
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} {
56
    set name ${p}:/dummy~~.fil
57
    if [catch {set fd [open $name w]}] {
58
        set err [lindex $errorCode 1]
59
        if {$cdrom == "" && $err == "EACCES"} {
60
            set cdrom ${p}:
61
        }
62
        if {$err == "ENOENT"} {
63
            set nodrive ${p}:
64
        }
65
    } else {
66
        close $fd
67
        file delete $name
68
    }
69
}
70
 
71
proc findfile {dir} {
72
    foreach p [glob $dir/*] {
73
        if {[file type $p] == "file"} {
74
            return $p
75
        }
76
    }
77
    foreach p [glob $dir/*] {
78
        if {[file type $p] == "directory"} {
79
            set f [findfile $p]
80
            if {$f != ""} {
81
                return $f
82
            }
83
        }
84
    }
85
    return ""
86
}
87
 
88
if {$cdrom == ""} {
89
    puts "Couldn't find a CD-ROM.  Skipping tests that access CD-ROM."
90
    puts "If you have a CD-ROM, insert a data disk and rerun tests."
91
} else {
92
    set testConfig(cdrom) 1
93
    set cdfile [findfile $cdrom]
94
}
95
 
96
if {[file exists c:/] && [file exists d:/]} {
97
    catch {file delete d:/tf1}
98
    if {[catch {close [open d:/tf1 w]}] == 0} {
99
        file delete d:/tf1
100
        set testConfig(exdev) 1
101
    }
102
}
103
 
104
if {[file exists //bisque/icepick]} {
105
    set testConfig(UNCPath) 1
106
}
107
 
108
file delete -force -- td1
109
set foo [catch {open td1 w} testfile]
110
if {$foo} {
111
    set testConfig(longFileNames) 0
112
} else {
113
    close $testfile
114
    set testConfig(longFileNames) 1
115
    file delete -force -- td1
116
}
117
 
118
# A really long file name
119
# length of longname is 1216 chars, which should be greater than any static
120
# buffer or allowable filename.
121
 
122
set longname "abcdefghihjllmnopqrstuvwxyz01234567890"
123
append longname $longname
124
append longname $longname
125
append longname $longname
126
append longname $longname
127
append longname $longname
128
 
129
# Uses the "testfile" command instead of the "file" command.  The "file"
130
# command provides several layers of sanity checks on the arguments and
131
# it can be difficult to actually forward "insane" arguments to the
132
# low-level posix emulation layer.
133
 
134
test winFCmd-1.1 {TclpRenameFile: errno: EACCES} {cdrom} {
135
    list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg
136
} {1 EACCES}
137
test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} {
138
    cleanup
139
    file mkdir td1/td2/td3
140
    file mkdir td2
141
    list [catch {testfile mv td2 td1/td2} msg] $msg
142
} {1 EEXIST}
143
test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} {!$testConfig(win32s) || ("[lindex [file split [pwd]] end]" == "C:/")} {
144
    # Don't run this test under Win32s on a drive mounted from an NT
145
    # machine; it causes the NT machine to die.
146
 
147
    cleanup
148
    list [catch {testfile mv / td1} msg] $msg
149
} {1 EINVAL}
150
test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} {
151
    cleanup
152
    file mkdir td1
153
    list [catch {testfile mv td1 td1/td2} msg] $msg
154
} {1 EINVAL}
155
test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} {
156
    cleanup
157
    file mkdir td1
158
    createfile tf1
159
    list [catch {testfile mv tf1 td1} msg] $msg
160
} {1 EISDIR}
161
test winFCmd-1.6 {TclpRenameFile: errno: ENOENT} {
162
    cleanup
163
    list [catch {testfile mv tf1 tf2} msg] $msg
164
} {1 ENOENT}
165
test winFCmd-1.7 {TclpRenameFile: errno: ENOENT} {
166
    cleanup
167
    list [catch {testfile mv "" tf2} msg] $msg
168
} {1 ENOENT}
169
test winFCmd-1.8 {TclpRenameFile: errno: ENOENT} {
170
    cleanup
171
    createfile tf1
172
    list [catch {testfile mv tf1 ""} msg] $msg
173
} {1 ENOENT}
174
test winFCmd-1.9 {TclpRenameFile: errno: ENOTDIR} {
175
    cleanup
176
    file mkdir td1
177
    createfile tf1
178
    list [catch {testfile mv td1 tf1} msg] $msg
179
} {1 ENOTDIR}
180
test winFCmd-1.10 {TclpRenameFile: errno: EXDEV} {exdev} {
181
    file delete -force d:/tf1
182
    file mkdir c:/tf1
183
    set msg [list [catch {testfile mv c:/tf1 d:/tf1} msg] $msg]
184
    file delete -force c:/tf1
185
    set msg
186
} {1 EXDEV}
187
test winFCmd-1.11 {TclpRenameFile: errno: EACCES} {
188
    cleanup
189
    set fd [open tf1 w]
190
    set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
191
    close $fd
192
    set msg
193
} {1 EACCES}
194
test winFCmd-1.12 {TclpRenameFile: errno: EACCES} {
195
    cleanup
196
    createfile tf1
197
    set fd [open tf2 w]
198
    set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
199
    close $fd
200
    set msg
201
} {1 EACCES}
202
test winFCmd-1.13 {TclpRenameFile: errno: EACCES} {
203
    cleanup
204
    list [catch {testfile mv nul tf1} msg] $msg
205
} {1 EACCES}
206
test winFCmd-1.14 {TclpRenameFile: errno: EACCES} {95} {
207
    cleanup
208
    createfile tf1
209
    list [catch {testfile mv tf1 nul} msg] $msg
210
} {1 EACCES}
211
test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} {nt} {
212
    cleanup
213
    createfile tf1
214
    list [catch {testfile mv tf1 nul} msg] $msg
215
} {1 EEXIST}
216
test winFCmd-1.16 {TclpRenameFile: MoveFile() != FALSE} {
217
    cleanup
218
    createfile tf1 tf1
219
    testfile mv tf1 tf2
220
    list [file exists tf1] [contents tf2]
221
} {0 tf1}
222
test winFCmd-1.17 {TclpRenameFile: MoveFile() == FALSE} {
223
    cleanup
224
    list [catch {testfile mv tf1 tf2} msg] $msg
225
} {1 ENOENT}
226
test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} {
227
    cleanup
228
    list [catch {testfile mv tf1 tf2} msg] $msg
229
} {1 ENOENT}
230
test winFCmd-1.19 {TclpRenameFile: errno == EACCES} {
231
    cleanup
232
    list [catch {testfile mv nul tf1} msg] $msg
233
} {1 EACCES}
234
# under 95, this would actually succed and move the current dir out from
235
# under yourself.
236
test winFCmd-1.20 {TclpRenameFile: src is dir} {!95} {
237
    cleanup
238
    file delete /tf1
239
    list [catch {testfile mv [pwd] /tf1} msg] $msg
240
} {1 EACCES}
241
test winFCmd-1.21 {TclpRenameFile: obscenely long src} {!win32s} {
242
    # Really long file names cause all the file system calls to lock up,
243
    # endlessly throwing an access violation and retrying the operation.
244
 
245
    list [catch {testfile mv $longname tf1} msg] $msg
246
} {1 ENAMETOOLONG}
247
test winFCmd-1.22 {TclpRenameFile: obscenely long dst} {nt} {
248
    # return ENOENT if name is too long!
249
    cleanup
250
    createfile tf1
251
    list [catch {testfile mv tf1 $longname} msg] $msg
252
} {1 ENOENT}
253
test winFCmd-1.23 {TclpRenameFile: obscenely long dst} {95} {
254
    cleanup
255
    createfile tf1
256
    list [catch {testfile mv tf1 $longname} msg] $msg
257
} {1 ENAMETOOLONG}
258
test winFCmd-1.24 {TclpRenameFile: move dir into self} {
259
    cleanup
260
    file mkdir td1
261
    list [catch {testfile mv [pwd]/td1 td1/td2} msg] $msg
262
} {1 EINVAL}
263
test winFCmd-1.25 {TclpRenameFile: move a root dir} {!$testConfig(win32s) || ("[lindex [file split [pwd]] end]" == "C:/")} {
264
    # Don't run this test under Win32s on a drive mounted from an NT
265
    # machine; it causes the NT machine to die.
266
 
267
    cleanup
268
    list [catch {testfile mv / c:/} msg] $msg
269
} {1 EINVAL}
270
test winFCmd-1.26 {TclpRenameFile: cross file systems} {cdrom} {
271
    cleanup
272
    file mkdir td1
273
    list [catch {testfile mv td1 $cdrom/td1} msg] $msg
274
} {1 EXDEV}
275
test winFCmd-1.27 {TclpRenameFile: readonly fs} {cdrom} {
276
    cleanup
277
    list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg
278
} {1 EACCES}
279
test winFCmd-1.28 {TclpRenameFile: open file} {
280
    cleanup
281
    set fd [open tf1 w]
282
    set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
283
    close $fd
284
    set msg
285
} {1 EACCES}
286
test winFCmd-1.29 {TclpRenameFile: errno == EEXIST} {
287
    cleanup
288
    createfile tf1
289
    createfile tf2
290
    testfile mv tf1 tf2
291
    list [file exist tf1] [file exist tf2]
292
} {0 1}
293
test winFCmd-1.30 {TclpRenameFile: src is dir} {
294
    cleanup
295
    file mkdir td1
296
    createfile tf1
297
    list [catch {testfile mv td1 tf1} msg] $msg
298
} {1 ENOTDIR}
299
test winFCmd-1.31 {TclpRenameFile: dst is dir} {
300
    cleanup
301
    file mkdir td1
302
    file mkdir td2/td2
303
    list [catch {testfile mv td1 td2} msg] $msg
304
} {1 EEXIST}
305
test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory fails} {
306
    cleanup
307
    file mkdir td1
308
    file mkdir td2/td2
309
    list [catch {testfile mv td1 td2} msg] $msg
310
} {1 EEXIST}
311
test winFCmd-1.33 {TclpRenameFile: TclpRemoveDirectory succeeds} {
312
    cleanup
313
    file mkdir td1/td2
314
    file mkdir td2
315
    testfile mv td1 td2
316
    list [file exist td1] [file exist td2] [file exist td2/td2]
317
} {0 1 1}
318
test winFCmd-1.34 {TclpRenameFile: After removing dst dir, MoveFile fails} {exdev} {
319
    file mkdir d:/td1
320
    testchmod 000 d:/td1
321
    set msg [list [catch {testfile mv c:/windows d:/td1} msg] $msg]
322
    set msg "$msg [file writable d:/td1]"
323
    file delete d:/td1
324
    set msg
325
} {1 EXDEV 0}
326
test winFCmd-1.35 {TclpRenameFile: src is dir, dst is not} {
327
    file mkdir td1
328
    createfile tf1
329
    list [catch {testfile mv td1 tf1} msg] $msg
330
} {1 ENOTDIR}
331
test winFCmd-1.36 {TclpRenameFile: src is not dir, dst is} {
332
    file mkdir td1
333
    createfile tf1
334
    list [catch {testfile mv tf1 td1} msg] $msg
335
} {1 EISDIR}
336
test winFCmd-1.37 {TclpRenameFile: src and dst not dir} {
337
    createfile tf1 tf1
338
    createfile tf2 tf2
339
    testfile mv tf1 tf2
340
    contents tf2
341
} {tf1}
342
test winFCmd-1.38 {TclpRenameFile: need to restore temp file} {
343
    # Can't figure out how to cause this.
344
    # Need a file that can't be copied.
345
} {}
346
 
347
test winFCmd-2.1 {TclpCopyFile: errno: EACCES} {cdrom} {
348
    cleanup
349
    list [catch {testfile cp $cdfile $cdrom/dummy~~.fil} msg] $msg
350
} {1 EACCES}
351
test winFCmd-2.2 {TclpCopyFile: errno: EISDIR} {
352
    cleanup
353
    file mkdir td1
354
    list [catch {testfile cp td1 tf1} msg] $msg
355
} {1 EISDIR}
356
test winFCmd-2.3 {TclpCopyFile: errno: EISDIR} {
357
    cleanup
358
    createfile tf1
359
    file mkdir td1
360
    list [catch {testfile cp tf1 td1} msg] $msg
361
} {1 EISDIR}
362
test winFCmd-2.4 {TclpCopyFile: errno: ENOENT} {
363
    cleanup
364
    list [catch {testfile cp tf1 tf2} msg] $msg
365
} {1 ENOENT}
366
test winFCmd-2.5 {TclpCopyFile: errno: ENOENT} {
367
    cleanup
368
    list [catch {testfile cp "" tf2} msg] $msg
369
} {1 ENOENT}
370
test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} {
371
    cleanup
372
    createfile tf1
373
    list [catch {testfile cp tf1 ""} msg] $msg
374
} {1 ENOENT}
375
test winFCmd-2.7 {TclpCopyFile: errno: EACCES} {!nt} {
376
    cleanup
377
    createfile tf1
378
    set fd [open tf2 w]
379
    set msg [list [catch {testfile cp tf1 tf2} msg] $msg]
380
    close $fd
381
    set msg
382
} {1 EACCES}
383
test winFCmd-2.8 {TclpCopyFile: errno: EACCES} {nt} {
384
    cleanup
385
    list [catch {testfile cp nul tf1} msg] $msg
386
} {1 EACCES}
387
test winFCmd-2.9 {TclpCopyFile: errno: ENOENT} {95} {
388
    cleanup
389
    list [catch {testfile cp nul tf1} msg] $msg
390
} {1 ENOENT}
391
test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} {
392
    cleanup
393
    createfile tf1 tf1
394
    testfile cp tf1 tf2
395
    list [contents tf1] [contents tf2]
396
} {tf1 tf1}
397
test winFCmd-2.11 {TclpCopyFile: CopyFile succeeds} {
398
    cleanup
399
    createfile tf1 tf1
400
    createfile tf2 tf2
401
    testfile cp tf1 tf2
402
    list [contents tf1] [contents tf2]
403
} {tf1 tf1}
404
test winFCmd-2.12 {TclpCopyFile: CopyFile succeeds} {
405
    cleanup
406
    createfile tf1 tf1
407
    testchmod 000 tf1
408
    testfile cp tf1 tf2
409
    list [contents tf2] [file writable tf2]
410
} {tf1 0}
411
test winFCmd-2.13 {TclpCopyFile: CopyFile fails} {
412
    cleanup
413
    createfile tf1
414
    file mkdir td1
415
    list [catch {testfile cp tf1 td1} msg] $msg
416
} {1 EISDIR}
417
test winFCmd-2.14 {TclpCopyFile: errno == EACCES} {
418
    cleanup
419
    file mkdir td1
420
    list [catch {testfile cp td1 tf1} msg] $msg
421
} {1 EISDIR}
422
test winFCmd-2.15 {TclpCopyFile: src is directory} {
423
    cleanup
424
    file mkdir td1
425
    list [catch {testfile cp td1 tf1} msg] $msg
426
} {1 EISDIR}
427
test winFCmd-2.16 {TclpCopyFile: dst is directory} {
428
    cleanup
429
    createfile tf1
430
    file mkdir td1
431
    list [catch {testfile cp tf1 td1} msg] $msg
432
} {1 EISDIR}
433
test winFCmd-2.17 {TclpCopyFile: dst is readonly} {
434
    cleanup
435
    createfile tf1 tf1
436
    createfile tf2 tf2
437
    testchmod 000 tf2
438
    testfile cp tf1 tf2
439
    list [file writable tf2] [contents tf2]
440
} {1 tf1}
441
test winFCmd-2.18 {TclpCopyFile: still can't copy onto dst} {95} {
442
    cleanup
443
    createfile tf1
444
    createfile tf2
445
    testchmod 000 tf2
446
    set fd [open tf2]
447
    set msg [list [catch {testfile cp tf1 tf2} msg] $msg]
448
    close $fd
449
    set msg "$msg [file writable tf2]"
450
} {1 EACCES 0}
451
 
452
test winFCmd-3.1 {TclpDeleteFile: errno: EACCES} {cdrom} {
453
    list [catch {testfile rm $cdfile $cdrom/dummy~~.fil} msg] $msg
454
} {1 EACCES}
455
test winFCmd-3.2 {TclpDeleteFile: errno: EISDIR} {
456
    cleanup
457
    file mkdir td1
458
    list [catch {testfile rm td1} msg] $msg
459
} {1 EISDIR}
460
test winFCmd-3.3 {TclpDeleteFile: errno: ENOENT} {
461
    cleanup
462
    list [catch {testfile rm tf1} msg] $msg
463
} {1 ENOENT}
464
test winFCmd-3.4 {TclpDeleteFile: errno: ENOENT} {
465
    cleanup
466
    list [catch {testfile rm ""} msg] $msg
467
} {1 ENOENT}
468
test winFCmd-3.5 {TclpDeleteFile: errno: EACCES} {
469
    cleanup
470
    set fd [open tf1 w]
471
    set msg [list [catch {testfile rm tf1} msg] $msg]
472
    close $fd
473
    set msg
474
} {1 EACCES}
475
test winFCmd-3.6 {TclpDeleteFile: errno: EACCES} {
476
    cleanup
477
    list [catch {testfile rm nul} msg] $msg
478
} {1 EACCES}
479
test winFCmd-3.7 {TclpDeleteFile: DeleteFile succeeds} {
480
    cleanup
481
    createfile tf1
482
    testfile rm tf1
483
    file exist tf1
484
} {0}
485
test winFCmd-3.8 {TclpDeleteFile: DeleteFile fails} {
486
    cleanup
487
    file mkdir td1
488
    list [catch {testfile rm td1} msg] $msg
489
} {1 EISDIR}
490
test winFCmd-3.9 {TclpDeleteFile: errno == EACCES} {
491
    cleanup
492
    set fd [open tf1 w]
493
    set msg [list [catch {testfile rm tf1} msg] $msg]
494
    close $fd
495
    set msg
496
} {1 EACCES}
497
test winFCmd-3.10 {TclpDeleteFile: path is readonly} {
498
    cleanup
499
    createfile tf1
500
    testchmod 000 tf1
501
    testfile rm tf1
502
    file exists tf1
503
} {0}
504
test winFCmd-3.11 {TclpDeleteFile: still can't remove path} {
505
    cleanup
506
    set fd [open tf1 w]
507
    testchmod 000 tf1
508
    set msg [list [catch {testfile rm tf1} msg] $msg]
509
    close $fd
510
    set msg
511
} {1 EACCES}
512
 
513
test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} {cdrom nt} {
514
    list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg
515
} {1 EACCES}
516
test winFCmd-4.2 {TclpCreateDirectory: errno: EACCES} {cdrom 95} {
517
    list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg
518
} {1 ENOSPC}
519
test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} {
520
    cleanup
521
    file mkdir td1
522
    list [catch {testfile mkdir td1} msg] $msg
523
} {1 EEXIST}
524
test winFCmd-4.4 {TclpCreateDirectory: errno: ENOENT} {
525
    cleanup
526
    list [catch {testfile mkdir td1/td2} msg] $msg
527
} {1 ENOENT}
528
test winFCmd-4.5 {TclpCreateDirectory: CreateDirectory succeeds} {
529
    cleanup
530
    testfile mkdir td1
531
    file type td1
532
} {directory}
533
 
534
test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} {
535
    cleanup
536
    file mkdir td1
537
    testfile cpdir td1 td2
538
    list [file type td1] [file type td2]
539
} {directory directory}
540
 
541
test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} {
542
    cleanup
543
    file mkdir td1
544
    testchmod 000 td1
545
    testfile rmdir td1
546
    file exist td1
547
} {0}
548
test winFCmd-6.2 {TclpRemoveDirectory: errno: EEXIST} {
549
    cleanup
550
    file mkdir td1/td2
551
    list [catch {testfile rmdir td1} msg] $msg
552
} {1 {td1 EEXIST}}
553
test winFCmd-6.3 {TclpRemoveDirectory: errno: EACCES} {
554
    # can't test this w/o removing everything on your hard disk first!
555
    # testfile rmdir /
556
} {}
557
test winFCmd-6.4 {TclpRemoveDirectory: errno: ENOENT} {
558
    cleanup
559
    list [catch {testfile rmdir td1} msg] $msg
560
} {1 {td1 ENOENT}}
561
test winFCmd-6.5 {TclpRemoveDirectory: errno: ENOENT} {
562
    cleanup
563
    list [catch {testfile rmdir ""} msg] $msg
564
} {1 ENOENT}
565
test winFCmd-6.6 {TclpRemoveDirectory: errno: ENOTDIR} {
566
    cleanup
567
    createfile tf1
568
    list [catch {testfile rmdir tf1} msg] $msg
569
} {1 {tf1 ENOTDIR}}
570
test winFCmd-6.7 {TclpRemoveDirectory: RemoveDirectory succeeds} {
571
    cleanup
572
    file mkdir td1
573
    testfile rmdir td1
574
    file exists td1
575
} {0}
576
test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} {
577
    cleanup
578
    createfile tf1
579
    list [catch {testfile rmdir tf1} msg] $msg
580
} {1 {tf1 ENOTDIR}}
581
test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} {
582
    cleanup
583
    file mkdir td1
584
    testchmod 000 td1
585
    testfile rmdir td1
586
    file exists td1
587
} {0}
588
test winFCmd-6.10 {TclpRemoveDirectory: attr == -1} {!nt} {
589
    cleanup
590
    list [catch {testfile rmdir nul} msg] $msg
591
} {1 {nul EACCES}}
592
test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} {nt} {
593
    cleanup
594
    list [catch {testfile rmdir /} msg] $msg
595
} {1 {\ EACCES}}
596
test winFCmd-6.12 {TclpRemoveDirectory: errno == EACCES} {!nt} {
597
    cleanup
598
    createfile tf1
599
    list [catch {testfile rmdir tf1} msg] $msg
600
} {1 {tf1 ENOTDIR}}
601
test winFCmd-6.13 {TclpRemoveDirectory: write-protected} {
602
    cleanup
603
    file mkdir td1
604
    testchmod 000 td1
605
    testfile rmdir td1
606
    file exists td1
607
} {0}
608
test winFCmd-6.14 {TclpRemoveDirectory: check if empty dir} {!nt} {
609
    cleanup
610
    file mkdir td1/td2
611
    list [catch {testfile rmdir td1} msg] $msg
612
} {1 {td1 EEXIST}}
613
test winFCmd-6.15 {TclpRemoveDirectory: !recursive} {
614
    cleanup
615
    file mkdir td1/td2
616
    list [catch {testfile rmdir td1} msg] $msg
617
} {1 {td1 EEXIST}}
618
test winFCmd-6.16 {TclpRemoveDirectory: recursive, but errno != EEXIST} {
619
    cleanup
620
    createfile tf1
621
    list [catch {testfile rmdir -force tf1} msg] $msg
622
} {1 {tf1 ENOTDIR}}
623
test winFCmd-6.17 {TclpRemoveDirectory: calls TraverseWinTree} {
624
    cleanup
625
    file mkdir td1/td2
626
    testfile rmdir -force td1
627
    file exists td1
628
} {0}
629
 
630
test winFCmd-7.1 {TraverseWinTree: targetPtr == NULL} {
631
    cleanup
632
    file mkdir td1/td2/td3
633
    testfile rmdir -force td1
634
    file exists td1
635
} {0}
636
test winFCmd-7.2 {TraverseWinTree: targetPtr != NULL} {
637
    cleanup
638
    file mkdir td1/td2/td3
639
    testfile cpdir td1 td2
640
    list [file exists td1] [file exists td2]
641
} {1 1}
642
test winFCmd-7.3 {TraverseWinTree: sourceAttr == -1} {
643
    cleanup
644
    list [catch {testfile cpdir td1 td2} msg] $msg
645
} {1 {td1 ENOENT}}
646
test winFCmd-7.4 {TraverseWinTree: source isn't directory} {
647
    cleanup
648
    file mkdir td1
649
    createfile td1/tf1 tf1
650
    testfile cpdir td1 td2
651
    contents td2/tf1
652
} {tf1}
653
test winFCmd-7.5 {TraverseWinTree: call TraversalCopy: DOTREE_F} {
654
    cleanup
655
    file mkdir td1
656
    createfile td1/tf1 tf1
657
    testfile cpdir td1 td2
658
    contents td2/tf1
659
} {tf1}
660
test winFCmd-7.6 {TraverseWinTree: call TraversalDelete: DOTREE_F} {
661
    cleanup
662
    file mkdir td1
663
    createfile td1/tf1 tf1
664
    testfile rmdir -force td1
665
    file exists td1
666
} {0}
667
test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} {
668
    cleanup
669
    file mkdir td1
670
    createfile td1/tf1 tf1
671
    testfile cpdir td1 td2
672
    contents td2/tf1
673
} {tf1}
674
test winFCmd-7.8 {TraverseWinTree: append \ to source if necessary} {!nt && cdrom} {
675
    list [catch {testfile rmdir $cdrom/} msg] $msg
676
} "1 {$cdrom\\ EEXIST}"
677
test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} {nt cdrom} {
678
    list [catch {testfile rmdir $cdrom/} msg] $msg
679
} "1 {$cdrom\\ EACCES}"
680
test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} {
681
    # can't make it happen
682
} {}
683
test winFCmd-7.11 {TraverseWinTree: call TraversalCopy: DOTREE_PRED} {
684
    cleanup
685
    file mkdir td1
686
    testchmod 000 td1
687
    createfile td1/tf1 tf1
688
    testfile cpdir td1 td2
689
    list [file exists td2] [file writable td2]
690
} {1 0}
691
test winFCmd-7.12 {TraverseWinTree: call TraversalDelete: DOTREE_PRED} {
692
    cleanup
693
    file mkdir td1
694
    createfile td1/tf1 tf1
695
    testfile rmdir -force td1
696
    file exists td1
697
} {0}
698
test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} {
699
    cleanup
700
    file mkdir td1
701
    createfile td1/tf1 tf1
702
    testfile cpdir td1 td2
703
    contents td2/tf1
704
} {tf1}
705
test winFCmd-7.14 {TraverseWinTree: append \ to target if necessary} {!nt} {
706
    cleanup
707
    file mkdir td1
708
    list [catch {testfile cpdir td1 /} msg] $msg
709
} {1 {\ EEXIST}}
710
test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} {nt} {
711
    cleanup
712
    file mkdir td1
713
    list [catch {testfile cpdir td1 /} msg] $msg
714
} {1 {\ EACCES}}
715
test winFCmd-7.16 {TraverseWinTree: recurse on files: no files} {
716
    cleanup
717
    file mkdir td1
718
    testfile cpdir td1 td2
719
} {}
720
test winFCmd-7.17 {TraverseWinTree: recurse on files: one file} {
721
    cleanup
722
    file mkdir td1
723
    createfile td1/td2
724
    testfile cpdir td1 td2
725
    glob td2/*
726
} {td2/td2}
727
test winFCmd-7.18 {TraverseWinTree: recurse on files: several files and dir} {
728
    cleanup
729
    file mkdir td1
730
    createfile td1/tf1
731
    createfile td1/tf2
732
    file mkdir td1/td2/td3
733
    createfile td1/tf3
734
    createfile td1/tf4
735
    testfile cpdir td1 td2
736
    glob td2/*
737
} {td2/tf1 td2/tf2 td2/td2 td2/tf3 td2/tf4}
738
test winFCmd-7.19 {TraverseWinTree: call TraversalCopy: DOTREE_POSTD} {
739
    cleanup
740
    file mkdir td1
741
    testchmod 000 td1
742
    createfile td1/tf1 tf1
743
    testfile cpdir td1 td2
744
    list [file exists td2] [file writable td2]
745
} {1 0}
746
test winFCmd-7.20 {TraverseWinTree: call TraversalDelete: DOTREE_POSTD} {
747
    cleanup
748
    file mkdir td1
749
    createfile td1/tf1 tf1
750
    testfile rmdir -force td1
751
    file exists td1
752
} {0}
753
test winFCmd-7.21 {TraverseWinTree: fill errorPtr} {
754
    cleanup
755
    list [catch {testfile cpdir td1 td2} msg] $msg
756
} {1 {td1 ENOENT}}
757
 
758
test winFCmd-8.1 {TraversalCopy: DOTREE_F} {
759
    cleanup
760
    file mkdir td1
761
    list [catch {testfile cpdir td1 td1} msg] $msg
762
} {1 {td1 EEXIST}}
763
test winFCmd-8.2 {TraversalCopy: DOTREE_PRED} {
764
    cleanup
765
    file mkdir td1/td2
766
    testchmod 000 td1
767
    testfile cpdir td1 td2
768
    list [file writable td1] [file writable td1/td2]
769
} {0 1}
770
test winFCmd-8.3 {TraversalCopy: DOTREE_POSTD} {
771
    cleanup
772
    file mkdir td1
773
    testfile cpdir td1 td2
774
} {}
775
 
776
test winFCmd-9.1 {TraversalDelete: DOTREE_F} {
777
    cleanup
778
    file mkdir td1
779
    createfile td1/tf1
780
    testfile rmdir -force td1
781
} {}
782
test winFCmd-9.2 {TraversalDelete: DOTREE_F} {95} {
783
    cleanup
784
    file mkdir td1
785
    set fd [open td1/tf1 w]
786
    set msg [list [catch {testfile rmdir -force td1} msg] $msg]
787
    close $fd
788
    set msg
789
} {1 {td1\tf1 EACCES}}
790
test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} {
791
    cleanup
792
    file mkdir td1/td2
793
    testchmod 000 td1
794
    testfile rmdir -force td1
795
    file exists td1
796
} {0}
797
test winFCmd-9.4 {TraversalDelete: DOTREE_POSTD} {
798
    cleanup
799
    file mkdir td1/td1/td3/td4/td5
800
    testfile rmdir -force td1
801
} {}
802
 
803
test winFCmd-10.1 {AttributesPosixError - get} {
804
    cleanup
805
    list [catch {file attributes td1 -archive} msg] $msg
806
} {1 {cannot get attribute "-archive" for file "td1": no such file or directory}}
807
test winFCmd-10.2 {AttributesPosixError - set} {
808
    cleanup
809
    list [catch {file attributes td1 -archive 0} msg] $msg
810
} {1 {cannot set attribute "-archive" for file "td1": no such file or directory}}
811
 
812
test winFCmd-11.1 {GetWinFileAttributes} {
813
    cleanup
814
    close [open td1 w]
815
    list [catch {file attributes td1 -archive} msg] $msg [cleanup]
816
} {0 1 {}}
817
test winFCmd-11.2 {GetWinFileAttributes} {
818
    cleanup
819
    close [open td1 w]
820
    list [catch {file attributes td1 -readonly} msg] $msg [cleanup]
821
} {0 0 {}}
822
test winFCmd-11.3 {GetWinFileAttributes} {
823
    cleanup
824
    close [open td1 w]
825
    list [catch {file attributes td1 -hidden} msg] $msg [cleanup]
826
} {0 0 {}}
827
test winFCmd-11.4 {GetWinFileAttributes} {
828
    cleanup
829
    close [open td1 w]
830
    list [catch {file attributes td1 -system} msg] $msg [cleanup]
831
} {0 0 {}}
832
 
833
test winFCmd-12.1 {ConvertFileNameFormat} {
834
    cleanup
835
    close [open td1 w]
836
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
837
} {0 td1 {}}
838
test winFCmd-12.2 {ConvertFileNameFormat} {
839
    cleanup
840
    file mkdir td1
841
    close [open td1/td1 w]
842
    list [catch {string tolower [file attributes td1/td1 -longname]} msg] $msg [cleanup]
843
} {0 td1/td1 {}}
844
test winFCmd-12.3 {ConvertFileNameFormat} {
845
    cleanup
846
    file mkdir td1
847
    file mkdir td1/td2
848
    close [open td1/td3 w]
849
    list [catch {string tolower [file attributes td1/td2/../td3 -longname]} msg] $msg [cleanup]
850
} {0 td1/td2/../td3 {}}
851
test winFCmd-12.4 {ConvertFileNameFormat} {
852
    cleanup
853
    close [open td1 w]
854
    list [catch {string tolower [file attributes ./td1 -longname]} msg] $msg [cleanup]
855
} {0 ./td1 {}}
856
test winFCmd-12.5 {ConvertFileNameFormat: absolute path} {
857
    list [file attributes / -longname] [file attributes \\ -longname]
858
} {/ /}
859
test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive} {
860
    catch {file delete -force -- c:/td1}
861
    close [open c:/td1 w]
862
    list [catch {string tolower [file attributes c:/td1 -longname]} msg] $msg [file delete -force -- c:/td1]
863
} {0 c:/td1 {}}
864
test winFCmd-12.7 {ConvertFileNameFormat} {UNCPath} {
865
    catch {file delete -force -- //bisque/icepick/test/td1}
866
    close [open //bisque/icepick/test/td1 w]
867
    list [catch {string tolower [file attributes //bisque/icepick/test/td1 -longname]} msg] $msg [file delete -force -- //bisque/icepick/test/td1]
868
} {0 //bisque/icepick/test/td1 {}}
869
test winFCmd-12.8 {ConvertFileNameFormat} {longFileNames} {
870
    cleanup
871
    close [open td1 w]
872
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
873
} {0 td1 {}}
874
test winFCmd-12.9 {ConvertFileNameFormat} {win32s} {
875
    cleanup
876
    close [open td1 w]
877
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
878
} {0 td1 {}}
879
test winFCmd-12.10 {ConvertFileNameFormat} {longFileNames} {
880
    cleanup
881
    close [open td1td1td1 w]
882
    list [catch {file attributes td1td1td1 -shortname}] [cleanup]
883
} {0 {}}
884
test winFCmd-12.11 {ConvertFileNameFormat} {longFileNames} {
885
    cleanup
886
    close [open td1 w]
887
    list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup]
888
} {0 td1 {}}
889
 
890
test winFCmd-13.1 {GetWinFileLongName} {
891
    cleanup
892
    close [open td1 w]
893
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
894
} {0 td1 {}}
895
 
896
test winFCmd-14.1 {GetWinFileShortName} {
897
    cleanup
898
    close [open td1 w]
899
    list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup]
900
} {0 td1 {}}
901
 
902
test winFCmd-15.1 {SetWinFileAttributes} {
903
    cleanup
904
    list [catch {file attributes td1 -archive 0} msg] $msg
905
} {1 {cannot set attribute "-archive" for file "td1": no such file or directory}}
906
test winFCmd-15.2 {SetWinFileAttributes - archive} {
907
    cleanup
908
    close [open td1 w]
909
    list [catch {file attributes td1 -archive 1} msg] $msg [file attributes td1 -archive] [cleanup]
910
} {0 {} 1 {}}
911
test winFCmd-15.3 {SetWinFileAttributes - archive} {
912
    cleanup
913
    close [open td1 w]
914
    list [catch {file attributes td1 -archive 0} msg] $msg [file attributes td1 -archive] [cleanup]
915
} {0 {} 0 {}}
916
test winFCmd-15.4 {SetWinFileAttributes - hidden} {
917
    cleanup
918
    close [open td1 w]
919
    list [catch {file attributes td1 -hidden 1} msg] $msg [file attributes td1 -hidden] [file attributes td1 -hidden 0] [cleanup]
920
} {0 {} 1 {} {}}
921
test winFCmd-15.5 {SetWinFileAttributes - hidden} {
922
    cleanup
923
    close [open td1 w]
924
    list [catch {file attributes td1 -hidden 0} msg] $msg [file attributes td1 -hidden] [cleanup]
925
} {0 {} 0 {}}
926
test winFCmd-15.6 {SetWinFileAttributes - readonly} {
927
    cleanup
928
    close [open td1 w]
929
    list [catch {file attributes td1 -readonly 1} msg] $msg [file attributes td1 -readonly] [cleanup]
930
} {0 {} 1 {}}
931
test winFCmd-15.7 {SetWinFileAttributes - readonly} {
932
    cleanup
933
    close [open td1 w]
934
    list [catch {file attributes td1 -readonly 0} msg] $msg [file attributes td1 -readonly] [cleanup]
935
} {0 {} 0 {}}
936
test winFCmd-15.8 {SetWinFileAttributes - system} {
937
    cleanup
938
    close [open td1 w]
939
    list [catch {file attributes td1 -system 1} msg] $msg [file attributes td1 -system] [cleanup]
940
} {0 {} 1 {}}
941
test winFCmd-15.9 {SetWinFileAttributes - system} {
942
    cleanup
943
    close [open td1 w]
944
    list [catch {file attributes td1 -system 0} msg] $msg [file attributes td1 -system] [cleanup]
945
} {0 {} 0 {}}
946
test winFCmd-15.10 {SetWinFileAttributes - failing} {cdrom} {
947
    cleanup
948
    catch {file attributes $cdfile -archive 1}
949
} {1}
950
 
951
cleanup
952
 
953
return
954
 
955
foreach source {tef ted tnf tnd "" nul com1} {
956
    foreach chmodsrc {000 755} {
957
        foreach dest "tfn tfe tdn tdempty tdfull td1/td2 $p $p/td1 {} nul" {
958
            foreach chmoddst {000 755} {
959
                puts hi
960
                cleanup
961
                file delete -force ted tef
962
                file mkdir ted
963
                createfile tef
964
                createfile tfe
965
                file mkdir tdempty
966
                file mkdir tdfull/td1/td2
967
 
968
                catch {testchmod $chmodsrc $source}
969
                catch {testchmod $chmoddst $dest}
970
 
971
                if [catch {file rename $source $dest} msg] {
972
                    puts "file rename $source ($chmodsrc) $dest ($chmoddst)"
973
                    puts $msg
974
                }
975
            }
976
        }
977
    }
978
}
979
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.