From 38480a0e030ebf2c1ddba4866ae35c123518808d Mon Sep 17 00:00:00 2001 From: Serhii Turivnyi Date: Jun 12 2018 12:17:45 +0000 Subject: [PATCH 1/2] Add CI tests using the standard test interface --- diff --git a/tests/basic-commands/Makefile b/tests/basic-commands/Makefile new file mode 100644 index 0000000..62ba577 --- /dev/null +++ b/tests/basic-commands/Makefile @@ -0,0 +1,62 @@ +# Makefile - basic commands +# Author: Petr Sklenar +# 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) + + +include /usr/share/rhts/lib/rhts-make.include + + +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: Petr Sklenar " > $(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 libjpeg-turbo-devel" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/basic-commands/PURPOSE b/tests/basic-commands/PURPOSE new file mode 100644 index 0000000..937f679 --- /dev/null +++ b/tests/basic-commands/PURPOSE @@ -0,0 +1,11 @@ +Test Name: basic commands +Author: Yulia Kopkova +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 diff --git a/tests/basic-commands/runtest.sh b/tests/basic-commands/runtest.sh new file mode 100755 index 0000000..c6ba45a --- /dev/null +++ b/tests/basic-commands/runtest.sh @@ -0,0 +1,148 @@ +#!/bin/bash +# runtest.sh - basic commands +# Author: Yulia Kopkova +# 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. + + +PACKAGE=cups + +# Include rhts environment +. /usr/bin/rhts-environment.sh +. /usr/share/rhts-library/rhtslib.sh + +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 diff --git a/tests/basic-commands/testfile.jpg b/tests/basic-commands/testfile.jpg new file mode 100644 index 0000000..8806a34 Binary files /dev/null and b/tests/basic-commands/testfile.jpg differ diff --git a/tests/basic-commands/testfile.pdf b/tests/basic-commands/testfile.pdf new file mode 100644 index 0000000..fe7d8a6 Binary files /dev/null and b/tests/basic-commands/testfile.pdf differ diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..acb2e2b --- /dev/null +++ b/tests/tests.yml @@ -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 From 3ee72f6a3aeaeb2ab0af00e80cdef4a77a5c8f52 Mon Sep 17 00:00:00 2001 From: Serhii Turivnyi Date: Jun 12 2018 12:21:32 +0000 Subject: [PATCH 2/2] Add CI tests using the standard test interface --- diff --git a/tests/tests.yml b/tests/tests.yml index acb2e2b..71052f9 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -5,6 +5,7 @@ - role: standard-test-beakerlib tags: - classic + - atomic tests: - basic-commands required_packages: