1#!@BASHREAL@
2
3# Meta-harness for rastertogutenprint test harness.
4#
5## Copyright (C) 2018 Robert Krawitz
6##
7## This program is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; either version 2, or (at your option)
10## any later version.
11##
12## This program is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
20
21if [[ -n "$STP_TEST_LOG_PREFIX" ]] ; then
22    redir="${STP_TEST_LOG_PREFIX}${0##*/}_$$.log"
23    if [[ -n $BUILD_VERBOSE ]] ; then
24	exec > >(tee -a "$redir" >&3)
25    else
26	exec 1>>"$redir"
27    fi
28    exec 2>&1
29fi
30
31STP_TEST_PROFILE=${STP_TEST_PROFILE:-full}
32
33[[ -n $STP_TEST_COMPONENTS && $STP_TEST_COMPONENTS != '*testpattern*' ]] && exit 77
34
35set -e
36
37declare QUIET=${TRAVIS_MODE:+-q}
38declare -a FASTOPT=("-dDitherAlgorithm=VeryFast" "-dResolution=MIN" "-dPageSize=MIN")
39declare MIN_PRINTERS="@MINIMAL_PRINTERS_TO_TEST@"
40
41function runit() {
42    if [[ -z $SILENT ]] ; then
43	echo "================================================================"
44	echo "$@"
45    fi
46    [[ -z $STP_TEST_DEBUG ]] && "$@"
47}
48
49function test_minimal() {
50    runit ./run-testpattern-2 -s "${FASTOPT[@]}" -dColorCorrection=Raw \
51	  -o InkType -o InkSet,RawChannels -o Duplex \
52	  -o MediaType -o InputSlot -o FullBleed -o UseGloss \
53	  -o Orientation -o LabelSeparator -o Resolution -T 720 \
54	  "$@" $MIN_PRINTERS
55    runit ./run-testpattern-2 -s $QUIET "${FASTOPT[@]}" -dColorCorrection=Raw -o - -G 1x1
56}
57
58function test_fast() {
59    runit ./run-testpattern-2 -s $QUIET "${FASTOPT[@]}" -dColorCorrection=Raw \
60	  -o InkType -o InkSet,RawChannels -o Duplex \
61	  -o MediaType -o InputSlot -o FullBleed -o UseGloss \
62	  -o Orientation -o LabelSeparator -o Resolution -T 720 "$@"
63    runit ./run-testpattern-2 $QUIET "${FASTOPT[@]}" -dColorCorrection=Raw -o -
64    runit ./run-testpattern-2 -s $QUIET "${FASTOPT[@]}" \
65	  -o TPMode,ColorCorrection,InkType,UseGloss $MIN_PRINTERS
66    runit ./run-testpattern-2 -s $QUIET "${FASTOPT[@]}" -o - -G 1x1
67}
68
69function test_full() {
70    runit ./run-testpattern-2 -s $QUIET
71    runit ./run-testpattern-2 $QUIET "${FASTOPT[@]}" -dColorCorrection=Raw -o - -G 1x1
72    runit ./run-testpattern-2 -s $QUIET \
73	  -oPageSize,Resolution=MIN,DitherAlgorithm=VeryFast
74    runit ./run-testpattern-2 -s $QUIET "${FASTOPT[@]}" \
75	  -o TPMode,ColorCorrection,InkType,UseGloss
76}
77
78function test_valgrind_minimal() {
79    runit ./run-testpattern-2 -s -v -v "${FASTOPT[@]}" -o InkType \
80	  -o InkSet,RawChannels -o Duplex -o MediaType -o InputSlot \
81	  -o FullBleed -o UseGloss -o Orientation -o LabelSeparator "$@" \
82	  $MIN_PRINTERS
83    runit ./run-testpattern-2 -s -v -v "${FASTOPT[@]}" -o - -G 1x1 "$@" \
84	  $MIN_PRINTERS
85}
86
87function test_valgrind_fast() {
88    test_valgrind_minimal
89    runit ./run-testpattern-2 -s -v -v $QUIET "${FASTOPT[@]}" -o - "$@"
90}
91
92function test_valgrind() {
93    runit ./run-testpattern-2 -s -v -v $QUIET "${FASTOPT[@]}" -o InkType \
94	  -o InkSet,RawChannels -o Duplex -o MediaType -o InputSlot \
95	  -o FullBleed -o UseGloss -o Orientation -o LabelSeparator "$@"
96    runit ./run-testpattern-2 -s -v -v "${FASTOPT[@]}" \
97	  -o TPMode,ColorCorrection,InkType,UseGloss "$@" $MIN_PRINTERS
98    runit ./run-testpattern-2 -s -v -v $QUIET "${FASTOPT[@]}" -dColorCorrection=Raw -o - -G 1x1
99}
100
101function test_checksums() {
102    export STP_DEBUG=$(printf "0x%x" $((0x8000000 | ${STP_DEBUG:-0})))
103    SILENT=1 runit ./run-testpattern-2 -q -M ':4' "$@"
104    SILENT=1 runit ./run-testpattern-2 -F -s -q -M ':4' \
105	  -o PageSize,Resolution=MIN,DitherAlgorithm=VeryFast "$@"
106    SILENT=1 runit ./run-testpattern-2 -F -s -q -M ':4' "${FASTOPT[@]}" \
107	  -o TPMode,ColorCorrection,InkType,UseGloss "$@"
108}
109
110case "$STP_TEST_PROFILE" in
111    full|fast|valgrind|checksums|minimal|valgrind_minimal|valgrind_fast)
112	test_"$STP_TEST_PROFILE"
113	;;
114    *)
115	exit 77
116	;;
117esac
118