1#!/bin/sh 2# 3# Copyright (c) International Business Machines Corp., 2000 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13# the GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18# 19# 20# 21# FILE : ftp 22# 23# PURPOSE: To test the basic functionality of the `ftp` command. 24# 25# SETUP: The home directory of root on the machine exported as "RHOST" 26# MUST have a ".rhosts" file with the hostname of the machine 27# where the test is executed. Also, both machines MUST have 28# the same path configuration for the test for proper test data 29# file transfers. The PASSWD variable should also be set to root's 30# login password. 31# 32# HISTORY: 33# 06/06/03 Manoj Iyer manjo@mail.utexas.edu 34# - Modified to use LTP test harness APIs 35# 03/01 Robbie Williamson (robbiew@us.ibm.com) 36# -Ported 37# 38# 39#----------------------------------------------------------------------- 40# 41#---------------------------------------------------------------------- 42 43#----------------------------------------------------------------------- 44# 45# FUNCTION: do_setup 46# 47#----------------------------------------------------------------------- 48 49do_setup() 50{ 51 52 TC=ftp 53 TCtmp=${TCtmp:-$LTPROOT/$TC${EXEC_SUFFIX}$$} 54 TCdat=${TCdat:-$LTPROOT/datafiles} 55 SLEEPTIME=${SLEEPTIME:-0} 56 ASCII_FILES=${ASCII_FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"} 57 BIN_FILES=${BIN_FILES:-"bin.sm bin.med bin.lg bin.jmb"} 58 59 RHOST=${RHOST:-`hostname`} 60 RUSER=${RUSER:-root} 61 PASSWD=${PASSWD:-.pasroot} 62 63 tst_setup 64 65 exists awk ftp rsh 66 67 cd "$TCtmp" 68 69 rsh -n -l root $RHOST mkdir -p "$TCtmp" 70 rsh -n -l root $RHOST chown -R ${RUSER} "$TCtmp" 71 [ $? = 0 ] || end_testcase "Check .rhosts file on remote machine." 72 73} 74 75#----------------------------------------------------------------------- 76# 77# FUNCTION: do_test 78# 79#----------------------------------------------------------------------- 80 81do_test() 82{ 83 84 for i in binary ascii; do 85 86 if [ $i = "binary" ]; then 87 FILES=$BIN_FILES 88 fi 89 if [ $i = "ascii" ]; then 90 FILES=$ASCII_FILES 91 fi 92 for j in $FILES; do 93 94 for a in get put; do 95 if [ $a = "get" ]; then 96 { 97 echo user $RUSER $PASSWD 98 echo lcd $TCtmp 99 echo $i 100 echo cd $TCdat 101 echo $a $j 102 echo quit 103 } | ftp -nv $RHOST 104 SUM1=`ls -l $TCtmp/$j | awk '{print $5}'` 105 SUM2=`ls -l $TCdat/$j | awk '{print $5}'` 106 rm -f $TCtmp/$j 107 else 108 { 109 echo user $RUSER $PASSWD 110 echo lcd $TCdat 111 echo $i 112 echo cd $TCtmp 113 echo $a $j 114 echo quit 115 } | ftp -nv $RHOST 116 SUM1=`rsh -n -l root $RHOST sum $TCtmp/$j | awk '{print $1}'` 117 SUM2=`sum $TCdat/$j | awk '{print $1}'` 118 rsh -n -l root $RHOST rm -f $TCtmp/$j 119 fi 120 121 if [ $SUM1 = $SUM2 ]; then 122 tst_resm TINFO "Test Successful doing ftp $a $j $i" 123 else 124 end_testcase "Test Fail: Wrong sum while performing ftp $a $j $i" 125 fi 126 sleep $SLEEPTIME 127 done 128 done 129 done 130} 131 132 133#----------------------------------------------------------------------- 134# 135# FUNCTION: do_cleanup 136# 137#----------------------------------------------------------------------- 138 139do_cleanup() 140{ 141 rsh -n -l root $RHOST rmdir "$TCtmp" 142 tst_cleanup 143} 144 145#---------------------------------------------------------------------- 146# FUNCTION: MAIN 147# PURPOSE: To invoke the functions to perform the tasks described in 148# the prologue. 149# INPUT: None. 150# OUTPUT: A testcase run log with the results of the execution of this 151# test. 152#---------------------------------------------------------------------- 153. net_cmdlib.sh 154 155read_opts $* 156do_setup 157do_test 158end_testcase 159