ftp01.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. # FUNCTION: do_setup
  45. #
  46. #-----------------------------------------------------------------------
  47. do_setup()
  48. {
  49. TC=ftp
  50. TCtmp=${TCtmp:-$LTPROOT/$TC${EXEC_SUFFIX}$$}
  51. TCdat=${TCdat:-$LTPROOT/datafiles}
  52. SLEEPTIME=${SLEEPTIME:-0}
  53. ASCII_FILES=${ASCII_FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
  54. BIN_FILES=${BIN_FILES:-"bin.sm bin.med bin.lg bin.jmb"}
  55. RHOST=${RHOST:-`hostname`}
  56. RUSER=${RUSER:-root}
  57. PASSWD=${PASSWD:-.pasroot}
  58. tst_setup
  59. exists awk ftp rsh
  60. cd "$TCtmp"
  61. rsh -n -l root $RHOST mkdir -p "$TCtmp"
  62. rsh -n -l root $RHOST chown -R ${RUSER} "$TCtmp"
  63. [ $? = 0 ] || end_testcase "Check .rhosts file on remote machine."
  64. }
  65. #-----------------------------------------------------------------------
  66. #
  67. # FUNCTION: do_test
  68. #
  69. #-----------------------------------------------------------------------
  70. do_test()
  71. {
  72. for i in binary ascii; do
  73. if [ $i = "binary" ]; then
  74. FILES=$BIN_FILES
  75. fi
  76. if [ $i = "ascii" ]; then
  77. FILES=$ASCII_FILES
  78. fi
  79. for j in $FILES; do
  80. for a in get put; do
  81. if [ $a = "get" ]; then
  82. {
  83. echo user $RUSER $PASSWD
  84. echo lcd $TCtmp
  85. echo $i
  86. echo cd $TCdat
  87. echo $a $j
  88. echo quit
  89. } | ftp -nv $RHOST
  90. SUM1=`ls -l $TCtmp/$j | awk '{print $5}'`
  91. SUM2=`ls -l $TCdat/$j | awk '{print $5}'`
  92. rm -f $TCtmp/$j
  93. else
  94. {
  95. echo user $RUSER $PASSWD
  96. echo lcd $TCdat
  97. echo $i
  98. echo cd $TCtmp
  99. echo $a $j
  100. echo quit
  101. } | ftp -nv $RHOST
  102. SUM1=`rsh -n -l root $RHOST sum $TCtmp/$j | awk '{print $1}'`
  103. SUM2=`sum $TCdat/$j | awk '{print $1}'`
  104. rsh -n -l root $RHOST rm -f $TCtmp/$j
  105. fi
  106. if [ $SUM1 = $SUM2 ]; then
  107. tst_resm TINFO "Test Successful doing ftp $a $j $i"
  108. else
  109. end_testcase "Test Fail: Wrong sum while performing ftp $a $j $i"
  110. fi
  111. sleep $SLEEPTIME
  112. done
  113. done
  114. done
  115. }
  116. #-----------------------------------------------------------------------
  117. #
  118. # FUNCTION: do_cleanup
  119. #
  120. #-----------------------------------------------------------------------
  121. do_cleanup()
  122. {
  123. rsh -n -l root $RHOST rmdir "$TCtmp"
  124. tst_cleanup
  125. }
  126. #----------------------------------------------------------------------
  127. # FUNCTION: MAIN
  128. # PURPOSE: To invoke the functions to perform the tasks described in
  129. # the prologue.
  130. # INPUT: None.
  131. # OUTPUT: A testcase run log with the results of the execution of this
  132. # test.
  133. #----------------------------------------------------------------------
  134. . net_cmdlib.sh
  135. read_opts $*
  136. do_setup
  137. do_test
  138. end_testcase