diff --git a/core/phpinfo/TC#0058630.fmf b/core/phpinfo/TC#0058630.fmf new file mode 100644 index 0000000..2f4d4d9 --- /dev/null +++ b/core/phpinfo/TC#0058630.fmf @@ -0,0 +1,17 @@ +component: +- php +contact: Jakub Heger +extra-nitrate: TC#0058630 +extra-pepa: | + PACKAGES='php php-cli' component/php + REQUIRES='httpd perl curl' component/php +extra-summary: /CoreOS/php/misc/phpinfo +relevancy: | + distro = rhel-4, rhel-5, rhel-6: False +tag: +- HttpdSclDone +- NoModularTier +- TIPfail_Security +- TIPpass_Apps +- TestParametrized +- Tier1 diff --git a/core/phpinfo/info.php b/core/phpinfo/info.php new file mode 100644 index 0000000..c9f5eeb --- /dev/null +++ b/core/phpinfo/info.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/core/phpinfo/main.fmf b/core/phpinfo/main.fmf new file mode 100644 index 0000000..84a7d0f --- /dev/null +++ b/core/phpinfo/main.fmf @@ -0,0 +1,22 @@ +component: +- php +description: '' +duration: 5m +enabled: true +extra-task: /CoreOS/php/misc/phpinfo +require: +- php +- php-fpm +- php-cli +- perl +- perl-interpreter +- curl +- httpd +- httpd +- curl +- sed +- grep +- library(php/utils) +- library(httpd/http) +summary: Simple test for phpinfo() +test: ./runtest.sh diff --git a/core/phpinfo/runtest.sh b/core/phpinfo/runtest.sh new file mode 100755 index 0000000..53e1229 --- /dev/null +++ b/core/phpinfo/runtest.sh @@ -0,0 +1,109 @@ +#!/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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/bin/rhts-environment.sh || exit 1 +. /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