This patch consists of the files
ch_ftp.sh - Starts the ftp from the child NS
container_ftp.pl - Handles the mechanism of logging and doing the ftp
par_chld_ftp.c - Basic program to test the ftp between parent and child ns
par_ftp.sh - Establishes the connection between parent NS and child NS.
Signed-off-by: Veerendra C <[EMAIL PROTECTED]>
Index: containers/netns/ch_ftp.sh
===================================================================
--- /dev/null
+++ containers/netns/ch_ftp.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# This script checks that the parent namespace is reachable from the child
+TCID=${TCID:-ch_ftp.sh}
+TST_TOTAL=1
+TST_COUNT=1
+export TCID
+export TST_COUNT
+export TST_TOTAL
+
+ ping -q -c 2 $IP1 > /dev/null
+ if [ $? -ne 0 ] ; then
+ tst_resm TFAIL "Pinging parent NS from child : FAIL"
+ status=-1
+ else
+ debug "INFO: Pinging parent NS from child "
+ eval ./container_ftp.pl $IP1
+ status=$?
+ if [ $status -ne 0 ] ; then
+ tst_resm TFAIL "ftp failed"
+ status=1
+ fi
+ fi
+ echo $status > /tmp/FIFO6
Index: containers/netns/container_ftp.pl
===================================================================
--- /dev/null
+++ containers/netns/container_ftp.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+use Net::FTP;
+
+my $host = $ARGV[0];
+
+my $newname;
+my $i = 0;
+my $kount = 51;
+my $file="junkfile";
+my $dir="/tmp/ftpdir";
+
+mkdir $dir;
+chdir $dir;
+system("dd if=/dev/zero of=$putdir$file bs=512 count=10 > /dev/null 2>&1 ");
+
+while ( $i < $kount )
+{
+ $ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1;
+ push @ERRORS, "Can't ftp to $host: $!\n" if $newerr;
+ printerr() if $newerr;
+
+ $ftp->login("anonymous","passwd") or $newerr=1;
+ push @ERRORS, "Can't login to $host: $!\n" if $newerr;
+ $ftp->quit if $newerr;
+ printerr() if $newerr;
+
+ $ftp->cwd($dir) or $newerr=1;
+ push @ERRORS, "Can't cd $!\n" if $newerr;
+ $ftp->quit if $newerr;
+ printerr() if $newerr;
+
+ $newname = $file . "_" . $i ;
+ $ftp->put($file,$newname) or $newerr=1;
+ push @ERRORS, "Can't get file $file $!\n" if $newerr;
+ printerr() if $newerr;
+
+ $i++;
+ $ftp->quit;
+}
+system("rm -rf $dir");
+exit 0;
+
+sub printerr {
+ print "Error: ";
+ print @ERRORS;
+ exit -1;
+}
Index: containers/netns/par_chld_ftp.c
===================================================================
--- /dev/null
+++ containers/netns/par_chld_ftp.c
@@ -0,0 +1,36 @@
+/*************************************************************************
+* Copyright (c) International Business Machines Corp., 2008
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+* the GNU General Public License for more details.
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*
+***************************************************************************/
+/* ============================================================================
+* This testcase uses the libnetns.c from the library to create network NS.
+* In libnetns.c it uses 2 scripts parentns.sh and childns.sh to create this.
+* After creating the NS, this program verifies that the network is reachable
+* from parent-NS to child-NS and vice-versa.
+*
+* Scripts Used: parentns.sh, childns.sh, par_ftp.sh , ch_ftp.sh container_ftp.pl
+*
+* Author: Veerendra C <[EMAIL PROTECTED]>
+* 31/07/2008
+* =============================================================================*/
+
+extern int create_net_namespace(char *, char *);
+
+int main()
+{
+ int status;
+ status = create_net_namespace("par_ftp.sh", "ch_ftp.sh");
+ return status;
+}
Index: containers/netns/par_ftp.sh
===================================================================
--- /dev/null
+++ containers/netns/par_ftp.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# This script checks whether child NS is reachable from parent NS.
+#set -x
+
+# The test case ID, the test case count and the total number of test case
+TCID=${TCID:-par_ftp.sh}
+TST_TOTAL=1
+TST_COUNT=1
+export TCID
+export TST_COUNT
+export TST_TOTAL
+
+ ping -q -c 2 $IP2 > /dev/null
+
+ if [ $? == 0 ] ; then
+ tst_resm TINFO "Pinging ChildNS from ParentNS"
+ else
+ tst_resm TFAIL "Error: Unable to ping ChildNS from ParentNS"
+ status=-1
+ fi
+ stat=`cat /tmp/FIFO6`
+ if [ $stat != 0 ] ; then
+ status=$stat
+ fi
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list