# # spec file for package ghostscript-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: ghostscript-testing Version: 1.0 Release: 0 Summary: Testing Ghostscript drivers, so called Ghostscript 'devices' # It is an openSUSE specific package (there is no real upstream project): Url: https://build.opensuse.org/package/show/home:jsmeix/ghostscript-testing # Use the fallback license (see the header of this spec file): License: MIT # Same RPM gropup as Ghostscript (cf. coreutils-testsuite glibc-testsuite qemu-testsuite): Group: System/Libraries # Source1: README.SUSE Source1: README.SUSE # The tests of the Ghostscript drivers happen during build of the ghostscript-testing package: BuildRequires: ghostscript BuildRequires: ghostscript-fonts-std BuildRequires: ghostscript-fonts-other # Install into this non-root directory (required when it is built as non-root user): BuildRoot: %{_tmppath}/%{name}-%{version}-build %description Testing Ghostscript drivers, so called Ghostscript 'devices' by running them with the Ghostscript example files and other test files. %prep # Nothing to do here. %build # Testing Ghostscript drivers, so called Ghostscript 'devices' # by running them with the Ghostscript example files # and other test files, # (see Source1 README.SUSE). # Do not let the build fail when one particular gs call fails # to ensure that during one build always all drivers are tested # but in case of failures report gs stdout and stderr in the buildlog. # At the end after all drivers had been tested let the bulid fail # when at least one particular gs call had failed. # When gs 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 gs_stdout_and_stderr="/tmp/gs.out" gs_options="-q -r50 -dNOPAUSE -dBATCH -dSAFER -sOutputFile=/dev/null" # All Ghostscript drivers would be gs_devices=$( gs -h | sed -n -e '/alc1900/,/xes/p' | tr -s '[:space:]' ' ' ) # but many Ghostscript drivers do not work with /dev/null as OutputFile # so that at least for now only some in practice important example drivers are tested # that work with /dev/null as OutputFile: gs_devices="nullpage cups epson deskjet ljet4 pxlmono pxlcolor pdfwrite ps2write jpeg pngalpha pnggray pngmono" example_files=$( ls -1 /usr/share/ghostscript/*/examples/*.p* ) failed_tests=() results_file="/tmp/ghostscript.test.results" cat /dev/null >$results_file # Avoid tons of bash debug messages in the build log: set +x # Do the actual work: echo "Start testing $gs_devices" | tee -a $results_file for gs_device in $gs_devices do echo "BEGIN testing $gs_device" | tee -a $results_file for example_file in $example_files do echo "Testing $gs_device with $example_file" | tee -a $results_file if gs $gs_options -sDEVICE=$gs_device $example_file &>$gs_stdout_and_stderr then echo "OK for $gs_device with $example_file" | tee -a $results_file else echo "FAILURE for $gs_device with $example_file with this gs stdout and stderr output:" | tee -a $results_file cat $gs_stdout_and_stderr | tee -a $results_file echo "End of gs stdout and stderr output for $gs_device with $example_file failure" | tee -a $results_file failed_tests=( "${failed_tests[@]}" "FAILURE for $gs_device with $example_file" ) fi done echo "END testing $gs_device" | tee -a $results_file done echo "Finished testing $gs_devices" | tee -a $results_file if test "${failed_tests[*]}" then echo "Build FAILURE because gs failed for those drivers and example_files:" | tee -a $results_file for failed_test in "${failed_tests[@]}" do echo "$failed_test" | fold -s -w 78 | tee -a $results_file done set -x exit 99 fi echo "Build SUCCESS: Nothing really failed but there could have been ERROR or WARNING messages" | tee -a $results_file set -x %install # Source1: README.SUSE mkdir -p %{buildroot}%{_datadir}/doc/packages/ghostscript-testing/ install -m 644 %{SOURCE1} %{buildroot}%{_datadir}/doc/packages/ghostscript-testing/README.SUSE # Provide the test results in the built RPM for later evaluation (without buildlog): results_file="/tmp/ghostscript.test.results" mkdir -p %{buildroot}%{_datadir}/ghostscript-testing/ install -m 644 $results_file %{buildroot}%{_datadir}/ghostscript-testing/results %files %defattr(-,root,root,-) %dir %{_datadir}/doc/packages/ghostscript-testing %{_datadir}/doc/packages/ghostscript-testing/README.SUSE %dir %{_datadir}/ghostscript-testing/ %{_datadir}/ghostscript-testing/results %changelog