This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_leavesub(): call FREETMPS and optimise
[perl5.git] / t / op / stat.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';        # for which_perl() etc
7 }
8
9 use Config;
10
11 my ($Null, $Curdir);
12 if(eval {require File::Spec; 1}) {
13     $Null = File::Spec->devnull;
14     $Curdir = File::Spec->curdir;
15 } else {
16     die $@ unless is_miniperl();
17     $Curdir = '.';
18     diag("miniperl failed to load File::Spec, error is:\n$@");
19     diag("\ncontinuing, assuming '.' for current directory. Some tests will be skipped.");
20 }
21
22 if ($^O eq 'MSWin32') {
23     # under minitest, buildcustomize sets this to 1, which means
24     # nlinks isn't populated properly, allow nlinks tests to pass
25     ${^WIN32_SLOPPY_STAT} = 0;
26 }
27
28 plan tests => 116;
29
30 my $Perl = which_perl();
31
32 $ENV{LC_ALL}   = 'C';           # Forge English error messages.
33 $ENV{LANGUAGE} = 'C';           # Ditto in GNU.
34
35 $Is_Amiga   = $^O eq 'amigaos';
36 $Is_Cygwin  = $^O eq 'cygwin';
37 $Is_Darwin  = $^O eq 'darwin';
38 $Is_Dos     = $^O eq 'dos';
39 $Is_MSWin32 = $^O eq 'MSWin32';
40 $Is_NetWare = $^O eq 'NetWare';
41 $Is_OS2     = $^O eq 'os2';
42 $Is_Solaris = $^O eq 'solaris';
43 $Is_VMS     = $^O eq 'VMS';
44 $Is_MPRAS   = $^O =~ /svr4/ && -f '/etc/.relid';
45 $Is_Android = $^O =~ /android/;
46
47 $Is_Dosish  = $Is_Dos || $Is_OS2 || $Is_MSWin32 || $Is_NetWare;
48
49 $Is_UFS     = $Is_Darwin && (() = `df -t ufs . 2>/dev/null`) == 2;
50
51 if ($Is_Cygwin && !is_miniperl) {
52   require Win32;
53   Win32->import;
54 }
55
56 my($DEV, $INO, $MODE, $NLINK, $UID, $GID, $RDEV, $SIZE,
57    $ATIME, $MTIME, $CTIME, $BLKSIZE, $BLOCKS) = (0..12);
58
59 my $tmpfile = tempfile();
60 my $tmpfile_link = tempfile();
61
62 chmod 0666, $tmpfile;
63 unlink_all $tmpfile;
64 open(FOO, ">$tmpfile") || DIE("Can't open temp test file: $!");
65 close FOO;
66
67 open(FOO, ">$tmpfile") || DIE("Can't open temp test file: $!");
68
69 my($nlink, $mtime, $ctime) = (stat(FOO))[$NLINK, $MTIME, $CTIME];
70
71 # The clock on a network filesystem might be different from the
72 # system clock.
73 my $Filesystem_Time_Offset = abs($mtime - time); 
74
75 #nlink should if link support configured in Perl.
76 SKIP: {
77     skip "No link count - Hard link support not built in.", 1
78         unless $Config{d_link};
79
80     is($nlink, 1, 'nlink on regular file');
81 }
82
83 SKIP: {
84   skip "mtime and ctime not reliable", 2
85     if $Is_MSWin32 or $Is_NetWare or $Is_Cygwin or $Is_Dos or $Is_Darwin;
86
87   ok( $mtime,           'mtime' );
88   is( $mtime, $ctime,   'mtime == ctime' );
89 }
90
91
92 # Cygwin seems to have a 3 second granularity on its timestamps.
93 my $funky_FAT_timestamps = $Is_Cygwin;
94 sleep 3 if $funky_FAT_timestamps;
95
96 print FOO "Now is the time for all good men to come to.\n";
97 close(FOO);
98
99 sleep 2;
100
101 my $has_link = 1;
102 my $inaccurate_atime = 0;
103 if (defined &Win32::IsWinNT && Win32::IsWinNT()) {
104     if (Win32::FsType() ne 'NTFS') {
105         $has_link            = 0;
106         $inaccurate_atime    = 1;
107     }
108 }
109
110 SKIP: {
111     skip "No link on this filesystem", 6 unless $has_link;
112     unlink $tmpfile_link;
113     my $lnk_result = eval { link $tmpfile, $tmpfile_link };
114     skip "link() unimplemented", 6 if $@ =~ /unimplemented/;
115
116     is( $@, '',         'link() implemented' );
117     ok( $lnk_result,    'linked tmp testfile' );
118     ok( chmod(0644, $tmpfile),             'chmoded tmp testfile' );
119
120     my($nlink, $mtime, $ctime) = (stat($tmpfile))[$NLINK, $MTIME, $CTIME];
121
122     SKIP: {
123         skip "No link count", 1 if $Config{dont_use_nlink};
124         skip "Cygwin9X fakes hard links by copying", 1
125           if $Config{myuname} =~ /^cygwin_(?:9\d|me)\b/i;
126
127         is($nlink, 2,     'Link count on hard linked file' );
128     }
129
130     SKIP: {
131         skip_if_miniperl("File::Spec not built for minitest", 2);
132         my $cwd = File::Spec->rel2abs($Curdir);
133         skip "Solaris tmpfs has different mtime/ctime link semantics", 2
134                                      if $Is_Solaris and $cwd =~ m#^/tmp# and
135                                         $mtime && $mtime == $ctime;
136         skip "AFS has different mtime/ctime link semantics", 2
137                                      if $cwd =~ m#$Config{'afsroot'}/#;
138         skip "AmigaOS has different mtime/ctime link semantics", 2
139                                      if $Is_Amiga;
140         # Win32 could pass $mtime test but as FAT and NTFS have
141         # no ctime concept $ctime is ALWAYS == $mtime
142         # expect netware to be the same ...
143         skip "No ctime concept on this OS", 2
144                                      if $Is_MSWin32 || 
145                                         ($Is_Darwin && $Is_UFS);
146
147         if( !ok($mtime, 'hard link mtime') ||
148             !isnt($mtime, $ctime, 'hard link ctime != mtime') ) {
149             print STDERR <<DIAG;
150 # Check if you are on a tmpfs of some sort.  Building in /tmp sometimes
151 # has this problem.  Building on the ClearCase VOBS filesystem may also
152 # cause this failure.
153 #
154 # Darwin's UFS doesn't have a ctime concept, and thus is expected to fail
155 # this test.
156 DIAG
157         }
158     }
159
160 }
161
162 # truncate and touch $tmpfile.
163 open(F, ">$tmpfile") || DIE("Can't open temp test file: $!");
164 ok(-z \*F,     '-z on empty filehandle');
165 ok(! -s \*F,   '   and -s');
166 close F;
167
168 ok(-z $tmpfile,     '-z on empty file');
169 ok(! -s $tmpfile,   '   and -s');
170
171 open(F, ">$tmpfile") || DIE("Can't open temp test file: $!");
172 print F "hi\n";
173 close F;
174
175 open(F, "<$tmpfile") || DIE("Can't open temp test file: $!");
176 ok(!-z *F,     '-z on empty filehandle');
177 ok( -s *F,   '   and -s');
178 close F;
179
180 ok(! -z $tmpfile,   '-z on non-empty file');
181 ok(-s $tmpfile,     '   and -s');
182
183
184 # Strip all access rights from the file.
185 ok( chmod(0000, $tmpfile),     'chmod 0000' );
186
187 SKIP: {
188     skip "-r, -w and -x have different meanings on VMS", 3 if $Is_VMS;
189
190     SKIP: {
191         # Going to try to switch away from root.  Might not work.
192         my $olduid = $>;
193         eval { $> = 1; };
194         skip "Can't test if an admin user in miniperl", 2,
195           if $Is_Cygwin && is_miniperl();
196         skip "Can't test -r or -w meaningfully if you're superuser", 2
197           if ($> == 0);
198
199         SKIP: {
200             skip "Can't test -r meaningfully?", 1 if $Is_Dos;
201             ok(!-r $tmpfile,    "   -r");
202         }
203
204         ok(!-w $tmpfile,    "   -w");
205
206         # switch uid back (may not be implemented)
207         eval { $> = $olduid; };
208     }
209
210     ok(! -x $tmpfile,   '   -x');
211 }
212
213
214
215 ok(chmod(0700,$tmpfile),    'chmod 0700');
216 ok(-r $tmpfile,     '   -r');
217 ok(-w $tmpfile,     '   -w');
218
219 SKIP: {
220     skip "-x simply determines if a file ends in an executable suffix", 1
221       if $Is_Dosish;
222
223     ok(-x $tmpfile,     '   -x');
224 }
225
226 ok(  -f $tmpfile,   '   -f');
227 ok(! -d $tmpfile,   '   !-d');
228
229 # Is this portable?
230 ok(  -d '.',          '-d cwd' );
231 ok(! -f '.',          '!-f cwd' );
232
233
234 SKIP: {
235     unlink($tmpfile_link);
236     my $symlink_rslt = eval { symlink $tmpfile, $tmpfile_link };
237     skip "symlink not implemented", 3 if $@ =~ /unimplemented/;
238
239     is( $@, '',     'symlink() implemented' );
240     ok( $symlink_rslt,      'symlink() ok' );
241     ok(-l $tmpfile_link,    '-l');
242 }
243
244 ok(-o $tmpfile,     '-o');
245
246 ok(-e $tmpfile,     '-e');
247
248 unlink($tmpfile_link);
249 ok(! -e $tmpfile_link,  '   -e on unlinked file');
250
251 SKIP: {
252     skip "No character, socket or block special files", 6
253       if $Is_MSWin32 || $Is_NetWare || $Is_Dos;
254     skip "/dev isn't available to test against", 6
255       unless -d '/dev' && -r '/dev' && -x '/dev';
256     skip "Skipping: unexpected ls output in MP-RAS", 6
257       if $Is_MPRAS;
258
259     # VMS problem:  If GNV or other UNIX like tool is installed, then
260     # sometimes Perl will find /bin/ls, and will try to run it.
261     # But since Perl on VMS does not know to run it under Bash, it will
262     # try to run the DCL verb LS.  And if the VMS product Language
263     # Sensitive Editor is installed, or some other LS verb, that will
264     # be run instead.  So do not do this until we can teach Perl
265     # when to use BASH on VMS.
266     skip "ls command not available to Perl in OpenVMS right now.", 6
267       if $Is_VMS;
268
269     delete $ENV{CLICOLOR_FORCE};
270     my $LS  = $Config{d_readlink} && !$Is_Android ? "ls -lL" : "ls -l";
271     my $CMD = "$LS /dev 2>/dev/null";
272     my $DEV = qx($CMD);
273
274     skip "$CMD failed", 6 if $DEV eq '';
275
276     my @DEV = do { my $dev; opendir($dev, "/dev") ? readdir($dev) : () };
277
278     skip "opendir failed: $!", 6 if @DEV == 0;
279
280     # /dev/stdout might be either character special or a named pipe,
281     # or a symlink, or a socket, depending on which OS and how are
282     # you running the test, so let's censor that one away.
283     # Similar remarks hold for stderr.
284     $DEV =~ s{^[cpls].+?\sstdout$}{}m;
285     @DEV =  grep { $_ ne 'stdout' } @DEV;
286     $DEV =~ s{^[cpls].+?\sstderr$}{}m;
287     @DEV =  grep { $_ ne 'stderr' } @DEV;
288
289     # /dev/printer is also naughty: in IRIX it shows up as
290     # Srwx-----, not srwx------.
291     $DEV =~ s{^.+?\sprinter$}{}m;
292     @DEV =  grep { $_ ne 'printer' } @DEV;
293
294     # If running as root, we will see .files in the ls result,
295     # and readdir() will see them always.  Potential for conflict,
296     # so let's weed them out.
297     $DEV =~ s{^.+?\s\..+?$}{}m;
298     @DEV =  grep { ! m{^\..+$} } @DEV;
299
300     # Irix ls -l marks sockets with 'S' while 's' is a 'XENIX semaphore'.
301     if ($^O eq 'irix') {
302         $DEV =~ s{^S(.+?)}{s$1}mg;
303     }
304
305     my $try = sub {
306         my @c1 = eval qq[\$DEV =~ /^$_[0].*/mg];
307         my @c2 = eval qq[grep { $_[1] "/dev/\$_" } \@DEV];
308         my $c1 = scalar @c1;
309         my $c2 = scalar @c2;
310         is($c1, $c2, "ls and $_[1] agreeing on /dev ($c1 $c2)");
311     };
312
313 {
314     $try->('b', '-b');
315     $try->('c', '-c');
316     $try->('s', '-S');
317 }
318
319 ok(! -b $Curdir,    '!-b cwd');
320 ok(! -c $Curdir,    '!-c cwd');
321 ok(! -S $Curdir,    '!-S cwd');
322
323 }
324
325 SKIP: {
326     my($cnt, $uid);
327     $cnt = $uid = 0;
328
329     # Find a set of directories that's very likely to have setuid files
330     # but not likely to be *all* setuid files.
331     my @bin = grep {-d && -r && -x} qw(/sbin /usr/sbin /bin /usr/bin);
332     skip "Can't find a setuid file to test with", 3 unless @bin;
333
334     for my $bin (@bin) {
335         opendir BIN, $bin or die "Can't opendir $bin: $!";
336         while (defined($_ = readdir BIN)) {
337             $_ = "$bin/$_";
338             $cnt++;
339             $uid++ if -u;
340             last if $uid && $uid < $cnt;
341         }
342     }
343     closedir BIN;
344
345     skip "No setuid programs", 3 if $uid == 0;
346
347     isnt($cnt, 0,    'found some programs');
348     isnt($uid, 0,    '  found some setuid programs');
349     ok($uid < $cnt,  "    they're not all setuid");
350 }
351
352
353 # To assist in automated testing when a controlling terminal (/dev/tty)
354 # may not be available (at, cron  rsh etc), the PERL_SKIP_TTY_TEST env var
355 # can be set to skip the tests that need a tty.
356 SKIP: {
357     skip "These tests require a TTY", 4 if $ENV{PERL_SKIP_TTY_TEST};
358
359     my $TTY = "/dev/tty";
360
361     SKIP: {
362         skip "Test uses unixisms", 2 if $Is_MSWin32 || $Is_NetWare;
363         skip "No TTY to test -t with", 2 unless -e $TTY;
364
365         open(TTY, $TTY) ||
366           warn "Can't open $TTY--run t/TEST outside of make.\n";
367         ok(-t TTY,  '-t');
368         ok(-c TTY,  'tty is -c');
369         close(TTY);
370     }
371     ok(! -t TTY,    '!-t on closed TTY filehandle');
372
373     {
374         local $TODO = 'STDIN not a tty when output is to pipe' if $Is_VMS;
375         ok(-t,          '-t on STDIN');
376     }
377 }
378
379 SKIP: {
380     skip "No null device to test with", 1 unless -e $Null;
381     skip "We know Win32 thinks '$Null' is a TTY", 1 if $Is_MSWin32;
382
383     open(NULL, $Null) or DIE("Can't open $Null: $!");
384     ok(! -t NULL,   'null device is not a TTY');
385     close(NULL);
386 }
387
388
389 # These aren't strictly "stat" calls, but so what?
390 my $statfile = './op/stat.t';
391 ok(  -T $statfile,    '-T');
392 ok(! -B $statfile,    '!-B');
393 ok(-B $Perl,      '-B');
394 ok(! -T $Perl,    '!-T');
395
396 open(FOO,$statfile);
397 SKIP: {
398     eval { -T FOO; };
399     skip "-T/B on filehandle not implemented", 15 if $@ =~ /not implemented/;
400
401     is( $@, '',     '-T on filehandle causes no errors' );
402
403     ok(-T FOO,      '   -T');
404     ok(! -B FOO,    '   !-B');
405
406     $_ = <FOO>;
407     like($_, qr/perl/, 'after readline');
408     ok(-T FOO,      '   still -T');
409     ok(! -B FOO,    '   still -B');
410     close(FOO);
411
412     open(FOO,$statfile);
413     $_ = <FOO>;
414     like($_, qr/perl/,      'reopened and after readline');
415     ok(-T FOO,      '   still -T');
416     ok(! -B FOO,    '   still !-B');
417
418     ok(seek(FOO,0,0),   'after seek');
419     ok(-T FOO,          '   still -T');
420     ok(! -B FOO,        '   still !-B');
421
422     # It's documented this way in perlfunc *shrug*
423     () = <FOO>;
424     ok(eof FOO,         'at EOF');
425     ok(-T FOO,          '   still -T');
426     ok(-B FOO,          '   now -B');
427 }
428 close(FOO);
429
430
431 SKIP: {
432     skip "No null device to test with", 2 unless -e $Null;
433
434     ok(-T $Null,  'null device is -T');
435     ok(-B $Null,  '    and -B');
436 }
437
438
439 # and now, a few parsing tests:
440 $_ = $tmpfile;
441 ok(-f,      'bare -f   uses $_');
442 ok(-f(),    '     -f() "');
443
444 unlink $tmpfile or print "# unlink failed: $!\n";
445
446 # bug id 20011101.069
447 my @r = \stat($Curdir);
448 is(scalar @r, 13,   'stat returns full 13 elements');
449
450 stat $0;
451 eval { lstat _ };
452 like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
453     'lstat _ croaks after stat' );
454 eval { lstat *_ };
455 like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
456     'lstat *_ croaks after stat' );
457 eval { lstat \*_ };
458 like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
459     'lstat \*_ croaks after stat' );
460 eval { -l _ };
461 like( $@, qr/^The stat preceding -l _ wasn't an lstat/,
462     '-l _ croaks after stat' );
463
464 lstat $0;
465 eval { lstat _ };
466 is( "$@", "", "lstat _ ok after lstat" );
467 eval { -l _ };
468 is( "$@", "", "-l _ ok after lstat" );
469
470 eval { lstat "test.pl" };
471 {
472     open my $fh, "test.pl";
473     stat *$fh{IO};
474     eval { lstat _ }
475 }
476 like $@, qr/^The stat preceding lstat\(\) wasn't an lstat at /,
477 'stat $ioref resets stat type';
478
479 {
480     open(FOO, ">$tmpfile") || DIE("Can't open temp test file: $!");
481     my @statbuf = stat FOO;
482     stat "test.pl";
483     my @lstatbuf = lstat *FOO{IO};
484     is "@lstatbuf", "@statbuf", 'lstat $ioref reverts to regular fstat';
485     close(FOO);
486     unlink $tmpfile or print "# unlink failed: $!\n";
487 }
488   
489 SKIP: {
490     skip "No lstat", 2 unless $Config{d_lstat};
491
492     # bug id 20020124.004
493     # If we have d_lstat, we should have symlink()
494     my $linkname = 'stat-' . rand =~ y/.//dr;
495     my $target = $Perl;
496     $target =~ s/;\d+\z// if $Is_VMS; # symlinks don't like version numbers
497     symlink $target, $linkname or die "# Can't symlink $0: $!";
498     lstat $linkname;
499     -T _;
500     eval { lstat _ };
501     like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
502         'lstat croaks after -T _' );
503     eval { -l _ };
504     like( $@, qr/^The stat preceding -l _ wasn't an lstat/,
505         '-l _ croaks after -T _' );
506     unlink $linkname or print "# unlink $linkname failed: $!\n";
507 }
508
509 SKIP: {
510     skip "Too much clock skew between system and filesystem", 5
511         if ($Filesystem_Time_Offset > 5);
512     print "# Zzz...\n";
513     sleep($Filesystem_Time_Offset+1);
514     my $f = 'tstamp.tmp';
515     unlink $f;
516     ok (open(S, "> $f"), 'can create tmp file');
517     close S or die;
518     my @a = stat $f;
519     print "# time=$^T, stat=(@a)\n";
520     my @b = (-M _, -A _, -C _);
521     print "# -MAC=(@b)\n";
522     ok( (-M _) < 0, 'negative -M works');
523   SKIP:
524     {
525         skip "Access timestamps inaccurate", 1 if $inaccurate_atime;
526         ok( (-A _) < 0, 'negative -A works');
527     }
528     ok( (-C _) < 0, 'negative -C works');
529     ok(unlink($f), 'unlink tmp file');
530 }
531
532 # [perl #4253]
533 {
534     ok(open(F, ">", $tmpfile), 'can create temp file');
535     close F;
536     chmod 0077, $tmpfile;
537     my @a = stat($tmpfile);
538     my $s1 = -s _;
539     -T _;
540     my $s2 = -s _;
541     is($s1, $s2, q(-T _ doesn't break the statbuffer));
542     SKIP: {
543         my $root_uid = $Is_Cygwin ? 18 : 0;
544         skip "No lstat", 1 unless $Config{d_lstat};
545         skip "uid=0", 1 if $< == $root_uid or $> == $root_uid;
546         skip "Can't check if admin user in miniperl", 1
547           if $^O =~ /^(cygwin|MSWin32|msys)$/ && is_miniperl();
548         skip "Readable by group/other means readable by me on $^O", 1 if $^O eq 'VMS'
549           or ($^O =~ /^(cygwin|MSWin32|msys)$/ and Win32::IsAdminUser());
550         lstat($tmpfile);
551         -T _;
552         ok(eval { lstat _ },
553            q(-T _ doesn't break lstat for unreadable file));
554     }
555     unlink $tmpfile;
556 }
557
558 SKIP: {
559     skip "No dirfd()", 9 unless $Config{d_dirfd} || $Config{d_dir_dd_fd};
560     ok(opendir(DIR, "."), 'Can open "." dir') || diag "Can't open '.':  $!";
561     ok(stat(DIR), "stat() on dirhandle works"); 
562     ok(-d -r _ , "chained -x's on dirhandle"); 
563     ok(-d DIR, "-d on a dirhandle works");
564
565     # And now for the ambiguous bareword case
566     {
567         no warnings 'deprecated';
568         ok(open(DIR, "TEST"), 'Can open "TEST" dir')
569             || diag "Can't open 'TEST':  $!";
570     }
571     my $size = (stat(DIR))[7];
572     ok(defined $size, "stat() on bareword works");
573     is($size, -s "TEST", "size returned by stat of bareword is for the file");
574     ok(-f _, "ambiguous bareword uses file handle, not dir handle");
575     ok(-f DIR);
576     closedir DIR or die $!;
577     close DIR or die $!;
578 }
579
580 {
581     # RT #8244: *FILE{IO} does not behave like *FILE for stat() and -X() operators
582     ok(open(F, ">", $tmpfile), 'can create temp file');
583     my @thwap = stat *F{IO};
584     ok(@thwap, "stat(*F{IO}) works");    
585     ok( -f *F{IO} , "single file tests work with *F{IO}");
586     close F;
587     unlink $tmpfile;
588
589     #PVIO's hold dirhandle information, so let's test them too.
590
591     SKIP: {
592         skip "No dirfd()", 9 unless $Config{d_dirfd} || $Config{d_dir_dd_fd};
593         ok(opendir(DIR, "."), 'Can open "." dir') || diag "Can't open '.':  $!";
594         ok(stat(*DIR{IO}), "stat() on *DIR{IO} works");
595         ok(-d _ , "The special file handle _ is set correctly"); 
596         ok(-d -r *DIR{IO} , "chained -x's on *DIR{IO}");
597
598         # And now for the ambiguous bareword case
599         {
600             no warnings 'deprecated';
601             ok(open(DIR, "TEST"), 'Can open "TEST" dir')
602                 || diag "Can't open 'TEST':  $!";
603         }
604         my $size = (stat(*DIR{IO}))[7];
605         ok(defined $size, "stat() on *THINGY{IO} works");
606         is($size, -s "TEST",
607            "size returned by stat of *THINGY{IO} is for the file");
608         ok(-f _, "ambiguous *THINGY{IO} uses file handle, not dir handle");
609         ok(-f *DIR{IO});
610         closedir DIR or die $!;
611         close DIR or die $!;
612     }
613 }
614
615 # [perl #71002]
616 {
617     local $^W = 1;
618     my $w;
619     local $SIG{__WARN__} = sub { warn shift; ++$w };
620     stat 'prepeinamehyparcheiarcheiometoonomaavto';
621     stat _;
622     is $w, undef, 'no unopened warning from stat _';
623 }
624
625 {
626     # [perl #123816]
627     # Inappropriate stacking of l?stat with filetests should either work or
628     # give a syntax error, they shouldn't crash.
629     eval { stat -t };
630     ok(1, 'can "stat -t" without crashing');
631         eval { lstat -t };
632     ok(1, 'can "lstat -t" without crashing');
633 }
634
635 # [perl #126064] stat stat stack busting
636 is join("-", 1,2,3,(stat stat stat),4,5,6), "1-2-3-4-5-6",
637   'stat inside stat gets scalar context';
638
639 END {
640     chmod 0666, $tmpfile;
641     unlink_all $tmpfile;
642 }