Add CI tests using the standard test interface

This commit is contained in:
sturivny 2018-08-06 17:11:26 +03:00
parent 3a729e0983
commit 7fc03f9ac2
6 changed files with 229 additions and 0 deletions

View File

@ -0,0 +1,60 @@
# Makefile - basic commands
# Author: Petr Sklenar <psklenar@redhat.com>
# Location: /CoreOS/cups/Sanity/basic_commands/Makefile
# Description: Test for basic CUPS commands
# Copyright (c) 2008 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 v.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.
TOPLEVEL_NAMESPACE=/CoreOS
PACKAGE_NAME=cups
RELATIVE_PATH=Sanity/basic-commands
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh testfile.jpg testfile.pdf Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
chmod a+x ./runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
$(METADATA): Makefile
@touch $(METADATA)
@echo "Owner: Petr Sklenar <psklenar@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Description: Test for basic CUPS commands" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
@echo "Requires: ghostscript libjpeg-turbo" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,11 @@
Test Name: basic commands
Author: Yulia Kopkova <ykopkova@redhat.com>
Location: /CoreOS/cups/Sanity/basic_commands/Makefile
Short Description: Test for basic CUPS commands
Long Description:
Test covers basic commands such as: lpadmin, lp, lpr, lpstat, cancel, lpinfo, lpq, lpc, lprm
Test based on CUPS test plan from http://www.cups.org

147
tests/basic-commands/runtest.sh Executable file
View File

@ -0,0 +1,147 @@
#!/bin/bash
# runtest.sh - basic commands
# Author: Yulia Kopkova <ykopkova@redhat.com>
# Location: /CoreOS/cups/Sanity/basic_commands/Makefile
# Description: Test for basic CUPS commands
# Copyright (c) 2008 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 v.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/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
PACKAGE=cups
FILEPDF=testfile.pdf
FILEJPG=testfile.jpg
NUMJOBS=50
TIMEOUT=30
TPRN1="testprinter1"
TPRN2="testprinter2"
FILEDEV="FileDevice YES"
CUPSCONF=/etc/cups/cupsd.conf
if `rlIsRHEL 5` ; then
ML="postscript.ppd.gz"
else
ML="drv:///sample.drv/deskjet.ppd"
fi
function setCupsCtlFileDeviceConf {
if `rlIsRHEL 5 6`;then
echo 'FileDevice YES' >> /etc/cups/cupsd.conf
else
echo 'FileDevice YES' >> /etc/cups/cups-files.conf
fi
}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlFileBackup --clean "/etc/cups" "/etc/printcap"
rlServiceStop cups
rlFileBackup $CUPSCONF /etc/cups/cups-files.conf
rlRun "setCupsCtlFileDeviceConf"
rlServiceStart cups
rlPhaseEnd
rlPhaseStartTest
rlRun "lpadmin -p $TPRN1 -v file:/dev/null -E -m $ML" 0 "Create printer $TPRN1"
rlRun "lpadmin -d $TPRN1" 0 "Set $TPRN1 default"
rlRun "lpadmin -p $TPRN2 -v file:/dev/null -E -m $ML" 0 "Create printer $TPRN2"
rlRun "lp $FILEPDF" 0 "Print $FILEPDF with lp and default printer"
rlRun "lp -d $TPRN2 $FILEJPG" 0 "Print $FILEJPG with lp and $TPRN2"
rlRun "lp -d $TPRN1 -P 1-2 -o job-sheets=classified,classified $FILEPDF" 0 "Print $FILEPDF with lp and $TPRN1"
for ((i=0; i < $NUMJOBS; i++)); do
lp -d $TPRN1 $FILEJPG &
sleep 0.02s
lp -d $TPRN2 $FILEJPG &
sleep 0.02s
lppid=$!
done
rlRun "wait $lppid" 0 "$NUMJOBS jobs queued"
for ((i=$TIMEOUT; i>0; i-=5 )); do
jobs=$(lpstat)
[ "x$jobs" = "x" ] && break
sleep 5
done
rlRun "lpr $FILEPDF" 0 "Print $FILEPDF with lpr and default printer"
rlRun "lpr -P $TPRN2 $FILEJPG" 0 "Print $FILEJPG with lpr and $TPRN2"
rlRun "lpr -P $TPRN1 -o number-up=2 -o job-sheets=standard,none $FILEPDF" 0 "Print $FILEPDF with lpr and $TPRN1"
for ((i=0; i < $NUMJOBS ; i++)); do
lpr -P $TPRN1 $FILEJPG &
sleep 0.02s
lpr -P $TPRN2 $FILEJPG &
sleep 0.02s
lprpid=$!
done
rlRun "wait $lprpid" 0 "$NUMJOBS jobs queued"
for ((i=$TIMEOUT; i>0 ; i-=5)); do
jobs=$(lpstat)
[ "x$jobs" = "x" ] && break
sleep 5
done
job_id=$(lp -d $TPRN1 -o job-hold-until=indefinite $FILEJPG | awk '{ match($0, /testprinter1-([0-9]+)/, arr); print arr[1] }')
rlRun "cancel $TPRN1-$job_id" 0 "Cancel $TPRN1-$job_id job"
rlRun "lp -d $TPRN1 -o job-hold-until=indefinite $FILEJPG" 0 "Hold job on $TPRN1"
rlRun "lp -d $TPRN2 -o job-hold-until=indefinite $FILEJPG" 0 "Hold job on $TPRN2"
rlRun "cancel -a" 0 "Cancel all jobs"
rlRun "lpc status" 0 "Show printers status"
rlRun "lpq" 0 "Show printer queue status"
rlRun "lpstat -t" 0 "Show all status information"
rlRun "lpinfo -m" 0 "Show list of available drivers"
rlRun "lpinfo -v" 0 "Show list of available devices"
rlRun "lpr -o job-hold-until=indefinite $FILEJPG" 0 "Hold test file"
rlRun "lprm" 0 "Cancel current job on default printer"
rlRun "lpr -P $TPRN1 -o job-hold-until=indefinite $FILEJPG" 0 "Hold test file"
rlRun "lprm $TPRN1" 0 "Cancel current job on $TPRN1"
rlRun "lpadmin -p $TPRN1 -v file:/tmp/$TPRN1 -o PageSize=A4" 0 "Modify $TPRN1"
rlRun "lpadmin -x $TPRN1" 0 "Delete $TPRN1"
rlRun "lpadmin -x $TPRN2" 0 "Delete $TPRN2"
rlPhaseEnd
rlPhaseStartCleanup
rlServiceStop cups
rlRun "rm -f $CUPSCONF" 0 "Remove modified cupsd.conf"
rlFileRestore
rlServiceRestore cups
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

11
tests/tests.yml Normal file
View File

@ -0,0 +1,11 @@
---
# This first play always runs on the local staging system
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- basic-commands
required_packages:
- cups