Adding new test

This commit is contained in:
Ondrej Mejzlik 2023-06-29 11:42:28 +02:00
commit 8fa9578c38
5 changed files with 114 additions and 0 deletions

View file

@ -0,0 +1,26 @@
summary: basic sanity test for paperconf
description: ''
contact: Ondrej Mejzlik <omejzlik@redhat.com>
component:
- libpaper
test: ./runtest.sh
framework: beakerlib
recommend:
- libpaper
duration: 5m
enabled: true
tag:
- NoRHEL4
- NoRHEL5
- TIPfail_infra
- TIPpass
- Tier1
tier: '1'
adjust:
- enabled: false
when: distro == rhel-4, rhel-5
continue: false
extra-nitrate: TC#0602521
extra-summary: /CoreOS/libpaper/Sanity/basic-sanity-test-for-paperconf
extra-task: /CoreOS/libpaper/Sanity/basic-sanity-test-for-paperconf
id: 9396c71b-0476-4f60-a531-1b234ce44273

View file

@ -0,0 +1 @@
a4

View file

@ -0,0 +1,86 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/libpaper/Sanity/basic-sanity-test-for-paperconf
# Description: basic sanity test for paperconf
# Author: kzilkova <kzilkova@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="libpaper"
TESTDIR="$(pwd)"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
SIZEBCKUP=$PAPERSIZE
CONFBCKUP=$PAPERCONF
rlRun "rlFileBackup --missing-ok /etc/papersize" 0 "backup papersize"
rlPhaseEnd
rlPhaseStartTest
#test basic functionality of paperconf command
rlRun "paperconf | grep 'letter'" 0 "Correct default value"
rlRun "paperconf -p a4 -wm | grep '210 mm'" 0 "check a4 width in mm"
rlRun "paperconf -p a4 -sc | grep '21 cm 29.7 cm'" 0 "check a4 height and width in cm"
rlRun "paperconf -p a2 -N | grep 'A2'" 0 "check if a in a2 is capitalized"
rlRun "paperconf -p note -N | grep 'Note'" 0 "check if N in note is capitalized"
rlRun "paperconf -d | grep 'letter'" 0 "check if default paper is letter"
rlRun "paperconf -p as -z | grep 'as'" 0 "check if -z prints wrong paper"
rlRun "paperconf -p a3 | grep 'a3'" 0 "check if there is paper a3"
rlRun "paperconf -p a5 | grep 'a5'" 0 "check if there is paper a5"
rlRun "paperconf -p a4 -hi | grep '11.6929'" 0 "check a4 height in inches"
rlRun "paperconf -p a4 -n | grep 'a4'" 0 "check if n print name"
#changing PAPERSIZE variable
rlRun "PAPERSIZE=a4 paperconf | grep 'a4'" 0 "value from papersize"
rlRun "PAPERSIZE=as paperconf |& grep 'unknown paper'" 0 "value from papersize with non-existent PAPARSIZE value inserted"
#changing PAPERCONF variable
rlRun "PAPERCONF=$TESTDIR/paper paperconf | grep 'a4'" 0 "value from paperconf"
rlRun "PAPERCONF=$TESTDIR/wrpaper paperconf |& grep 'unknown paper'" 0 "value from paperconf, wrong paper"
rlRun "PAPERCONF=$TESTDIR/nopaper paperconf | grep 'letter'" 0 "empty file, print letter"
#changing paper size value through /etc/papersize file
rlRun "echo a5 >/etc/papersize" 0 "filling papersize with a5 paper"
rlRun "paperconf | grep 'a5'" 0 "value from papersize"
rlRun "echo as > /etc/papersize" 0 "filling papersize with nonsence"
rlRun "paperconf |& grep 'unknown paper'" 0 "value from papersize, nonsence"
rlRun "> /etc/papersize" 0 "remove content of /etc/papersize file"
rlRun "paperconf | grep 'letter'" 0 "value from papersize should now defaults to 'letter'"
rlPhaseEnd
rlPhaseStartCleanup
PAPERSIZE=$SIZEBCKUP
PAPERCONF=$CONFBCKUP
rlRun "rlFileRestore" 0 " restoring papersize"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1 @@
skksjd