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