From d586295a07c34e5285b3362e568c562eb49c147e Mon Sep 17 00:00:00 2001 From: Frantisek Hrdina Date: Thu, 7 Apr 2022 11:00:07 +0200 Subject: [PATCH] Adding upstream-scripttests --- Sanity/upstream-scripttests/main.fmf | 53 +++++++++ Sanity/upstream-scripttests/runtest.sh | 152 +++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 Sanity/upstream-scripttests/main.fmf create mode 100755 Sanity/upstream-scripttests/runtest.sh diff --git a/Sanity/upstream-scripttests/main.fmf b/Sanity/upstream-scripttests/main.fmf new file mode 100644 index 0000000..1730316 --- /dev/null +++ b/Sanity/upstream-scripttests/main.fmf @@ -0,0 +1,53 @@ +summary: Runs upstream script tests +description: '' +contact: fhrdina@redhat.com +component: +- vim +test: ./runtest.sh +framework: beakerlib +recommend: +- vim-enhanced +- rpm-build +- gcc +- Xvfb +- python3 +- python3-devel +- ruby +- ruby-devel +- lua-devel +- gpm-devel +- perl-ExtUtils-Embed +- libacl-devel +- libXpm-devel +- ncurses-devel +- perl-devel +- perl +- perl-generators +- python3-dnf-plugins-core +duration: 40m +enabled: true +tag: +- NoRHEL4 +- NoRHEL5 +- NoRHEL6 +- TIPfail_infra +- TIPpass +- Tier1 +tier: '1' +adjust: +- enabled: false + when: distro == rhel-4, rhel-5 + continue: false +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2004974 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011389 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011424 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011429 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011749 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011412 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2002320 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2004976 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2015517 +extra-nitrate: TC#0602359 +extra-summary: /CoreOS/vim/Sanity/upstream-scripttests +extra-task: /CoreOS/vim/Sanity/upstream-scripttests diff --git a/Sanity/upstream-scripttests/runtest.sh b/Sanity/upstream-scripttests/runtest.sh new file mode 100755 index 0000000..48a8099 --- /dev/null +++ b/Sanity/upstream-scripttests/runtest.sh @@ -0,0 +1,152 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/vim/Sanity/upstream-scripttests +# Description: Runs upstream scripttests +# Authors: Zdenek Dohnal +# Patrik Mosko +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# 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, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="vim-enhanced" # tested package +TESTER="vimtester" # USERname which we use for testing +TEST=scripttests # main target for `make` +SET_XVFB="NO" # Do we want to setup `Xvfb` before testing? +TERM_type="xterm" # terminfo type set before running tests +set -o pipefail # because test output is piped to `tee` + +if rlIsRHEL 8 +then + CONFOPT="--build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-features=huge --enable-python3interp=dynamic --enable-perlinterp=dynamic --disable-tclinterp --with-x=no --enable-gui=no --enable-multibyte --enable-cscope --with-tlib=ncurses --enable-fips-warning --enable-netbeans --enable-rubyinterp=dynamic --enable-luainterp=dynamic" +elif rlIsRHEL 9 +then + CONFOPT="--build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-features=huge --enable-python3interp=dynamic --enable-perlinterp=dynamic --disable-tclinterp --with-x=no --enable-gui=no --enable-multibyte --enable-cscope --with-tlib=ncurses --enable-fips-warning --enable-netbeans --enable-rubyinterp=dynamic --enable-luainterp=dynamic --disable-canberra" +else + CONFOPT="--build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-features=huge --enable-python3interp=dynamic --enable-perlinterp=dynamic --disable-tclinterp --with-x=no --enable-gui=no --enable-multibyte --enable-cscope --with-tlib=ncurses --enable-fips-warning --enable-netbeans --enable-rubyinterp=dynamic --enable-luainterp=dynamic --enable-libsodium --disable-canberra" +fi + +_Cleanup_Phase() { + rlPhaseStartCleanup + kill $XVFB_PID + rlFileRestore + rlRun "popd" + rlRun "userdel -frZ $TESTER" 0 "Removing user $TESTER" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +} + +rlJournalStart +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + rlPhaseStartSetup Setup + rlAssertRpm $PACKAGE + rlFileBackup /etc/vimrc + rlRun "rm -f /etc/vimrc" 0 "Remove system wide vimrc, breaks the test suite" + + if rlIsFedora + then + rlRun "dnf -y install libsodium-devel" + fi + + # prepare the user account + rlRun "useradd $TESTER" 0 "Creating user $TESTER" + # we cannot use /tmp here, because Test_write_backup_symlink() from test_writefile.vim fails because of that. + # It happens because the test expects there is a backup file created, but it isn't + # because the default Vim settings for skipping doing backup in certain directories is + # /tmp/*, so our scope where we run the test matches the wildcard, giving us the test + # failure. + rlRun "TmpDir=\"/var/tmp/vim-upstream-scripttests-$(echo $RANDOM)\"" 0 "Creating tmp directory name" + rlRun "mkdir $TmpDir" 0 "Create the temp dir" + rlRun "pushd $TmpDir" + + # extract the test suite + rlRun "rlFetchSrcForInstalled $PACKAGE" 0 "Fetching the source rpm" + rlRun "rpm --define '_topdir $TmpDir' -i *src.rpm" 0 "Installing the source rpm" + rlRun "mkdir BUILD" 0 "Creating BUILD directory" + rlRun "rpmbuild --nodeps --define '_topdir $TmpDir' -bp $TmpDir/SPECS/*spec" \ + 0 "Preparing sources" + rlRun "cd BUILD/vim*" + rlRun "chown -R $TESTER.$TESTER $TmpDir" 0 "Setting permissions" + rlRun "export LANG=en_US.UTF-8" 0 "Setting \$LANG to US locale" + + # need to get ruby CFLAGS, because configure script fails otherwise - Vim configure script + # drags in ruby LDFLAGS, but not its CFLAGS + rlRun "RUBY_CFLAGS='`ruby -r rbconfig -e "puts RbConfig::CONFIG['CFLAGS']"`'" 0 "Get ruby CFLAGS" + rlRun "export CFLAGS='$RUBY_CFLAGS'" 0 "Set ruby CFLAGS" + + # show relevant info & ENV variables + rlLog "TEST: $TEST" + rlLog "CONFOPT: $CONFOPT" + rlLog "TERM (default): $TERM" + rlLog "TERM (testing): $TERM_type" + rlRun -l "vim --version" + rlPhaseEnd + +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # untested properly - because it wasn't needed yet + [ "$SET_XVFB" = "YES" ] && { + rlPhaseStartSetup "Setup virtual framebuffer - Xvfb" + # alternative: 'xvfb-run -w 10 make TARGET' + # note: upstream CI test-run example: https://travis-ci.org/vim/vim/jobs/561452534 + rlRun "Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &" + XVFB_PID=$! + sleep 10 + rlRun "export DISPLAY=99.0" + rlRun "modinfo snd-dummy" + rlRun "modprobe snd-dummy" + rlRun "usermod -a -G audio $TESTER" + rlPhaseEnd + } + +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + rlPhaseStartTest Testing "Testing: make $TEST" + # important: beaker defaults to vt100, which is not enough for some tests! + rlRun "TERM=$TERM_type" + + # following block of code is taken from upstream travis.yml + rlRun "su $TESTER -c './configure ${CONFOPT} CFLAGS=\"${CFLAGS} $RUBY_FLAGS\"'" 0 "Configure Vim" + rlRun "su $TESTER -c 'make'" 0 "Build the binary which we substitute" + rlRun "su $TESTER -c 'ln -sf /usr/bin/vim src/vim'" 0 "Create symlink to installed vim for testing" + rlRun "su $TESTER -c 'make ${TEST} |& tee output_main'" 0,2 "Run tests (skip builtin terminal errors)" + _res_=$? + + # final checks + if grep -iq "No rule to make target.*${TEST}" output_main; then + rlLogError "This version of Vim doesn't include tests for target '$TEST'" + elif [ $_res_ -eq 0 ]; then + rlPass "Test run finished smoothly: no errors!" + rlIsRHEL '>7' && rlRun "grep 'ALL DONE' output_main" + else + rlFail "Something went wrong!" + fi + rlAssertNotGrep "TEST FAILURE" output_main + + rlFileSubmit "output_main" + rlPhaseEnd + +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + _Cleanup_Phase +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +rlJournalPrintText +rlJournalEnd