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-download-stress01-rmt
23f08c3bdfSopenharmony_ciTST_TOTAL=1
24f08c3bdfSopenharmony_ci
25f08c3bdfSopenharmony_ci. test.sh
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ciserver_ipaddr="$1"
28f08c3bdfSopenharmony_cifilename="$2"
29f08c3bdfSopenharmony_cifilesize="$3"
30f08c3bdfSopenharmony_ci
31f08c3bdfSopenharmony_citst_require_cmds curl
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_ciecho $server_ipaddr | grep ':' > /dev/null
34f08c3bdfSopenharmony_ciif [ $? -eq 0 ]; then
35f08c3bdfSopenharmony_ci	server_ipaddr='['$server_ipaddr']'
36f08c3bdfSopenharmony_cifi
37f08c3bdfSopenharmony_ci
38f08c3bdfSopenharmony_ci# Download the test file
39f08c3bdfSopenharmony_ciout=$(curl --noproxy '*' -sS -g "ftp://$server_ipaddr/$filename" -o /dev/null \
40f08c3bdfSopenharmony_ci	-w "time=%{time_total} size=%{size_download} speed=%{speed_download}")
41f08c3bdfSopenharmony_ci
42f08c3bdfSopenharmony_citst_resm TINFO "stat: $out"
43f08c3bdfSopenharmony_cirecv_filesize=$(echo "$out" | awk '{print $2}')
44f08c3bdfSopenharmony_ci
45f08c3bdfSopenharmony_ciif [ "$recv_filesize" != "size=$filesize" ]; then
46f08c3bdfSopenharmony_ci	tst_resm TINFO "Expected file size '$filesize'"
47f08c3bdfSopenharmony_ci	tst_brkm TBROK "Failed to download ftp://$server_ipaddr/$filename"
48f08c3bdfSopenharmony_cifi
49f08c3bdfSopenharmony_ci
50f08c3bdfSopenharmony_citst_exit
51