File dymo-cups-drivers-testing.spec of Package dymo-cups-drivers-testing
#
# spec file for package dymo-cups-drivers-testing
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: dymo-cups-drivers-testing
# Have the same version as in dymo-cups-drivers.spec of the dymo-cups-drivers package
# hat exists in the OBS "Printing" project at the time when dymo-cups-drivers-testing is changed
# which is currently "define _version 1.4.0.5"
Version: 1.4.0.5
Release: 0
Summary: Testing the printer drivers for CUPS from the dymo-cups-drivers package
# It is an openSUSE specific package (there is no real upstream project):
Url: https://build.opensuse.org/package/show/Printing/dymo-cups-drivers-testing
# Use the fallback license (see the header of this spec file):
License: MIT
# Same RPM gropup as Gutenprint (cf. coreutils-testsuite glibc-testsuite qemu-testsuite):
Group: Hardware/Printing
# The tests of the dymo-cups-drivers package happen during build of the dymo-cups-drivers-testing package:
BuildRequires: dymo-cups-drivers
# The tests require the cupsfilter program that is provided by CUPS:
BuildRequires: cups
# The cupsfilter program runs other filters that are provided by the cups-filters RPM:
BuildRequires: cups-filters
# Avoid that only ghostscript-mini gets installed in the build system
# by explicit requiring ghostscript which provides the 'cups' device
# that is needed by dymo-cups-drivers:
BuildRequires: ghostscript
# Install into this non-root directory (required when it is built as non-root user):
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Testing the dymo-cups-drivers package for CUPS
by running the drivers via the cupsfilter program.
See the section "How to test a printer driver package" in
https://en.opensuse.org/openSUSE:How_to_contribute_to_the_Printing_project
%prep
# Nothing to do here.
%build
# Testing the dymo-cups-drivers package for CUPS
# by running the drivers via the cupsfilter program.
# Do not let the build fail when one particular cupsfilter call fails
# to ensure that during one build always all drivers are tested
# but in case of failures report cupsfilter stderr in the buildlog.
# At the end after all drivers had been tested let the bulid fail
# when at least one particular cupsfilter call had failed.
# When cupsfilter fails it usually means a driver fails
# but it does not mean it fails when there is wrong output
# i.e. the build succeeds for any output
# cf. "How to test a printer driver package" at
# https://en.opensuse.org/openSUSE:How_to_contribute_to_the_Printing_project
postscript_file="/tmp/dymo-cups-drivers.test.ps"
pdf_file="/tmp/dymo-cups-drivers.test.pdf"
output_file="/tmp/dymo-cups-drivers.test.out"
cupsfilter_log_file="/tmp/dymo-cups-drivers.test.cupsfilter.log"
results_file="/tmp/dymo-cups-drivers.test.results"
cat /dev/null >$results_file
# Draw a PostScript rectangle with lower left corner at x=100 y=200 of width 300 and height 400:
echo -e '%!\n100 200 300 400 rectstroke\nshowpage' >$postscript_file
# Convert the PostScript into PDF with ps2pdf so that this same filtering step does not need to be run for each PPD:
/usr/bin/ps2pdf $postscript_file $pdf_file
# When build fails no matching /usr/share/dymo-cups-drivers-testing/results is built
# so that one must inspect the buildlog to find out why a current build failed.
# Excerpt from "osc rbl Printing dymo-cups-drivers-testing SLE_15 x86_64 | egrep 'FAILURE:|ERROR:'"
# FAILURE: cupsfilter failed for lm400.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 1764) crashed on signal 11
# FAILURE: cupsfilter failed for lm450.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 1777) crashed on signal 11
# FAILURE: cupsfilter failed for lmpc.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 1794) crashed on signal 11
# FAILURE: cupsfilter failed for lmpc2.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 1807) crashed on signal 11
# FAILURE: cupsfilter failed for lmpnp.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 1820) crashed on signal 11
# FAILURE: cupsfilter failed for lp350.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 1833) crashed on signal 11
# FAILURE: cupsfilter failed for lw450dt.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 2118) crashed on signal 11
# FAILURE: cupsfilter failed for lwduot.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 2239) crashed on signal 11
# FAILURE: cupsfilter failed for lwduot2.ppd with this cupsfilter stderr output:
# ERROR: raster2dymolm (PID 2252) crashed on signal 11
# PPDs that are already known to fail:
known_failing_PPDs="lm400.ppd lm450.ppd lmpc.ppd lmpc2.ppd lmpnp.ppd lp350.ppd lw450dt.ppd lwduot.ppd lwduot2.ppd"
# Avoid tons of bash debug messages in the build log when thousands of PPDs are tested below:
set +x
# Do the actual work (i.e. test each PPD):
ppds_dir="/usr/share/cups/model/manufacturer-PPDs/dymo"
echo "Begin testing all PPDs in $ppds_dir"
failed_ppds=""
succeeded_known_failing_PPDs=""
failed_known_failing_PPDs=""
test_counter=0
# dymo-cups-drivers less than 50 PPDs
# so that for test builds during development of this dymo-cups-drivers-testing package
# one does not want to test all of them and then one can adapt "head -n 50" as needed:
for PPD in $( echo $ppds_dir/*.ppd | tr ' ' '\n' | head -n 50 )
do ppd="$( basename "$PPD" .gz )"
# Show a test counter so that it is easier to estimate the progress in the buildlog while the PPDs are tested:
printf '%04d ' $(( test_counter += 1 ))
# The actual test command:
if /usr/sbin/cupsfilter -p $PPD -e -m printer/foo -i application/pdf $pdf_file 1>$output_file 2>$cupsfilter_log_file
then output_bytes="$( stat --printf=%s $output_file )"
echo -n "Tested $ppd results $output_bytes bytes " | tee -a $results_file
file -b $output_file | tee -a $results_file
if test $output_bytes -lt 1024
then # Nothing really failed but report suspiciously little or even no output:
if test $output_bytes -gt 0
then echo "WARNING: $ppd results less than 1KiB output" | tee -a $results_file
else echo "ERROR: $ppd results no output" | tee -a $results_file
fi
fi
# Detect when it works for a PPD that is considered to be known to fail:
for known_failing_PPD in $known_failing_PPDs
do known_failing_ppd="$( basename "$known_failing_PPD" .gz )"
if test "$ppd" = "$known_failing_ppd"
then echo "Unexpected success for $ppd that is considered to be known to fail" | tee -a $results_file
succeeded_known_failing_PPDs="$succeeded_known_failing_PPDs $ppd"
# Continue with the next PPD (i.e. continue the outer 'for' loop):
continue 2
fi
done
else echo "FAILURE: cupsfilter failed for $ppd with this cupsfilter stderr output:" | tee -a $results_file
cat $cupsfilter_log_file | tee -a $results_file
echo "End of cupsfilter stderr output for $ppd" | tee -a $results_file
# Do not let the build fail for PPDs that are already known to fail:
for known_failing_PPD in $known_failing_PPDs
do known_failing_ppd="$( basename "$known_failing_PPD" .gz )"
if test "$ppd" = "$known_failing_ppd"
then echo "Ignoring failure for $ppd because it is already known to fail" | tee -a $results_file
failed_known_failing_PPDs="$failed_known_failing_PPDs $ppd"
# Continue with the next PPD (i.e. continue the outer 'for' loop):
continue 2
fi
done
failed_ppds="$failed_ppds $ppd"
fi
done
echo "End testing all PPDs in $ppds_dir"
if test "$failed_ppds"
then echo "Build FAILURE because cupsfilter failed for those PPDs:" | tee -a $results_file
echo "$failed_ppds" | fold -s -w 78 | tee -a $results_file
set -x
exit 99
fi
echo "Build SUCCESS: Nothing failed unexpectedly but there could have been ERROR or WARNING messages and" | tee -a $results_file
echo "Failures for those PPDs are ignored because they are known to fail:" | tee -a $results_file
echo "$known_failing_PPDs" | fold -s -w 78 | tee -a $results_file
echo "Of the known to fail PPDs those actually failed:" | tee -a $results_file
echo "$failed_known_failing_PPDs" | fold -s -w 78 | tee -a $results_file
echo "Of the known to fail PPDs those succeeded unexpectedly:" | tee -a $results_file
echo "$succeeded_known_failing_PPDs" | fold -s -w 78 | tee -a $results_file
set -x
%install
# Provide the test results in the built RPM for later evaluation (without buildlog):
results_file="/tmp/dymo-cups-drivers.test.results"
mkdir -p %{buildroot}%{_datadir}/dymo-cups-drivers-testing/
install -m 644 $results_file %{buildroot}%{_datadir}/dymo-cups-drivers-testing/results
%files
%defattr(-,root,root,-)
%dir %{_datadir}/dymo-cups-drivers-testing/
%{_datadir}/dymo-cups-drivers-testing/results
%changelog