1#!./perl 2 3use Config; 4 5BEGIN { 6 if($ENV{PERL_CORE}) { 7 if ($Config{'extensions'} !~ /\bIO\b/) { 8 print "1..0 # Skip: IO extension not built\n"; 9 exit 0; 10 } 11 } 12 if( $^O eq 'VMS' && $Config{'vms_cc_type'} ne 'decc' ) { 13 print "1..0 # Skip: not compatible with the VAXCRTL\n"; 14 exit 0; 15 } 16} 17 18use Test::More tests => 5; 19use IO::File; 20use IO::Seekable; 21 22$x = new_tmpfile IO::File; 23ok($x, "new_tmpfile"); 24print $x "ok 2\n"; 25$x->seek(0,SEEK_SET); 26my $line = <$x>; 27is($line, "ok 2\n", "check we can write to the tempfile"); 28 29$x->seek(0,SEEK_SET); 30print $x "not ok 3\n"; 31$p = $x->getpos; 32print $x "ok 3\n"; 33$x->flush; 34$x->setpos($p); 35$line = <$x>; 36is($line, "ok 3\n", "test getpos/setpos"); 37 38$! = 0; 39$x->setpos(undef); 40ok($!, "setpos(undef) makes errno non-zero"); 41 42SKIP: 43{ # [perl #64772] IO::Handle->sync fails on an O_RDONLY descriptor 44 $Config{d_fsync} 45 or skip "No fsync", 1; 46 $^O =~ /^(?:aix|irix)$/ 47 and skip "fsync() documented to fail on non-writable handles on $^O", 1; 48 $^O eq 'cygwin' 49 and skip "fsync() on cygwin uses FlushFileBuffers which requires a writable handle", 1; 50 open my $fh, "<", "t/io_xs.t" 51 or skip "Cannot open t/io_xs.t read-only: $!", 1; 52 ok($fh->sync, "sync to a read only handle") 53 or diag "sync(): ", $!; 54} 55