From 38f92ea944c5bb928b0d4cbcc1a1f7bf18f0a0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Hrdina?= Date: Mon, 20 Mar 2023 13:48:09 +0100 Subject: [PATCH] Adding tests /CoreOS/vim/Sanity/bz2011389-Loading-etc-vimrc-virc /CoreOS/vim/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace /CoreOS/vim/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim --- .../main.fmf | 23 +++ .../runtest.sh | 62 ++++++++ .../main.fmf | 27 ++++ .../runtest.sh | 104 +++++++++++++ .../test.vim | 9 ++ .../bz2011389-Loading-etc-vimrc-virc/main.fmf | 28 ++++ .../runtest.sh | 140 ++++++++++++++++++ Sanity/upstream-unittests/main.fmf | 1 + Sanity/vim-aliases/main.fmf | 18 +-- 9 files changed, 403 insertions(+), 9 deletions(-) create mode 100644 Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/main.fmf create mode 100755 Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/runtest.sh create mode 100644 Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/main.fmf create mode 100755 Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/runtest.sh create mode 100755 Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/test.vim create mode 100644 Sanity/bz2011389-Loading-etc-vimrc-virc/main.fmf create mode 100755 Sanity/bz2011389-Loading-etc-vimrc-virc/runtest.sh diff --git a/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/main.fmf b/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/main.fmf new file mode 100644 index 0000000..73930dd --- /dev/null +++ b/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/main.fmf @@ -0,0 +1,23 @@ +summary: Test for BZ#1083924 (Include c++11 syntax highlighting in vim) +description: | + Bug summary: Include c++11 syntax highlighting in vim + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1083924 +enabled: true +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1083924 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1267826 +tag: + - Tier1 +tier: '1' +contact: fhrdina@redhat.com +component: + - vim +test: ./runtest.sh +framework: beakerlib +recommend: + - vim-enhanced +duration: 5m +extra-nitrate: TC#0475856 +extra-summary: /CoreOS/vim/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim +extra-task: /CoreOS/vim/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim +id: ecff0abc-636e-418e-bea4-3e5ab92abe2a \ No newline at end of file diff --git a/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/runtest.sh b/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/runtest.sh new file mode 100755 index 0000000..7f972e5 --- /dev/null +++ b/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim/runtest.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/vim/Regression/bz1083924-Include-c-11-syntax-highlighting-in-vim +# Description: Test for BZ#1083924 (Include c++11 syntax highlighting in vim) +# Author: Filip Holec +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# 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 + +PACKAGE="vim-enhanced" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + CPPPATH=$(rpm -ql vim-common | grep syntax/cpp.vim$) + rlPhaseEnd + + rlPhaseStartTest + rlAssertGrep "override" $CPPPATH + rlAssertGrep "final" $CPPPATH + rlAssertGrep "noexcept" $CPPPATH + rlAssertGrep "constexpr" $CPPPATH + rlAssertGrep "decltype" $CPPPATH + rlAssertGrep "thread_local" $CPPPATH + rlAssertGrep "nullptr" $CPPPATH + rlAssertGrep "ATOMIC_FLAG_INIT" $CPPPATH + rlAssertGrep "ATOMIC_VAR_INIT" $CPPPATH + for NAME in BOOL CHAR CHAR16_T CHAR32_T WCHAR_T SHORT INT LONG LLONG POINTER; do + rlAssertGrep "ATOMIC_${NAME}_LOCK_FREE" $CPPPATH + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/main.fmf b/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/main.fmf new file mode 100644 index 0000000..1000978 --- /dev/null +++ b/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/main.fmf @@ -0,0 +1,27 @@ +summary: Test for BZ#1676339 (Vim runs out of memory during a find and replace) +description: | + Bug summary: Vim runs out of memory during a find and replace + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1676339 +contact: fhrdina@redhat.com +component: + - vim +test: ./runtest.sh +framework: beakerlib +recommend: + - sudo + - vim-minimal +duration: 20m +enabled: true +tag: + - Tier1 +tier: '1' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1676339 +adjust: + - enabled: false + when: distro < rhel-7 + continue: false +extra-nitrate: TC#0599530 +extra-summary: /CoreOS/vim/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace +extra-task: /CoreOS/vim/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace +id: d8580839-772b-413a-af0f-4a9c74e01291 \ No newline at end of file diff --git a/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/runtest.sh b/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/runtest.sh new file mode 100755 index 0000000..328f65c --- /dev/null +++ b/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/runtest.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/vim/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace +# Description: Test for BZ#1676339 (Vim runs out of memory during a find and replace) +# 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 + +# vim-minimal-7.4.160-5.el7.x86_64 +# VALGRIND: heap usage +# --------------------------------| +# lines num | HEAP usage total | 4B/line +# --------------------------------| +# 10000 | 523,032,856 | +# 20000 | 1,945,801,529 | +# 30000 | 4,268,705,371 | +# 40000 | 7,491,994,207 | +# 50000 | 11,615,328,127 | +# ... | ... | +# 300000 should be enough | +# --------------------------------| + +PACKAGE="vim-minimal" +VIM_MSG_LINES=300000 +: ${VALGRIND_DEBUG:="NO"} + +print_oom_score_all_proc() { + ( + while read -r pid comm; do + if [[ -f /proc/$pid/oom_score ]]; then + printf '%d\t%d\t\t%d\t%s\n' "$pid" "$(cat /proc/$pid/oom_score)" "$(cat /proc/$pid/oom_score_adj)" "$comm" + fi + done < <(ps -e -o pid= -o comm=) | sort -k 2nr) | column -t +} + + +rlJournalStart + # workarond because of BaseOS CI gating - yielding FAIL for this test + # another options - remove it completely from Tier1/gating bugs + if rlIsRHEL '<=7.6'; then + rlPhaseStartSetup + rlPass "This test is excluded from RHEL-7.6 and older distros" + rlPhaseEnd + else + + ########## SETUP PHASE ########## + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TMP_vimdir=\$(mktemp -d)" + rlRun "cp test.vim $TMP_vimdir" + rlRun "pushd $TMP_vimdir" + rm -f msg + rlPhaseEnd + + ##################### TEST PHASE #################### + rlPhaseStartTest + #debug + rlLog "PID | oom_score | oom_score_adj | command" + print_oom_score_all_proc + + rlRun "for x in {1..$VIM_MSG_LINES};do echo 'cau' >> msg; done" + rlRun "[ `wc -l msg|awk '{print $1}'` -eq $VIM_MSG_LINES ]" + + echo "VALGRIND_DEBUG: $VALGRIND_DEBUG" + if [[ "$VALGRIND_DEBUG" == "YES" ]]; then + yum -y install valgrind + valgrind vi msg -c 'source test.vim' + fi + rlRun "vi msg -c 'source test.vim'" 0 "Find EOL and substitute them." + rlRun "[ `wc -l msg|awk '{print $1}'` -eq 1 ]" + rlPhaseEnd + + ########## CLEANUP PHASE ########## + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -rf $TMP_vimdir" + rlPhaseEnd + + fi +rlJournalPrintText +rlJournalEnd diff --git a/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/test.vim b/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/test.vim new file mode 100755 index 0000000..8f27c32 --- /dev/null +++ b/Regression/bz1676339-Vim-runs-out-of-memory-during-a-find-and-replace/test.vim @@ -0,0 +1,9 @@ +:silent !echo -n "oom_score: "; cat /proc/$PPID/oom_score +:silent !echo -n "oom_score_adj: "; cat /proc/$PPID/oom_score_adj +:silent !sudo echo 1000 > /proc/$PPID/oom_score_adj +:silent !sleep 3 +:silent !echo -e "PID: $PPID" +:silent !echo -n "oom_score: "; cat /proc/$PPID/oom_score +:silent !echo -n "oom_score_adj: "; cat /proc/$PPID/oom_score_adj +:%s/\n//g +:wq! diff --git a/Sanity/bz2011389-Loading-etc-vimrc-virc/main.fmf b/Sanity/bz2011389-Loading-etc-vimrc-virc/main.fmf new file mode 100644 index 0000000..0a69054 --- /dev/null +++ b/Sanity/bz2011389-Loading-etc-vimrc-virc/main.fmf @@ -0,0 +1,28 @@ +summary: Test whether we load system wide vimrcs +description: '' +contact: fhrdina@redhat.com +component: + - vim +test: ./runtest.sh +framework: beakerlib +recommend: + - vim-minimal + - vim-enhanced + - rpm + - grep +duration: 5m +enabled: false +tag: + - Tier1 +tier: '1' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011389 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2011429 +adjust: + - enabled: false + when: distro < rhel-8 + continue: false +extra-nitrate: TC#0611953 +extra-summary: /CoreOS/vim/Sanity/bz2011389-Loading-etc-vimrc-virc +extra-task: /CoreOS/vim/Sanity/bz2011389-Loading-etc-vimrc-virc +id: a74a0489-d7d7-4936-9587-04b1eb26d185 diff --git a/Sanity/bz2011389-Loading-etc-vimrc-virc/runtest.sh b/Sanity/bz2011389-Loading-etc-vimrc-virc/runtest.sh new file mode 100755 index 0000000..de3ab4f --- /dev/null +++ b/Sanity/bz2011389-Loading-etc-vimrc-virc/runtest.sh @@ -0,0 +1,140 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/vim/Sanity/bz2011389-Loading-etc-vimrc-virc +# Description: Test whether we load system wide vimrcs +# Author: Zdenek Dohnal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 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_VI="vim-minimal" +PACKAGE_VIM="vim-enhanced" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE_VI + rlAssertRpm $PACKAGE_VIM + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlFileBackup /etc/virc + rlFileBackup /etc/vimrc + DEFAULTS_FILE=`rpm -ql vim-common | grep defaults` + rlFileBackup $DEFAULTS_FILE + rlPhaseEnd + + rlPhaseStartTest "VIM" + rlLog "# Default configuration - system vimrc and defaults.vim loaded #" + rlRun "vim -c scriptnames -c q &> log" + rlAssertGrep "/etc/vimrc" log + rlAssertNotGrep "~/.vimrc" log + rlAssertGrep "defaults.vim" log + + rlLog "# Created user vimrc - system and user vimrc loaded, defaults not #" + rlRun "touch ~/.vimrc" + rlRun "vim -c scriptnames -c q &> log" + rlAssertGrep "/etc/vimrc" log + rlAssertGrep "~/.vimrc" log + rlAssertNotGrep "defaults.vim" log + + rlLog "# Remove user vimrc and put skip_defaults_vim into system vimrc #" + rlLog "# system vimrc and defaults are loaded, but settings from defaults #" + rlLog "# are skipped #" + rlRun "rm -f ~/.vimrc" + rlRun "echo 'let skip_defaults_vim = 1' >> /etc/vimrc" + rlRun "vim -c scriptnames -c 'set history?' -c q &> log" + rlAssertGrep "/etc/vimrc" log + rlAssertNotGrep "~/.vimrc" log + rlAssertGrep "defaults.vim" log + # if defaults.vim isn't loaded, history is 50 from /etc/vimrc + rlAssertGrep "history=50" log + rlRun "sed -i 's,let skip_defaults_vim = 1,,' /etc/vimrc" + rlPhaseEnd + + rlPhaseStartTest "VI->VIM via alias" + if rlIsRHEL '<=8' && [ "$USER" = "root" ] + then + rlLog "RHEL 8 and older detected - vi is used for root, covered by next test" + else + rlLog "# Default configuration - system vimrc and defaults.vim loaded #" + rlRun "vi -c scriptnames -c q &> log" + rlAssertGrep "/etc/vimrc" log + rlAssertNotGrep "~/.vimrc" log + rlAssertGrep "defaults.vim" log + + rlLog "# Created user vimrc - system and user vimrc loaded, defaults not #" + rlRun "touch ~/.vimrc" + rlRun "vi -c scriptnames -c q &> log" + rlAssertGrep "/etc/vimrc" log + rlAssertGrep "~/.vimrc" log + rlAssertNotGrep "defaults.vim" log + + rlLog "# Remove user vimrc and put skip_defaults_vim into system vimrc #" + rlLog "# system vimrc and defaults are loaded, but settings from defaults #" + rlLog "# are skipped #" + rlRun "rm -f ~/.vimrc" + rlRun "echo 'let skip_defaults_vim = 1' >> /etc/vimrc" + rlRun "vi -c scriptnames -c 'set history?' -c q &> log" + rlAssertGrep "/etc/vimrc" log + rlAssertNotGrep "~/.vimrc" log + rlAssertGrep "defaults.vim" log + rlAssertGrep "history=50" log + rlRun "sed -i 's,let skip_defaults_vim = 1,,' /etc/vimrc" + fi + rlPhaseEnd + + rlPhaseStartTest "VI" + rlRun "dnf -y remove vim-enhanced vim-common" + + rlLog "# scriptnames doesn't work for vi, we need to check settings themselves" + rlLog "# Default configuration - system virc and defaults.vim loaded #" + rlRun "echo 'set nu' >> /etc/virc" + rlRun "vi -c 'set history?' -c 'set nu?' -c q &> log" + if rlIsRHEL '>9' || rlIsFedora + then + rlAssertGrep "history=200" log + else + rlLog "No defaults.vim for vi on RHEL <= 9" + rlAssertGrep "history=50" log + fi + rlAssertGrep "number" log + + rlLog "# Created user virc - system and user virc loaded, defaults not #" + rlRun "echo 'set autoindent' > ~/.virc" + rlRun "vi -c 'set autoindent?' -c 'set history?' -c q &> log" + # if contains title, .virc was loaded + rlAssertGrep "autoindent" log + # if history is 50, defaults.vim (which sets it to 200) wasn't loaded and /etc/virc was + # loaded + rlAssertGrep "history=50" log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -f ~/.vimrc" + rlRun "rm -f ~/.virc" + rlFileRestore + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/Sanity/upstream-unittests/main.fmf b/Sanity/upstream-unittests/main.fmf index b69fa11..6d1982a 100644 --- a/Sanity/upstream-unittests/main.fmf +++ b/Sanity/upstream-unittests/main.fmf @@ -6,6 +6,7 @@ component: test: ./runtest.sh framework: beakerlib recommend: + - vim-minimal - vim-enhanced - rpm-build - autoconf diff --git a/Sanity/vim-aliases/main.fmf b/Sanity/vim-aliases/main.fmf index 70f3007..cc1dc1f 100644 --- a/Sanity/vim-aliases/main.fmf +++ b/Sanity/vim-aliases/main.fmf @@ -2,23 +2,23 @@ summary: vim-aliases description: 'Test checks whether vi/vim/view aliases via wrappers work' contact: Petr Sklenar component: -- vim + - vim test: ./runtest.sh framework: beakerlib recommend: -- vim-minimal -- vim-enhanced -- ksh -- zsh -- tcsh + - vim-minimal + - vim-enhanced + - ksh + - zsh + - tcsh duration: 10m enabled: true tag: -- Tier1 + - Tier1 tier: '1' adjust: -- enabled: false - when: distro < rhel-9 + - enabled: false + when: distro < rhel-8 continue: false extra-nitrate: TC#0609483 extra-summary: /CoreOS/vim/Sanity/vim-aliases