File gutenprint-testing.spec of Package gutenprint-testing
#
# spec file for package gutenprint-testing
#
# Copyright (c) 2023 SUSE LLC
#
# 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: gutenprint-testing
# Have the same version as in gutenprint.spec of the gutenprint package
# hat exists in the OBS "Printing" project at the time when gutenprint-testing is changed
# which is currently "Version: 5.3.4"
Version: 5.3.4
Release: 0
Summary: Testing the printer drivers for CUPS from the Gutenprint project
# It is an openSUSE specific package (there is no real upstream project):
Url: https://build.opensuse.org/package/show/Printing/gutenprint-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
# Source1: README.SUSE
Source1: README.SUSE
# The tests of the Gutenprint printer drivers happen during build of the gutenprint-testing package:
BuildRequires: gutenprint
# 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
# /usr/bin/ps2pdf is provided by Ghostscript:
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 Gutenprint printer drivers for CUPS
by running the drivers via the cupsfilter program.
See /usr/share/doc/packages/gutenprint-testing/README.SUSE
and cf. 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 Gutenprint printer drivers for CUPS
# by running the drivers via the cupsfilter program,
# (see Source1 README.SUSE).
# 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/gutenprint.test.ps"
pdf_file="/tmp/gutenprint.test.pdf"
output_file="/tmp/gutenprint.test.out"
cupsfilter_log_file="/tmp/gutenprint.test.cupsfilter.log"
results_file="/tmp/gutenprint.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/gutenprint-testing/results is built
# so that one must inspect the buildlog to find out why a current build failed.
# PPDs that are already known to fail:
# known_failing_PPDs="stp-citizen-cx-w.5.2.sim.ppd stp-dnp-ds620.5.2.sim.ppd ... "
# Since 5.2.13pre14.2 (second pre-release of Gutenprint 5.2.14) all PPDs work:
known_failing_PPDs=""
# 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/gutenprint/5.3/C"
echo "Begin testing all PPDs in $ppds_dir"
failed_ppds=""
succeeded_known_failing_PPDs=""
failed_known_failing_PPDs=""
test_counter=0
# Gutenprint has more than 7000 PPDs (e.g. gutenprint-5.3.4 has 7156 PPDs)
# so that for test builds during development of this gutenprint-testing package
# one does not want to test all of them and then one can adapt "head -n 9000" as needed:
for PPD in $( echo $ppds_dir/* | tr ' ' '\n' | head -n 9000 )
do ppd="$( basename "$PPD" .gz )"
# Show a test counter so that it is easier to estimate the progress in the buildlog while thousands of 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
# Source1: README.SUSE
mkdir -p %{buildroot}%{_datadir}/doc/packages/gutenprint-testing/
install -m 644 %{SOURCE1} %{buildroot}%{_datadir}/doc/packages/gutenprint-testing/README.SUSE
# Provide the test results in the built RPM for later evaluation (without buildlog):
results_file="/tmp/gutenprint.test.results"
mkdir -p %{buildroot}%{_datadir}/gutenprint-testing/
install -m 644 $results_file %{buildroot}%{_datadir}/gutenprint-testing/results
%files
%defattr(-,root,root,-)
%dir %{_datadir}/doc/packages/gutenprint-testing
%{_datadir}/doc/packages/gutenprint-testing/README.SUSE
%dir %{_datadir}/gutenprint-testing/
%{_datadir}/gutenprint-testing/results
%changelog