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-stress01-rmt 23f08c3bdfSopenharmony_ciTST_TOTAL=1 24f08c3bdfSopenharmony_ciTST_CLEANUP="cleanup" 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci. test.sh 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ciserver_ipaddr="$1" 29f08c3bdfSopenharmony_ciurldir="$2" 30f08c3bdfSopenharmony_cifilename="$3" 31f08c3bdfSopenharmony_cifilesize="$4" 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_citst_require_cmds curl 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_cicleanup() 36f08c3bdfSopenharmony_ci{ 37f08c3bdfSopenharmony_ci rm -f $filename 38f08c3bdfSopenharmony_ci} 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_ciecho $server_ipaddr | grep ':' > /dev/null 41f08c3bdfSopenharmony_ciif [ $? -eq 0 ]; then 42f08c3bdfSopenharmony_ci server_ipaddr='['$server_ipaddr']' 43f08c3bdfSopenharmony_cifi 44f08c3bdfSopenharmony_ci 45f08c3bdfSopenharmony_ci# Create a file to upload 46f08c3bdfSopenharmony_ciecho -n "A" > $filename 47f08c3bdfSopenharmony_ciecho -n "Z" | dd of=$filename bs=1 seek=$(($filesize - 1)) > /dev/null 2>&1 || \ 48f08c3bdfSopenharmony_ci tst_brkm TBROK "Failed to create $filename" 49f08c3bdfSopenharmony_ci 50f08c3bdfSopenharmony_ciout=$(curl --noproxy '*' -sS -u anonymous:ftp@ltp-ns.org -T $filename \ 51f08c3bdfSopenharmony_ci -g "ftp://$server_ipaddr/$urldir/" \ 52f08c3bdfSopenharmony_ci -w "time=%{time_total} size=%{size_upload} speed=%{speed_upload}") 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_citst_resm TINFO "stat: $out" 55f08c3bdfSopenharmony_cisend_filesize=$(echo "$out" | awk '{print $2}') 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ciif [ "$send_filesize" != "size=$filesize" ]; then 58f08c3bdfSopenharmony_ci tst_resm TINFO "Expected file size '$filesize'" 59f08c3bdfSopenharmony_ci tst_brkm TBROK "Failed to upload to ftp://$server_ipaddr/$urldir/" 60f08c3bdfSopenharmony_cifi 61f08c3bdfSopenharmony_ci 62f08c3bdfSopenharmony_citst_exit 63