108 lines
3.9 KiB
Bash
Executable file
108 lines
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#
|
|
# runtest.sh of /CoreOS/php/misc/phpinfo
|
|
# Description: Simple test for phpinfo()
|
|
# Author: David Kutalek <dkutalek@redhat.com>
|
|
#
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#
|
|
# Copyright (c) 2013 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 Beaker environment
|
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
|
|
|
# Packages to be tested
|
|
PACKAGES=${PACKAGES:-php php-cli}
|
|
# Other required packages
|
|
REQUIRES=${REQUIRES:-httpd perl curl}
|
|
|
|
# Use php-fpm instead of mod_php on RHEL8 and later
|
|
rlIsRHEL "<=7" && phpUsePhpFpm="no"
|
|
|
|
REPRODUCER="info.php"
|
|
URL="http://localhost/$REPRODUCER"
|
|
TESTDIR=$(pwd)
|
|
|
|
set -o pipefail
|
|
|
|
rlJournalStart
|
|
rlPhaseStartSetup
|
|
rlRun "rlImport httpd/http" 0 "Import httpd library"
|
|
rlImport "php/utils"
|
|
rlAssertRpm --all
|
|
|
|
phpPopulateSources # needed for phpAssertFileOrigin
|
|
phpMainPackage
|
|
if [ "$phpUsePhpFpm" == 'no' ]; then
|
|
phpChooseModPhpConfig
|
|
else
|
|
PHP_FPM_RPM=$(rpm -qf $(which php-fpm) --qf '%{NAME}')
|
|
rlServiceStart "$PHP_FPM_RPM"
|
|
fi
|
|
|
|
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
|
rlRun "cp $REPRODUCER ${httpROOTDIR}"
|
|
rlRun "pushd $TmpDir"
|
|
|
|
rlRun "httpStart" 0 "Start httpd"
|
|
|
|
if [ "$phpUsePhpFpm" == "no" ]; then
|
|
phpAssertModPhpLoaded
|
|
phpAssertFileOrigin $(phpPrintLoadedModPhpLibs)
|
|
php_lib=$(phpPrintLoadedModPhpLibs | grep '\/libphp\|fileinfo.so$' | head -1)
|
|
else
|
|
phpAssertFileOrigin $(phpPrintLoadedPhpFpmLibs)
|
|
php_lib=$(phpPrintLoadedPhpFpmLibs | grep '\/libphp\|fileinfo.so$' | head -1)
|
|
fi
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartTest "php-cli"
|
|
# Test that the phpinfo() function has produced some useful output
|
|
rlRun "php $TESTDIR/$REPRODUCER | sed -n '/PHP Version/{s/.*Version[^0-9]*\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/;p;}' | head -1 | tee output" 0
|
|
rlRun "rpm -q --qf '%{version}\n' $(rpm -qf $(which php)) | sed 1q | tee rpmoutput" 0
|
|
rlAssertNotDiffer output rpmoutput
|
|
rlPhaseEnd
|
|
|
|
if [ -n "$phpUsePhpFpm" ]; then
|
|
rlPhaseStartTest "mod_php"
|
|
else
|
|
rlPhaseStartTest "php-fpm"
|
|
fi
|
|
# Test that the phpinfo() function has produced some useful output
|
|
rlRun "curl $URL | sed -n '/PHP Version/{s/.*Version[^0-9]*\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/;p;}' | head -1 | tee curloutput" 0
|
|
rlRun "rpm -q --qf '%{version}\n' $(rpm -qf $php_BIN) | sed 1q | tee rpmoutput" 0
|
|
rlRun "rpm -q --qf '%{version}\n' $(rpm -qf $php_lib) | sed 1q | tee rpmoutput2" 0
|
|
rlAssertNotDiffer curloutput rpmoutput
|
|
rlAssertNotDiffer curloutput rpmoutput2
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartCleanup
|
|
rlRun "rm ${httpROOTDIR}/$REPRODUCER"
|
|
rlFileRestore
|
|
if [ -n "$phpUsePhpFpm" ]; then
|
|
rlServiceRestore "$PHP_FPM_RPM"
|
|
fi
|
|
rlRun "httpStop" 0 "Stop httpd"
|
|
rlRun "popd"
|
|
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
rlPhaseEnd
|
|
rlJournalPrintText
|
|
rlJournalEnd
|