ftp-download-stress01-rmt.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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-download-stress01-rmt
  21. TST_TOTAL=1
  22. . test.sh
  23. server_ipaddr="$1"
  24. filename="$2"
  25. filesize="$3"
  26. tst_require_cmds curl
  27. echo $server_ipaddr | grep ':' > /dev/null
  28. if [ $? -eq 0 ]; then
  29. server_ipaddr='['$server_ipaddr']'
  30. fi
  31. # Download the test file
  32. out=$(curl --noproxy '*' -sS -g "ftp://$server_ipaddr/$filename" -o /dev/null \
  33. -w "time=%{time_total} size=%{size_download} speed=%{speed_download}")
  34. tst_resm TINFO "stat: $out"
  35. recv_filesize=$(echo "$out" | awk '{print $2}')
  36. if [ "$recv_filesize" != "size=$filesize" ]; then
  37. tst_resm TINFO "Expected file size '$filesize'"
  38. tst_brkm TBROK "Failed to download ftp://$server_ipaddr/$filename"
  39. fi
  40. tst_exit