2 # Test for File::Temp - POSIX functions
7 require Test; import Test;
13 use File::Temp qw/ :POSIX unlink0 /;
20 print "# TMPNAM: in a scalar context: \n";
21 my $tmpnam = tmpnam();
23 # simply check that the file does not exist
24 # Not a 100% water tight test though if another program
25 # has managed to create one in the meantime.
28 print "# TMPNAM file name: $tmpnam\n";
31 # Not strict posix behaviour
32 (my $fh, $tmpnam) = tmpnam();
34 print "# TMPNAM: in list context: $fh $tmpnam\n";
36 # File is opened - make sure it exists
39 # Unlink it - a possible NFS issue again if TMPDIR is not a local disk
40 my $status = unlink0($fh, $tmpnam);
44 skip("Skip test failed probably due to \$TMPDIR being on NFS",1);
53 print "# TMPFILE: tmpfile got FH $fh\n";
55 $fh->autoflush(1) if $] >= 5.006;
57 # print something to it
58 my $original = "Hello a test\n";
59 print "# TMPFILE: Wrote line: $original";
61 or die "Error printing to tempfile\n";
69 print "# TMPFILE: Read line: $line";
70 ok( $original, $line);
75 # Skip all the remaining tests
77 skip("Skip test failed probably due to \$TMPDIR being on NFS",1);