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@jp.ibm.com> 21 22TCID=ftp-upload-stress02-rmt 23TST_TOTAL=1 24TST_CLEANUP="cleanup" 25 26. test.sh 27 28tst_test_cmds killall 29 30server_ipaddr="$1" 31urldir="$2" 32filename="$3" 33filesize="$4" 34duration="$5" 35client_num="$6" 36 37cleanup() 38{ 39 rm -f $filename 40} 41 42echo $server_ipaddr | grep ':' > /dev/null 43if [ $? -eq 0 ]; then 44 server_ipaddr='['$server_ipaddr']' 45fi 46 47# Create a file to upload 48echo -n "A" > $filename 49echo -n "Z" | dd of=$filename bs=1 seek=$(($filesize - 1)) > /dev/null 2>&1 || \ 50 tst_brkm TBROK "Failed to create $filename" 51 52start_epoc=$(date +%s) 53while true ; do 54 # Exit when the specified seconds have passed. 55 current_epoc=$(date +%s) 56 elapse_epoc=$(($current_epoc - $start_epoc)) 57 if [ $elapse_epoc -ge $duration ]; then 58 break 59 fi 60 61 num=0 62 while [ $num -lt $client_num ]; do 63 ps auxw | grep -l -- "curl.*${filename}${num}" >/dev/null 2>&1 64 if [ $? -eq 0 ]; then 65 num=$(($num + 1)) 66 continue 67 fi 68 curl -s --noproxy '*' -u anonymous:ftp@ltp-ns.org -T $filename \ 69 -g "ftp://${server_ipaddr}/${urldir}/${filename}${num}" & 70 num=$(($num + 1)) 71 done 72done 73 74killall -qw -s SIGPIPE curl 75 76out=$(curl --noproxy '*' -sS -u anonymous:ftp@ltp-ns.org -T $filename \ 77 -g "ftp://$server_ipaddr/$urldir/" \ 78 -w "time=%{time_total} size=%{size_upload} speed=%{speed_upload}") 79 80tst_resm TINFO "stat: $out" 81send_filesize=$(echo "$out" | awk '{print $2}') 82 83if [ "$send_filesize" != "size=$filesize" ]; then 84 tst_resm TINFO "Expected file size '$filesize'" 85 tst_brkm TBROK "Failed to upload to ftp://$server_ipaddr/$urldir/" 86fi 87 88tst_exit 89