• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-download-stress02-rmt
23TST_TOTAL=1
24
25. test.sh
26
27tst_check_cmds awk killall
28
29server_ipaddr="$1"
30filename="$2"
31filesize="$3"
32duration="$4"
33connect_quantity="$5"
34
35echo $server_ipaddr | grep ':' > /dev/null
36if [ $? -eq 0 ]; then
37	server_ipaddr='['$server_ipaddr']'
38fi
39
40start_epoc=$(date +%s)
41while true ; do
42	# Exit when the specified seconds have passed.
43	current_epoc=$(date +%s)
44	elapse_epoc=$(($current_epoc - $start_epoc))
45	if [ $elapse_epoc -ge $duration ]; then
46		break
47	fi
48
49	# Do not request the file over the specified quantity
50	ftp_num=$(jobs | wc -l)
51	if [ $ftp_num -ge $connect_quantity ]; then
52		sleep 1
53		continue;
54	fi
55
56	# Login to the server
57	curl --noproxy '*' -s -g "ftp://${server_ipaddr}/${filename}" \
58		-o /dev/null &
59done
60
61killall -qw -s SIGPIPE curl
62
63# Download the test file
64out=$(curl --noproxy '*' -sS -g "ftp://$server_ipaddr/$filename" -o /dev/null \
65	-w "time=%{time_total} size=%{size_download} speed=%{speed_download}")
66
67tst_resm TINFO "stat: $out"
68recv_filesize=$(echo "$out" | awk '{print $2}')
69
70if [ "$recv_filesize" != "size=$filesize" ]; then
71	tst_resm TINFO "Expected file size '$filesize'"
72	tst_brkm TBROK "Failed to download ftp://$server_ipaddr/$filename"
73fi
74
75tst_exit
76