From d2dff56ba9fd0b792e1e6830f009a3a80c6ffdb3 Mon Sep 17 00:00:00 2001 From: Ondrej Mejzlik Date: Wed, 12 Jul 2023 13:04:54 +0200 Subject: [PATCH] Adding new test --- Sanity/basic-sanity-test/main.fmf | 32 +++++++++++++ Sanity/basic-sanity-test/runtest.sh | 68 +++++++++++++++++++++++++++ Sanity/basic-sanity-test/test.md | 3 ++ Sanity/basic-sanity-test/testfile.txt | 6 +++ 4 files changed, 109 insertions(+) create mode 100644 Sanity/basic-sanity-test/main.fmf create mode 100755 Sanity/basic-sanity-test/runtest.sh create mode 100644 Sanity/basic-sanity-test/test.md create mode 100644 Sanity/basic-sanity-test/testfile.txt diff --git a/Sanity/basic-sanity-test/main.fmf b/Sanity/basic-sanity-test/main.fmf new file mode 100644 index 0000000..44b02a1 --- /dev/null +++ b/Sanity/basic-sanity-test/main.fmf @@ -0,0 +1,32 @@ +summary: Test basic behavior +description: '' +contact: Ondrej Mejzlik +component: + - urlview +test: ./runtest.sh +framework: beakerlib +recommend: + - urlview +duration: 5m +enabled: true +tag: + - NoRHEL4 + - NoRHEL5 + - TIPfail_infra + - TIPfail_samba + - TIPfail_systemd + - TIPpass + - Tier1 + - notier +tier: '1' +adjust: + - enabled: false + when: distro == rhel-4, rhel-5 + continue: false + - enabled: false + when: arch == s390x + continue: false +extra-nitrate: TC#0597641 +extra-summary: /CoreOS/urlview/Sanity/basic-sanity-test +extra-task: /CoreOS/urlview/Sanity/basic-sanity-test +id: c4f64066-f366-46ef-8a6f-314ba25e1b8f diff --git a/Sanity/basic-sanity-test/runtest.sh b/Sanity/basic-sanity-test/runtest.sh new file mode 100755 index 0000000..e775b94 --- /dev/null +++ b/Sanity/basic-sanity-test/runtest.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/urlview/Sanity/basic-sanity-test +# Description: Test basic behavior +# Author: Ondrej Mejzlik +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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=${PACKAGE:-urlview} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE || rlDie "Package $PACKAGE not installed" + rlLog "PC name: $(hostname) User: $(whoami)" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp testfile.txt $TmpDir" 0 "Copy testfile to test directory" + rlRun "pushd $TmpDir" 0 "Going into tmp directory $TmpDir" + rlPhaseEnd + + rlGetTestState && { + rlPhaseStartTest + # Will be killed by timeout + echo 'Test file contents:' + cat testfile.txt + rlRun "timeout 2 urlview testfile.txt &> out" 124 "Run urlview to generate output" + rlAssertGrep "1 https://www.google.com/" out + rlAssertGrep "2 https://www.redhat.com" out + rlLog "Only links should be in the out file" + rlAssertNotGrep "Excellent" out 0 + rlRun "urlview fakefile 1>/dev/null 2>out1" 1 "Try nonexistent file" + rlAssertGrep 'No such file or directory' out1 + echo "Command error output:" + cat out1 + rlRun "urlview fakefile | grep 'No URLs found'" 0 "No url should be found in nonexistent file" + rlRun "urlview /dev/null | grep 'No URLs found'" 0 "Try /dev/null" + rlRun "urlview /home | grep 'No URLs found'" 0 "Try to use a directory as input" + rlBundleLogs urlview out out1 + rlPhaseEnd + } + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/Sanity/basic-sanity-test/test.md b/Sanity/basic-sanity-test/test.md new file mode 100644 index 0000000..e14e2ab --- /dev/null +++ b/Sanity/basic-sanity-test/test.md @@ -0,0 +1,3 @@ +# Setup +Run manually on s390x + diff --git a/Sanity/basic-sanity-test/testfile.txt b/Sanity/basic-sanity-test/testfile.txt new file mode 100644 index 0000000..8312ce5 --- /dev/null +++ b/Sanity/basic-sanity-test/testfile.txt @@ -0,0 +1,6 @@ +We are now ready to begin the test properly. +First link: +https://www.google.com/ +More text below the first very very interesting link. +https://www.redhat.com +Excellent.