From 7ada4d0c958db419822ceb9186d24548c01cda8a Mon Sep 17 00:00:00 2001 From: Frantisek Hrdina Date: Thu, 9 Dec 2021 13:04:56 +0100 Subject: [PATCH] Adding vim-aliases sanity test --- Sanity/vim-aliases/main.fmf | 30 ++++++++ Sanity/vim-aliases/runtest.sh | 127 ++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 Sanity/vim-aliases/main.fmf create mode 100755 Sanity/vim-aliases/runtest.sh diff --git a/Sanity/vim-aliases/main.fmf b/Sanity/vim-aliases/main.fmf new file mode 100644 index 0000000..fc9226d --- /dev/null +++ b/Sanity/vim-aliases/main.fmf @@ -0,0 +1,30 @@ +summary: Test checks whether vi/vim/view 'aliases' via wrappers work +description: '' +contact: Petr Sklenar +component: +- vim +test: ./runtest.sh +framework: beakerlib +recommend: +- vim-minimal +- vim-enhanced +- ksh +- zsh +- tcsh +duration: 10m +enabled: true +tag: +- NoRHEL4 +- NoRHEL5 +- NoRHEL6 +- NoRHEL7 +- TIPpass +- Tier1 +tier: '1' +adjust: +- enabled: false + when: distro == rhel-4, rhel-5, rhel-6, rhel-7, rhel-8 + continue: false +extra-nitrate: TC#0609483 +extra-summary: /CoreOS/vim/Sanity/vim-aliases +extra-task: /CoreOS/vim/Sanity/vim-aliases diff --git a/Sanity/vim-aliases/runtest.sh b/Sanity/vim-aliases/runtest.sh new file mode 100755 index 0000000..fa062bb --- /dev/null +++ b/Sanity/vim-aliases/runtest.sh @@ -0,0 +1,127 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/vim/Sanity/vim-aliases +# Description: Test checks whether vi/vim/view 'aliases' via wrappers work +# 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 + +VIM_PACKAGE="vim-enhanced" +VI_PACKAGE="vim-minimal" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $VIM_PACKAGE + rlAssertRpm $VI_PACKAGE + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + for shell in bash ksh zsh + do + if test "$shell" == "tcsh" + then + ERRNO=1 + else + ERRNO=127 + fi + + rlLog "==============================================================" + rlLog "$shell: Running vi/vim/view" + rlLog "==============================================================" + rlLog "Minimal and Enhanced installed, using vim for all commands." + rlLog "--------------------------------------------------------------" + for app in /usr/bin/vi /usr/bin/view /usr/bin/vim + do + rlLog "$shell: Running $app" + $shell -c "$app --version > out" + rlAssertGrep 'Huge version without GUI' out + + rlLog "$shell: Running $app under sudo" + sudo $shell -c "$app --version > sudo_out" + rlAssertGrep 'Huge version without GUI' sudo_out + done + + rlRun "dnf -y remove $VI_PACKAGE" 0 "Remove vi" + rlLog "--------------------------------------------------------------" + rlLog "Enhanced installed, vi/view fail, vim works." + rlLog "--------------------------------------------------------------" + + for app in /usr/bin/vi /usr/bin/view + do + rlLog "$shell: Running $app" + rlRun "$shell -c \"$app --version\"" $ERRNO "$app is missing, the command will fail." + + rlLog "$shell: Running $app under sudo" + rlRun "sudo $shell -c \"$app --version\"" $ERRNO "SUDO: $app is missing, the command will fail." + done + + rlLog "$shell: Running /usr/bin/vim" + $shell -c "/usr/bin/vim --version > out" + rlAssertGrep 'Huge version without GUI' out + + rlLog "$shell: Running /usr/bin/vim under sudo" + sudo $shell -c "/usr/bin/vim --version > sudo_out" + rlAssertGrep 'Huge version without GUI' sudo_out + + rlRun "dnf -y install $VI_PACKAGE" 0 "Install vi" + rlRun "dnf -y remove $VIM_PACKAGE" 0 "Remove vim" + rlLog "--------------------------------------------------------------" + rlLog "Minimal installed, using vi for vi and view commands." + rlLog "--------------------------------------------------------------" + + for app in /usr/bin/vi /usr/bin/view + do + rlLog "$shell: Running $app" + $shell -c "$app --version > out" + rlAssertGrep 'Small version without GUI' out + + rlLog "$shell: Running $app under sudo" + sudo $shell -c "$app --version > sudo_out" + rlAssertGrep 'Small version without GUI' sudo_out + done + + rlLog "--------------------------------------------------------------" + rlLog "Minimal installed, vim command should fail." + rlLog "--------------------------------------------------------------" + + rlLog "$shell: Running /usr/bin/vim" + rlRun "$shell -c \"/usr/bin/vim --version\"" $ERRNO "vim is missing, the command will fail" + + rlLog "$shell: Running /usr/bin/vim under sudo" + rlRun "sudo $shell -c \"/usr/bin/vim --version\"" $ERRNO "SUDO: vim is missing, the command will fail" + + rlRun "dnf -y install $VIM_PACKAGE" 0 "Install vim" + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd