#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/ghostscript/Smoke/start-stop-all-binaries
# Description: it starts and stops all binaries
# Author: Petr Sklenar <psklenar@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2018 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# 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, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="ghostscript"
# EXAMPLES sources:
# https://www.ibm.com/investor/att/pdf/IBM-RED-HAT-Press-Release-10-2018.pdf
# https://www.ghostscript.com/doc/examples/tiger.eps
# http://www.paradise.caltech.edu/~mikel/papers/theta_SICOMP.ps
LOG=$(mktemp)
LOGCFF=$(mktemp)
echo 'log from cff' > $LOGCFF
cff() {
#_C_HECK_F_OR_F_AILURES
R=0
grep -i fault $1 && R=1
grep -i error $1 && R=1
rlLog "`echo LOG;tail -c600 $1`"
tail -c600 $1 >> $LOGCFF
return $R
}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp * $TmpDir"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest "eps2eps"
rlRun "eps2eps tiger.eps tiger2.eps &> $LOG"
rlRun "file tiger2.eps|grep EPS"
rlRun "eps2eps theta_SICOMP.ps theta_%d.eps"
rlRun "cff $LOG"
rlPhaseEnd
for i in "ghostscript" "gs" "gsnd" "ps2ascii";do
rlPhaseStartTest "$i"
rlRun "echo ''| GS_DEVICE=display $i &> $LOG"
rlRun "cff $LOG"
rlPhaseEnd
done
rlPhaseStartTest 'pdf2dsc'
rlRun "pdf2dsc IBM-RED-HAT-Press-Release-10-2018.pdf &> $LOG"
rlRun "cff $LOG"
rlRun "file IBM-RED-HAT-Press-Release-10-2018.dsc|grep DSC"
rlPhaseEnd
rlPhaseStartTest 'pdf2ps'
rlRun "pdf2ps IBM-RED-HAT-Press-Release-10-2018.pdf &> $LOG "
rlRun "cff $LOG"
rlRun "file IBM-RED-HAT-Press-Release-10-2018.ps | grep 'PostScript'"
rlRun "pdf2ps IBM-RED-HAT-Press-Release-10-2018.pdf IBM-Press-Release_%d.ps"
rlPhaseEnd
for i in 'ps2pdf' 'ps2pdf12' 'ps2pdf13' 'ps2pdf14' 'ps2pdfwr';do
rlPhaseStartTest $i
#there is file 'IBM-RED-HAT-Press-Release-10-2018.ps' created before
rlRun "$i IBM-RED-HAT-Press-Release-10-2018.ps &> $LOG"
rlRun "cff $LOG"
rlRun "$i IBM-RED-HAT-Press-Release-10-2018.ps IBM-Press-Release_${i}_%d.pdf &> $LOG"
rlRun "cff $LOG"
rlPhaseEnd
done
rlPhaseStartTest 'ps2epsi'
rlRun "ps2epsi IBM-RED-HAT-Press-Release-10-2018.ps 2>&1 | grep 'EPS files may not contain multiple pages' "
rlRun "ps2epsi testprinter.ps &> $LOG"
rlRun "cff $LOG"
rlPhaseEnd
rlPhaseStartTest ps2ascii
rlRun "ps2ascii IBM-RED-HAT-Press-Release-10-2018.ps &> $LOG"
rlRun "cff $LOG"
rlPhaseEnd
rlPhaseStartCleanup
echo '--------------------------'
cat $LOGCFF
echo '--------------------------'
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd