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 <[email protected]> 21 22TCID=ftp-download-stress 23TST_TOTAL=2 24TST_CLEANUP="cleanup" 25 26TST_USE_LEGACY_API=1 27 28# Big file size to upload/download in ftp tests (byte) 29DOWNLOAD_BIGFILESIZE=${DOWNLOAD_BIGFILESIZE:-2147483647} 30# Regular file size to upload/download in ftp tests (byte) 31DOWNLOAD_REGFILESIZE=${DOWNLOAD_REGFILESIZE:-1048576} 32 33cleanup() 34{ 35 rm -f $FTP_DOWNLOAD_DIR/ftp_file* 36 rm -f $FTP_DOWNLOAD_DIR/ftp_reg_file* 37 tst_rmdir 38 pkill vsftpd 39} 40 41setup() 42{ 43 tst_require_root 44 tst_require_cmds pkill vsftpd 45 tst_tmpdir 46 47 tst_resm TINFO "run FTP over IPv$TST_IPVER" 48 49 trap "tst_brkm TBROK 'test interrupted'" INT 50 51 [ "$FTP_DOWNLOAD_DIR" ] || \ 52 tst_brkm TCONF "Start ftp server and set FTP_DOWNLOAD_DIR var" 53 54 tst_resm TINFO "restart vsftpd with custom options" 55 pkill vsftpd 56 touch vsftpd.conf 57 58 local ip_opt="-olisten=YES -olisten_ipv6=NO" 59 [ $TST_IPV6 ] && ip_opt="-olisten=NO -olisten_ipv6=YES" 60 61 vsftpd $ip_opt -oanonymous_enable=YES vsftpd.conf 62} 63 64test01() 65{ 66 tst_resm TINFO "download file with size '$DOWNLOAD_BIGFILESIZE'" 67 68 create_file $FTP_DOWNLOAD_DIR/ftp_file $DOWNLOAD_BIGFILESIZE || \ 69 tst_resm TBROK "Failed to create test file" 70 71 # Run the script at the remote host 72 tst_rhost_run -s -c "ftp-download-stress01-rmt.sh \ 73 $(tst_ipaddr) ftp_file $DOWNLOAD_BIGFILESIZE" 74 75 tst_resm TPASS "Test is finished successfully" 76} 77 78test02() 79{ 80 tst_resm TINFO "Download data asynchronously in $NS_DURATION sec" 81 82 create_file $FTP_DOWNLOAD_DIR/ftp_reg_file $DOWNLOAD_REGFILESIZE || \ 83 tst_resm TBROK "Failed to create test file" 84 85 tst_rhost_run -s -c "ftp-download-stress02-rmt.sh $(tst_ipaddr) \ 86 ftp_reg_file $DOWNLOAD_REGFILESIZE \ 87 $NS_DURATION $CONNECTION_TOTAL" 88 89 tst_resm TPASS "Test is finished successfully" 90} 91 92. tst_net.sh 93setup 94test01 95test02 96tst_exit 97