Adding upstream-unittests

This commit is contained in:
Frantisek Hrdina 2022-03-03 10:19:30 +01:00
commit bdf21bc9f6
2 changed files with 159 additions and 0 deletions

View file

@ -0,0 +1,41 @@
summary: Runs upstream unit tests
description: ''
contact: fhrdina@redhat.com
component:
- vim
test: ./runtest.sh
framework: beakerlib
recommend:
- vim-enhanced
- rpm-build
- autoconf
- gcc
- python3
- python3-yaml
- python3-devel
- python-devel
- ruby
- ruby-devel
- lua-devel
- gpm-devel
- perl-ExtUtils-Embed
- libacl-devel
- libXpm-devel
- ncurses-devel
duration: 20m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- NoRHEL6
- TIPfail_infra
- TIPpass
- Tier1
tier: '1'
adjust:
- enabled: false
when: distro == rhel-4, rhel-5, rhel-6
continue: false
extra-nitrate: TC#0602358
extra-summary: /CoreOS/vim/Sanity/upstream-unittests
extra-task: /CoreOS/vim/Sanity/upstream-unittests

View file

@ -0,0 +1,118 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/vim/Sanity/upstream-unittests
# Description: Runs upstream unittests
# Authors: Zdenek Dohnal <zdohnal@redhat.com>
# Patrik Mosko <pmosko@redhat.com>
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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=unittests # main target for `make`
TERM_type=xterm # terminfo type set before running tests
set -o pipefail # because test output is piped to `tee`
if rlIsRHEL 8
then
CONFOPT="--prefix=/usr --with-features=huge --enable-python3interp=dynamic --enable-perlinterp=dynamic --disable-tclinterp --with-x=no --enable-gui=no --exec-prefix=/usr --enable-multibyte --enable-cscope --with-tlib=ncurses --enable-fips-warning --enable-netbeans --enable-rubyinterp=dynamic --enable-luainterp=dynamic"
elif rlIsRHEL 9
then
CONFOPT="--prefix=/usr --with-features=huge --enable-python3interp=dynamic --enable-perlinterp=dynamic --disable-tclinterp --with-x=no --enable-gui=no --exec-prefix=/usr --enable-multibyte --enable-cscope --with-tlib=ncurses --enable-fips-warning --enable-netbeans --enable-rubyinterp=dynamic --enable-luainterp=dynamic --disable-canberra"
else
CONFOPT="--prefix=/usr --with-features=huge --enable-python3interp=dynamic --enable-perlinterp=dynamic --disable-tclinterp --with-x=no --enable-gui=no --exec-prefix=/usr --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
rlRun "popd"
rlRun "userdel -frZ $TESTER" 0 "Removing user $TESTER"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
}
rlJournalStart
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rlPhaseStartSetup Setup
rlAssertRpm $PACKAGE
# prepare the user account
rlRun "useradd $TESTER" 0 "Creating user $TESTER"
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
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 "FEATURES: $FEATURES"
rlLog "TERM (default): $TERM"
rlLog "TERM (testing): $TERM_type"
rlRun -l "vim --version"
rlPhaseEnd
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rlPhaseStartTest "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'" 0,2 "Run tests (skip builtin terminal errors)"
_res_=$?
# final checks
if grep -iq "No rule to make target.*${TEST}" output; 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!"
else
rlFail "Something went wrong!"
fi
rlFileSubmit "output"
rlPhaseEnd
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_Cleanup_Phase
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rlJournalPrintText
rlJournalEnd