ftp-upload-stress01-rmt.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
  3. # Copyright (c) International Business Machines Corp., 2005
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2 of
  8. # the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it would be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # 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 the Free Software Foundation,
  17. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. # Author: Mitsuru Chinen <mitch@jp.ibm.com>
  20. TCID=ftp-upload-stress01-rmt
  21. TST_TOTAL=1
  22. TST_CLEANUP="cleanup"
  23. . test.sh
  24. server_ipaddr="$1"
  25. urldir="$2"
  26. filename="$3"
  27. filesize="$4"
  28. tst_require_cmds curl
  29. cleanup()
  30. {
  31. rm -f $filename
  32. }
  33. echo $server_ipaddr | grep ':' > /dev/null
  34. if [ $? -eq 0 ]; then
  35. server_ipaddr='['$server_ipaddr']'
  36. fi
  37. # Create a file to upload
  38. echo -n "A" > $filename
  39. echo -n "Z" | dd of=$filename bs=1 seek=$(($filesize - 1)) > /dev/null 2>&1 || \
  40. tst_brkm TBROK "Failed to create $filename"
  41. out=$(curl --noproxy '*' -sS -u anonymous:ftp@ltp-ns.org -T $filename \
  42. -g "ftp://$server_ipaddr/$urldir/" \
  43. -w "time=%{time_total} size=%{size_upload} speed=%{speed_upload}")
  44. tst_resm TINFO "stat: $out"
  45. send_filesize=$(echo "$out" | awk '{print $2}')
  46. if [ "$send_filesize" != "size=$filesize" ]; then
  47. tst_resm TINFO "Expected file size '$filesize'"
  48. tst_brkm TBROK "Failed to upload to ftp://$server_ipaddr/$urldir/"
  49. fi
  50. tst_exit