On Tue, Apr 19, 2011 at 8:52 PM, Peng Haitao <[email protected]> wrote:
>
> On RedHat, the case will output error message: Error: Can't get file junkfile.
> Because anonymous FTP user will not upload file into dir "/tmp/ftpdir" which
> permission is "755".

This should work better. It really should be rewritten to use /bin/sh,
but unfortunately ftp(1) isn't a part of the standard Linux toolset.
That being said it may or may not be a good idea to add it to the
requirements for this test.
Thanks,
-Garrett
diff --git a/testcases/kernel/containers/netns/container_ftp.pl b/testcases/kernel/containers/netns/container_ftp.pl
index 3c704c8..5e0e372 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 <[email protected]>                         ##
 ################################################################################ 
 
+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 (chown(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");
 }
diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index e8a35db..4228406 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -49,11 +49,11 @@
  *      test may have to be run as root depending on the tty permissions
  */
 
-#include <stdio.h>
-#include <sys/termios.h>
-#include <termio.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <stdio.h>
+#include <termio.h>
+#include <termios.h>
 #include "test.h"
 #include "usctest.h"
 
@@ -71,7 +71,6 @@ int exp_enos[] = { EBADF, EFAULT, EINVAL, ENOTTY, EFAULT, 0 };
 int fd, fd1;
 int bfd = -1;
 
-char *tty;
 struct termio termio;
 
 struct test_case_t {
@@ -123,10 +122,8 @@ int main(int ac, char **av)
 
 	setup();
 
-	if ((fd = open(devname, O_RDWR, 0777)) < 0) {
-		tst_brkm(TBROK, cleanup, "Couldn't open %s, errno = %d",
-			 tty, errno);
-	}
+	if ((fd = open(devname, O_RDWR, 0777)) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "Couldn't open %s", devname);
 
 	TEST_EXP_ENOS(exp_enos);
 
@@ -146,15 +143,12 @@ int main(int ac, char **av)
 
 			TEST_ERROR_LOG(TEST_ERRNO);
 
-			if (TEST_ERRNO == TC[i].error) {
-				tst_resm(TPASS, "expected failure - "
-					 "errno = %d : %s", TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TFAIL, "unexpected error - %d : %s - "
-					 "expected %d", TEST_ERRNO,
-					 strerror(TEST_ERRNO), TC[i].error);
-			}
+			if (TEST_ERRNO == TC[i].error)
+				tst_resm(TPASS|TTERRNO, "failed as expected");
+			else
+				tst_resm(TFAIL|TTERRNO,
+				    "failed unexpectedly; expected %d - %s",
+				    TC[i].error, strerror(TC[i].error));
 		}
 	}
 	cleanup();
@@ -168,14 +162,14 @@ int main(int ac, char **av)
  */
 void help()
 {
+
 	printf("  -D <tty device> : for example, /dev/tty[0-9]\n");
 }
 
 /*
  * setup() - performs all ONE TIME setup for this test.
  */
-void setup()
-{
+void setup(void) {
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
@@ -185,17 +179,16 @@ void setup()
 	tst_tmpdir();
 
 	/* create a temporary file */
-	if ((fd1 = open("x", O_CREAT, 0777)) < 0) {
-		tst_resm(TFAIL, "Could not open test file, errno = %d", errno);
-	}
+	if ((fd1 = open("x", O_CREAT, 0777)) == -1)
+		tst_resm(TFAIL|TERRNO, "Could not open test file");
 }
 
 /*
  * cleanup() - performs all ONE TIME cleanup for this test at
  *	       completion or premature exit.
  */
-void cleanup()
-{
+void cleanup(void) {
+
 	/*
 	 * print timing stats if that option was specified.
 	 * print errno log if that option was specified.
@@ -206,5 +199,4 @@ void cleanup()
 
 	/* delete the test directory created in setup() */
 	tst_rmdir();
-
-}
\ No newline at end of file
+}
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to