1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci 3f08c3bdfSopenharmony_ci# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 4f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2005 5f08c3bdfSopenharmony_ci# 6f08c3bdfSopenharmony_ci# This program is free software; you can redistribute it and/or 7f08c3bdfSopenharmony_ci# modify it under the terms of the GNU General Public License as 8f08c3bdfSopenharmony_ci# published by the Free Software Foundation; either version 2 of 9f08c3bdfSopenharmony_ci# the License, or (at your option) any later version. 10f08c3bdfSopenharmony_ci# 11f08c3bdfSopenharmony_ci# This program is distributed in the hope that it would be useful, 12f08c3bdfSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 13f08c3bdfSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14f08c3bdfSopenharmony_ci# GNU General Public License for more details. 15f08c3bdfSopenharmony_ci# 16f08c3bdfSopenharmony_ci# You should have received a copy of the GNU General Public License 17f08c3bdfSopenharmony_ci# along with this program; if not, write the Free Software Foundation, 18f08c3bdfSopenharmony_ci# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19f08c3bdfSopenharmony_ci# 20f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ciTCID=ftp-upload-stress02-rmt 23f08c3bdfSopenharmony_ciTST_TOTAL=1 24f08c3bdfSopenharmony_ciTST_CLEANUP="cleanup" 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci. test.sh 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_citst_require_cmds killall 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ciserver_ipaddr="$1" 31f08c3bdfSopenharmony_ciurldir="$2" 32f08c3bdfSopenharmony_cifilename="$3" 33f08c3bdfSopenharmony_cifilesize="$4" 34f08c3bdfSopenharmony_ciduration="$5" 35f08c3bdfSopenharmony_ciclient_num="$6" 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_cicleanup() 38f08c3bdfSopenharmony_ci{ 39f08c3bdfSopenharmony_ci rm -f $filename 40f08c3bdfSopenharmony_ci} 41f08c3bdfSopenharmony_ci 42f08c3bdfSopenharmony_ciecho $server_ipaddr | grep ':' > /dev/null 43f08c3bdfSopenharmony_ciif [ $? -eq 0 ]; then 44f08c3bdfSopenharmony_ci server_ipaddr='['$server_ipaddr']' 45f08c3bdfSopenharmony_cifi 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci# Create a file to upload 48f08c3bdfSopenharmony_ciecho -n "A" > $filename 49f08c3bdfSopenharmony_ciecho -n "Z" | dd of=$filename bs=1 seek=$(($filesize - 1)) > /dev/null 2>&1 || \ 50f08c3bdfSopenharmony_ci tst_brkm TBROK "Failed to create $filename" 51f08c3bdfSopenharmony_ci 52f08c3bdfSopenharmony_cistart_epoc=$(date +%s) 53f08c3bdfSopenharmony_ciwhile true ; do 54f08c3bdfSopenharmony_ci # Exit when the specified seconds have passed. 55f08c3bdfSopenharmony_ci current_epoc=$(date +%s) 56f08c3bdfSopenharmony_ci elapse_epoc=$(($current_epoc - $start_epoc)) 57f08c3bdfSopenharmony_ci if [ $elapse_epoc -ge $duration ]; then 58f08c3bdfSopenharmony_ci break 59f08c3bdfSopenharmony_ci fi 60f08c3bdfSopenharmony_ci 61f08c3bdfSopenharmony_ci num=0 62f08c3bdfSopenharmony_ci while [ $num -lt $client_num ]; do 63f08c3bdfSopenharmony_ci ps auxw | grep -l -- "curl.*${filename}${num}" >/dev/null 2>&1 64f08c3bdfSopenharmony_ci if [ $? -eq 0 ]; then 65f08c3bdfSopenharmony_ci num=$(($num + 1)) 66f08c3bdfSopenharmony_ci continue 67f08c3bdfSopenharmony_ci fi 68f08c3bdfSopenharmony_ci curl -s --noproxy '*' -u anonymous:ftp@ltp-ns.org -T $filename \ 69f08c3bdfSopenharmony_ci -g "ftp://${server_ipaddr}/${urldir}/${filename}${num}" & 70f08c3bdfSopenharmony_ci num=$(($num + 1)) 71f08c3bdfSopenharmony_ci done 72f08c3bdfSopenharmony_cidone 73f08c3bdfSopenharmony_ci 74f08c3bdfSopenharmony_cikillall -qw -s SIGPIPE curl 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_ciout=$(curl --noproxy '*' -sS -u anonymous:ftp@ltp-ns.org -T $filename \ 77f08c3bdfSopenharmony_ci -g "ftp://$server_ipaddr/$urldir/" \ 78f08c3bdfSopenharmony_ci -w "time=%{time_total} size=%{size_upload} speed=%{speed_upload}") 79f08c3bdfSopenharmony_ci 80f08c3bdfSopenharmony_citst_resm TINFO "stat: $out" 81f08c3bdfSopenharmony_cisend_filesize=$(echo "$out" | awk '{print $2}') 82f08c3bdfSopenharmony_ci 83f08c3bdfSopenharmony_ciif [ "$send_filesize" != "size=$filesize" ]; then 84f08c3bdfSopenharmony_ci tst_resm TINFO "Expected file size '$filesize'" 85f08c3bdfSopenharmony_ci tst_brkm TBROK "Failed to upload to ftp://$server_ipaddr/$urldir/" 86f08c3bdfSopenharmony_cifi 87f08c3bdfSopenharmony_ci 88f08c3bdfSopenharmony_citst_exit 89