From: Garrett C. <su...@li...> - 2011-04-22 03:19:28
|
The branch, master, has been updated via c39aa59fd711d246d700c18cc36e9085a0d9ad79 (commit) via d050ff285dededc353dd40b01ec4c5977fb0081e (commit) from f8d9373e0b1042459c32d55fc2636c1cdfe3f817 (commit) - Log ----------------------------------------------------------------- commit c39aa59fd711d246d700c18cc36e9085a0d9ad79 Merge: d050ff285dededc353dd40b01ec4c5977fb0081e f8d9373e0b1042459c32d55fc2636c1cdfe3f817 Author: Garrett Cooper <yan...@gm...> Date: Thu Apr 21 20:18:35 2011 -0700 Merge branch 'master' of ssh://ltp.git.sourceforge.net/gitroot/ltp/ltp commit d050ff285dededc353dd40b01ec4c5977fb0081e Author: Garrett Cooper <yan...@gm...> Date: Thu Apr 21 20:16:43 2011 -0700 Fix the testcase by using a temporary directory. Signed-off-by: Garrett Cooper <yan...@gm...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/containers/netns/container_ftp.pl | 36 +++++++++++++++----- 1 files changed, 27 insertions(+), 9 deletions(-) diff --git a/testcases/kernel/containers/netns/container_ftp.pl b/testcases/kernel/containers/netns/container_ftp.pl index 3c704c8..696d252 100644 --- a/testcases/kernel/containers/netns/container_ftp.pl +++ b/testcases/kernel/containers/netns/container_ftp.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ################################################################################ ## ## @@ -21,19 +21,34 @@ ## Author: Veerendra <ve...@li...> ## ################################################################################ +use File::Temp 'tempdir'; use Net::FTP; +if ($#ARGV == -1) { + print "usage: $0 host\n"; + exit 1; +} my $host = $ARGV[0]; my $newname; my $i = 0; my $kount = 51; my $file="junkfile"; -my $dir="/tmp/ftpdir"; -mkdir $dir; +my $tmpdir = defined($ENV{TMPDIR}) ? $ENV{TMPDIR} : "/tmp"; + +my $dir; +$dir = tempdir("container_ftp.XXXXXXX", DIR => $tmpdir); +if (!defined($dir)) { + push @ERRORS, "Failed to create a temporary directory: $!\n"; + printerr(); +} +if (chmod(0777, $dir) != 0) { + push @ERRORS, "Failed to change mode for temporary directory: $!\n"; + printerr(); +} chdir $dir; -system("dd if=/dev/zero of=$putdir$file bs=512 count=10 > /dev/null 2>&1 "); +system("dd if=/dev/zero of=$file bs=512 count=10 > /dev/null 2>&1 "); while ( $i < $kount ) { @@ -59,11 +74,14 @@ while ( $i < $kount ) $i++; $ftp->quit; } -system("rm -rf $dir"); -exit 0; sub printerr { - print "Error: "; - print @ERRORS; - exit -1; + print "Error: "; + print @ERRORS; + exit 1; +} + +END { + unlink("$dir/$file"); + rmdir("$dir"); } hooks/post-receive -- ltp |