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 : rcp 22 # 23 # PURPOSE: To test the basic functionality of the `rcp` 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. 28 # 29 # HISTORY: 30 # 06/06/03 Manoj Iyer manjo (at] mail.utexas.edu 31 # - Modified testcases to use test APIS and fixed bugs 32 # 03/01 Robbie Williamson (robbiew (at] us.ibm.com) 33 # -Ported 34 # 35 # 36 #----------------------------------------------------------------------- 37 38 #----------------------------------------------------------------------- 39 # 40 # FUNCTION: do_setup 41 # 42 #----------------------------------------------------------------------- 43 44 do_setup() 45 { 46 47 TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$} 48 TCdat=${TCdat:-$LTPROOT/testcases/bin/datafiles} 49 LHOST=`hostname` 50 RHOST=${RHOST:-$LHOST} 51 SLEEPTIME=${SLEEPTIME:-0} 52 FILES=${FILES:-"bin.sm bin.med bin.lg bin.jmb"} 53 54 tst_setup 55 56 exists awk rcp rsh sum 57 58 if ! rsh -n -l root $RHOST mkdir -p $TCtmp >/dev/null 2>&1; then 59 end_testcase "Remote mkdir failed" 60 fi 61 62 trap do_cleanup EXIT 63 64 } 65 66 #----------------------------------------------------------------------- 67 # 68 # FUNCTION: do_test 69 # 70 #----------------------------------------------------------------------- 71 72 do_test() 73 { 74 75 for j in $FILES; do 76 77 if ! rcp $TCdat/$j $RHOST:$TCtmp/$j; then 78 end_testcase "Failed to rcp file." 79 fi 80 81 SUM1=`sum $TCdat/$j | awk '{print $1}'` 82 SUM2=`rsh -n -l root $RHOST sum $TCtmp/$j | awk '{print $1}'` 83 rsh -n -l root $RHOST "rm -f $TCtmp/$j" 84 sleep $SLEEPTIME 85 86 if [ "$SUM1" = "$SUM2" ]; then 87 tst_resm TINFO "rcp $TCdat/$j $RHOST:$TCtmp/$j successful" 88 else 89 end_testcase "FAILED: wrong sum in transfer to $RHOST" 90 fi 91 92 sleep $SLEEPTIME 93 94 done 95 96 for j in $FILES; do 97 98 tst_resm TINFO "remote copying $RHOST:$TCdat/$j to $TCtmp/$j" 99 if ! rcp $RHOST:$TCdat/$j $TCtmp/$j >/dev/null 2>&1; then 100 tst_resm TFAIL "Failed to rcp file."; continue 101 fi 102 103 SUM1=`sum $TCtmp/$j | awk '{print $1}'` 104 SUM2=`rsh -n -l root $RHOST sum $TCdat/$j | awk '{print $1}'` 105 rm -f $TCtmp/$j 106 sleep $SLEEPTIME 107 108 if [ "$SUM1" = "$SUM2" ]; then 109 tst_resm TINFO "rcp $RHOST:$TCdat/$j $TCtmp/$j successful" 110 else 111 end_testcase "FAILED: wrong sum in transfer to $LHOST from $RHOST" 112 fi 113 sleep $SLEEPTIME 114 115 done 116 117 } 118 119 #----------------------------------------------------------------------- 120 # 121 # FUNCTION: do_cleanup 122 # 123 #----------------------------------------------------------------------- 124 125 do_cleanup() 126 { 127 rsh -n -l root $RHOST rmdir $TCtmp 128 tst_cleanup 129 } 130 131 #---------------------------------------------------------------------- 132 # FUNCTION: MAIN 133 # PURPOSE: To invoke the functions to perform the tasks described in 134 # the prologue. 135 # INPUT: None. 136 # OUTPUT: A testcase run log with the results of the execution of this 137 # test. 138 #---------------------------------------------------------------------- 139 . net_cmdlib.sh 140 141 read_opts $* 142 do_setup 143 do_test 144 end_testcase 145