Commit | Line | Data |
---|---|---|
f7a45afb JH |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
5 | @INC = '../lib'; | |
6 | } | |
7 | ||
8 | BEGIN { | |
9 | our $hasst; | |
10 | eval { my @n = stat "TEST" }; | |
11 | $hasst = 1 unless $@ && $@ =~ /unimplemented/; | |
12 | unless ($hasst) { print "1..0 # Skip: no stat\n"; exit 0 } | |
13 | use Config; | |
14 | $hasst = 0 unless $Config{'i_sysstat'} eq 'define'; | |
15 | unless ($hasst) { print "1..0 # Skip: no sys/stat.h\n"; exit 0 } | |
16 | } | |
17 | ||
18 | BEGIN { | |
19 | our @stat = stat "TEST"; # This is the function stat. | |
20 | unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 } | |
21 | } | |
22 | ||
23 | print "1..14\n"; | |
24 | ||
25 | use File::stat; | |
26 | ||
27 | print "ok 1\n"; | |
28 | ||
29 | my $stat = stat "TEST"; # This is the OO stat. | |
30 | ||
31 | print "not " unless $stat->dev == $stat[ 0]; | |
32 | print "ok 2\n"; | |
33 | ||
4f0c37ba IZ |
34 | # On OS/2 (fake) ino is not constant, it is incremented each time |
35 | print "# ino=>@{[$stat->ino]}, 1=>$stat[ 1]\nnot " | |
36 | unless $stat->ino == $stat[ 1] or $^O eq 'os2'; | |
f7a45afb JH |
37 | print "ok 3\n"; |
38 | ||
39 | print "not " unless $stat->mode == $stat[ 2]; | |
40 | print "ok 4\n"; | |
41 | ||
42 | print "not " unless $stat->nlink == $stat[ 3]; | |
43 | print "ok 5\n"; | |
44 | ||
45 | print "not " unless $stat->uid == $stat[ 4]; | |
46 | print "ok 6\n"; | |
47 | ||
48 | print "not " unless $stat->gid == $stat[ 5]; | |
49 | print "ok 7\n"; | |
50 | ||
51 | print "not " unless $stat->rdev == $stat[ 6]; | |
52 | print "ok 8\n"; | |
53 | ||
54 | print "not " unless $stat->size == $stat[ 7]; | |
55 | print "ok 9\n"; | |
56 | ||
57 | print "not " unless $stat->atime == $stat[ 8]; | |
58 | print "ok 10\n"; | |
59 | ||
60 | print "not " unless $stat->mtime == $stat[ 9]; | |
61 | print "ok 11\n"; | |
62 | ||
63 | print "not " unless $stat->ctime == $stat[10]; | |
64 | print "ok 12\n"; | |
65 | ||
66 | print "not " unless $stat->blksize == $stat[11]; | |
67 | print "ok 13\n"; | |
68 | ||
69 | print "not " unless $stat->blocks == $stat[12]; | |
70 | print "ok 14\n"; | |
71 | ||
72 | # Testing pretty much anything else is unportable. |