#!/bin/bash
# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/lftp/Regression/bz358181-disconnect-on-empty-dir-and-sanity
# Description: "lftp" disconnects FTP data connection if remote dir is found empty, and test also need to test some simle functioanlity on vasious file sizes
# Author: Jan Scotka <jscotka@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/share/rhts-library/rhtslib.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="lftp"
ARCH=`arch`
rlJournalStart
rlPhaseStartSetup Setup
rlAssertRpm $PACKAGE || rlDie "Package $PACKAGE not installed"
rlAssertRpm "vsftpd" || rlDie "Package vsftpd not installed"
if rlIsFedora; then
rlRun "TmpDir=$(mktemp -d /var/tmp/ftptmpXXXX)" 0 "Creating fedora tmp directory"
else
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
fi
rlRun "rlFileBackup '/etc/vsftpd/vsftpd.conf'" 0 "Back up vsftpd.conf"
# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=860951#c9
if rlIsRHEL 7 && [ "_$ARCH" = "_x86_64" ]; then
echo -e "\nseccomp_sandbox=NO\n" >> /etc/vsftpd/vsftpd.conf
fi
rlRun 'sed -i s/anonymous_enable=.*/anonymous_enable=YES/ /etc/vsftpd/vsftpd.conf' 0 "Enable anonymous"
rlRun "rlServiceStart vsftpd" 0 "Start vsftpd"
rlPhaseEnd
rlPhaseStartTest Testing
rlAssertExists $TmpDir
rlRun "ls -l $TmpDir" 0 "Listing tmp directory"
FTPDIR=/var/ftp
rlRun "lftp -e 'nlist; quit' localhost" 0 "simple nlist"
rlRun "lftp -e 'cd pub; nlist; quit' localhost" 0 "simple nlist on empty dir"
rlRun "mkdir $FTPDIR/testf" 0 "Create $FTPDIR/testf"
for foo in `seq 2000`; do
echo "filee sss$foo" > $FTPDIR/testf/file$foo
done
dd if=/dev/zero of=$FTPDIR/biggerfile bs=20M count=1
#file size 21* 100M ~ 2.2Gb
dd if=/dev/zero of=$FTPDIR/biggestfile bs=100M count=21
rlRun "pushd $TmpDir" 0 "Get into $TmpDir"
rlRun "lftp -e 'cd testf; mget *; quit' localhost" 0 "2000 small files download"
rlRun "lftp -e 'get biggerfile; quit' localhost" 0 "20M file download"
rlRun "lftp -e 'get biggestfile; quit' localhost" 0 "2^31-1 bytes file download"
rlRun "popd" 0 "Get out of $TmpDir"
rlPhaseEnd
rlPhaseStartCleanup Cleanup
rlRun "rlFileRestore" 0 "Restoring vsftpd.conf"
rlRun "rm -fr $TmpDir $FTPDIR/big* $FTPDIR/testf" 0 "Removing tmp directories"
rlServiceRestore vsftpd
rlPhaseEnd
rlJournalPrintText
rlJournalEnd