This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid race conditions with files in /tmp, by explicitly checking dev & inode.
[perl5.git] / t / io / perlio_open.t
CommitLineData
72e93046
JH
1#!./perl
2
72e93046
JH
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
3484683b
RGS
6 if ($ENV{PERL_CORE_MINITEST}) {
7 print "1..0 # Skip: no Fcntl under miniperl\n";
8 exit 0;
9 }
72e93046
JH
10 unless (find PerlIO::Layer 'perlio') {
11 print "1..0 # Skip: not perlio\n";
12 exit 0;
13 }
14 use Config;
15 unless (" $Config{extensions} " =~ / Fcntl /) {
16 print "1..0 # Skip: no Fcntl (how did you get this far?)\n";
17 exit 0;
18 }
0214bff6 19 require './test.pl';
72e93046
JH
20}
21
3484683b
RGS
22use strict;
23use warnings;
24
0214bff6 25plan tests => 6;
72e93046
JH
26
27use Fcntl qw(:seek);
28
29{
30 ok((open my $fh, "+>", undef), "open my \$fh, '+>', undef");
31 print $fh "the right write stuff";
32 ok(seek($fh, 0, SEEK_SET), "seek to zero");
33 my $data = <$fh>;
34 is($data, "the right write stuff", "found the right stuff");
35}
36
37{
38 ok((open my $fh, "+<", undef), "open my \$fh, '+<', undef");
39 print $fh "the right read stuff";
40 ok(seek($fh, 0, SEEK_SET), "seek to zero");
41 my $data = <$fh>;
42 is($data, "the right read stuff", "found the right stuff");
43}
44
45
46
47