summaryrefslogtreecommitdiff
path: root/lib/Temp/File-Temp-0.12/t/mktemp.t
diff options
context:
space:
mode:
authorAndreas Mair <amair.sob@googlemail.com>2005-03-21 11:57:02 +0100
committerAndreas Mair <amair.sob@googlemail.com>2005-03-21 11:57:02 +0100
commit5083c05ce2e2bfc5719346d809719ebf01b0e69d (patch)
tree71e65c65489eebc70a366006be250529a97b5410 /lib/Temp/File-Temp-0.12/t/mktemp.t
parent7525bed2d315a25ac2caf95ff0bf44c905d58a7e (diff)
downloadvdradmin-am-0.97-am2.tar.gz
vdradmin-am-0.97-am2.tar.bz2
2005-03-20: 0.97-am2v0.97-am2
- TV and remote templates have same remote control. Added patches: - fix for timers.conf of vdr1.3.23+ (Submitted by x-stefan @vdrportal.de) - Localnet Patch; no password request if client ip in given ip range) (Submitted by "Reiner Buehl" <reiner@buehl.net>) 2005-03-19: Templates cleanup: - timer_list.html - timer_new.html - toolbar.html - tv_flash.html - tv.html 2005-03-18: - reworked summary display of recordings - summary editbox preserves linefeeds while editing timers Templates cleanup: - prog_timeline.html - rc.html - rec_edit.html - rec_list.html 2005-03-12: - Added stream button in prog_summmary (suggested by Unimatrix0 @vdrportal.de) Templates cleanup: - at_new.html - at_timer_list.html - config.html - error.html - index.html - left.html - noauth.html - noperm.html - prog_details.html (TODO) - prog_list2.html - prog_list.html - prog_summary.html (TODO) Added patches: - vdradmin-0.96_For_vdr-1.3_StoreAutotimerChannelID_And_EventIdCheckDisable.diff (posted at the VDR mailinglist by "Rantanen Teemu" <teemu.rantanen@tekla.com>) - vdradmin-0.96_OneShot_Timers_English_Only.diff and merged it to "Deutsch" template (posted at the VDR mailinglist by "Rantanen Teemu" <teemu.rantanen@tekla.com>) - included changes from vdradmin-0.96-3-ctvdr-1 (see HISTORY.ct). Changes that have been forgotten while merging previous patches: - Fixed: timer listing now shows "VPS" instead of "Auto (alt)". - removed unneeded <br>. They are still used for display only.
Diffstat (limited to 'lib/Temp/File-Temp-0.12/t/mktemp.t')
-rwxr-xr-xlib/Temp/File-Temp-0.12/t/mktemp.t110
1 files changed, 110 insertions, 0 deletions
diff --git a/lib/Temp/File-Temp-0.12/t/mktemp.t b/lib/Temp/File-Temp-0.12/t/mktemp.t
new file mode 100755
index 0000000..2014e30
--- /dev/null
+++ b/lib/Temp/File-Temp-0.12/t/mktemp.t
@@ -0,0 +1,110 @@
+#!/usr/local/bin/perl -w
+
+# Test for mktemp family of commands in File::Temp
+# Use STANDARD safe level for these tests
+
+use strict;
+use Test;
+BEGIN { plan tests => 9 }
+
+use File::Spec;
+use File::Path;
+use File::Temp qw/ :mktemp unlink0 /;
+use FileHandle;
+
+ok(1);
+
+# MKSTEMP - test
+
+# Create file in temp directory
+my $template = File::Spec->catfile(File::Spec->tmpdir, 'wowserXXXX');
+
+(my $fh, $template) = mkstemp($template);
+
+print "# MKSTEMP: FH is $fh File is $template fileno=".fileno($fh)."\n";
+# Check if the file exists
+ok( (-e $template) );
+
+# Autoflush
+$fh->autoflush(1) if $] >= 5.006;
+
+# Try printing something to the file
+my $string = "woohoo\n";
+print $fh $string;
+
+# rewind the file
+ok(seek( $fh, 0, 0));
+
+# Read from the file
+my $line = <$fh>;
+
+# compare with previous string
+ok($string, $line);
+
+# Tidy up
+# This test fails on Windows NT since it seems that the size returned by
+# stat(filehandle) does not always equal the size of the stat(filename)
+# This must be due to caching. In particular this test writes 7 bytes
+# to the file which are not recognised by stat(filename)
+# Simply waiting 3 seconds seems to be enough for the system to update
+
+if ($^O eq 'MSWin32') {
+ sleep 3;
+}
+my $status = unlink0($fh, $template);
+if ($status) {
+ ok( $status );
+} else {
+ skip("Skip test failed probably due to \$TMPDIR being on NFS",1);
+}
+
+# MKSTEMPS
+# File with suffix. This is created in the current directory so
+# may be problematic on NFS
+
+$template = "suffixXXXXXX";
+my $suffix = ".dat";
+
+($fh, my $fname) = mkstemps($template, $suffix);
+
+print "# MKSTEMPS: File is $template -> $fname fileno=".fileno($fh)."\n";
+# Check if the file exists
+ok( (-e $fname) );
+
+# This fails if you are running on NFS
+# If this test fails simply skip it rather than doing a hard failure
+$status = unlink0($fh, $fname);
+
+if ($status) {
+ ok($status);
+} else {
+ skip("Skip test failed probably due to cwd being on NFS",1)
+}
+
+# MKDTEMP
+# Temp directory
+
+$template = File::Spec->catdir(File::Spec->tmpdir, 'tmpdirXXXXXX');
+
+my $tmpdir = mkdtemp($template);
+
+print "# MKDTEMP: Name is $tmpdir from template $template\n";
+
+ok( (-d $tmpdir ) );
+
+# Need to tidy up after myself
+rmtree($tmpdir);
+
+# MKTEMP
+# Just a filename, not opened
+
+$template = File::Spec->catfile(File::Spec->tmpdir, 'mytestXXXXXX');
+
+my $tmpfile = mktemp($template);
+
+print "# MKTEMP: Tempfile is $template -> $tmpfile\n";
+
+# Okay if template no longer has XXXXX in
+
+
+ok( ($tmpfile !~ /XXXXX$/) );