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