blob: 40e7b4931e75e333b3079ef1424d29a96bb1445c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
#!@SHELL@
retval=0
if [ -z "$srcdir" -o "$srcdir" = "." ] ; then
sdir=`pwd`
elif [ -n "`echo $srcdir |grep '^/'`" ] ; then
sdir="$srcdir"
else
sdir="`pwd`/$srcdir"
fi
if [ -z "$STP_DATA_PATH" ] ; then
STP_DATA_PATH="$sdir/../xml"
export STP_DATA_PATH
fi
if [ -z "$STP_MODULE_PATH" ] ; then
STP_MODULE_PATH="$sdir/../main:$sdir/../main/.libs"
export STP_MODULE_PATH
fi
single=''
all_models=''
verbose=''
make_ppds=1
md5dir=''
outdir=''
cupsargs=''
usage() {
echo "Usage: test-rastertogutenprint [-s] [-v|--valgrind]"
exit 0;
}
set_args() {
while true ; do
case "$1" in
-s) single=1 ;;
-h*|--h*) usage ;;
-v|--valgrind) valopts='--tool=memcheck' ; valgrind=`expr $valgrind + 1` ;;
-c|--cachegrind) valopts='--tool=cachegrind'; valgrind=4 ;;
-g|--gdb-attach) valopts='--gdb-attach=yes' ;;
-V|--verbose) verbose=1 ;;
-n|--no-make-ppds) make_ppds='' ;;
-O|--output) shift; outdir="$1" ;;
-o|--option) shift; cupsargs="$cupsargs $1" ;;
-m|--md5dir) shift; md5dir="$1" ;;
--) shift; args="$@"; return ;;
*) return ;;
esac
shift
done
}
set_args `getopt vcgsVnO:m:o: "$@"`
if [ -n "$outdir" -a ! -d "$outdir" ] ; then
mkdir -p "$outdir"
fi
if [ -n "$md5dir" -a ! -d "$md5dir" ] ; then
mkdir -p "$md5dir"
fi
version="@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@";
cupsdir="@cups_conf_serverbin@/filter"
if [ -x "$cupsdir/pstoraster" ] ; then
pages='page-ranges=24-26 '
else
pages=''
fi
if [ ! -x "$cupsdir/cgpdftoraster" -a ! -x "$cupsdir/pdftops" ] ; then
echo 'CUPS does not appear to be installed, skipping test'
exit 0
fi
cleanup() {
if [ -f "$tfile" ] ; then
rm -f $tfile
fi
exit 1
}
pdftops="`type -p pdftops`"
if [ -n "$pdftops" -a ! -x "$cupsdir/cgpdftoraster" ] ; then
tfile=`mktemp`
trap cleanup 1 2 3 6 14 15 30
$pdftops -f 24 -l 26 "$sdir/../../doc/gutenprint-users-manual.pdf" $tfile
fi
if [ -z "$verbose" ] ; then
STP_SUPPRESS_MESSAGES=1
export STP_SUPPRESS_MESSAGES
fi
is_duplicate() {
model=`gunzip -c "$1" | grep '^.StpDriverModelFamily' | awk '{print $2}'`
for m in $all_models; do
if [ "$model" = "$m" ] ; then
skip=1
fi
done
all_models="$model $all_models"
}
# Note that using CUPS arguments may trigger valgrind memory leaks in
# CUPS.
#cupsargs='PageSize=Custom.400.00x500.00'
#cupsargs='PageSize=Custom.324x495 Resolution=180dpi'
#cupsargs='PageSize=w324h495 Resolution=180dpi'
#cupsargs='PageSize=A8'
run_rastertogp() {
case "$valgrind" in
1) valgrind $valopts -q --num-callers=100 --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;;
2) valgrind $valopts --num-callers=100 --leak-resolution=high --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;;
3) valgrind $valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;;
4) valgrind $valopts ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;;
*) ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;;
esac
if [ $? -ne 0 ] ; then
retval=1
fi
exit $retval
}
get_ppds() {
args="$@"
if [ -n "$args" ] ; then
for f in "$@" ; do
if [ -r "$f" ] ; then
echo $f
elif [ -r "ppd/C/$f" ] ; then
echo "ppd/C/$f"
elif [ -f "ppd/C/${f}.ppd" ] ; then
echo "ppd/C/${f}.ppd"
elif [ -f "ppd/C/${f}.ppd.gz" ] ; then
echo "ppd/C/${f}.ppd.gz"
elif [ -f "ppd/C/${f}.ppd.GZ" ] ; then
echo "ppd/C/${f}.ppd.GZ"
elif [ -f "ppd/C/${f}.ppd.bz2" ] ; then
echo "ppd/C/${f}.ppd.bz2"
elif [ -f "ppd/C/${f}.ppd.BZ2" ] ; then
echo "ppd/C/${f}.ppd.BZ2"
elif [ -f "ppd/C/${f}.ppd.z" ] ; then
echo "ppd/C/${f}.ppd.z"
elif [ -f "ppd/C/${f}.ppd.Z" ] ; then
echo "ppd/C/${f}.ppd.Z"
elif [ -f "ppd/C/stp-${f}.ppd" ] ; then
echo "ppd/C/stp-${f}.ppd"
elif [ -f "ppd/C/stp-${f}.ppd.gz" ] ; then
echo "ppd/C/stp-${f}.ppd.gz"
elif [ -f "ppd/C/stp-${f}.ppd.GZ" ] ; then
echo "ppd/C/stp-${f}.ppd.GZ"
elif [ -f "ppd/C/stp-${f}.ppd.bz2" ] ; then
echo "ppd/C/stp-${f}.ppd.bz2"
elif [ -f "ppd/C/stp-${f}.ppd.BZ2" ] ; then
echo "ppd/C/stp-${f}.ppd.BZ2"
elif [ -f "ppd/C/stp-${f}.ppd.z" ] ; then
echo "ppd/C/stp-${f}.ppd.z"
elif [ -f "ppd/C/stp-${f}.ppd.Z" ] ; then
echo "ppd/C/stp-${f}.ppd.Z"
elif [ -f "ppd/C/stp-${f}.${version}.ppd" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd"
elif [ -f "ppd/C/stp-${f}.${version}.ppd.gz" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd.gz"
elif [ -f "ppd/C/stp-${f}.${version}.ppd.GZ" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd.GZ"
elif [ -f "ppd/C/stp-${f}.${version}.ppd.bz2" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd.bz2"
elif [ -f "ppd/C/stp-${f}.${version}.ppd.BZ2" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd.BZ2"
elif [ -f "ppd/C/stp-${f}.${version}.ppd.z" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd.z"
elif [ -f "ppd/C/stp-${f}.${version}.ppd.Z" ] ; then
echo "ppd/C/stp-${f}.${version}.ppd.Z"
fi
done
else
echo ppd/C/*.ppd*
fi
}
if [ -n "$make_ppds" -o ! -d ppd/C ] ; then
make ppd-nonls
fi
do_output() {
if [ -n "`echo "$PPD" |grep '\.gz$'`" ] ; then
driver=`gunzip -c "$PPD" | grep '^\*StpDriverName:' |awk '{print $2}' | sed 's/"//g'`
else
driver=`grep '^\*StpDriverName:' "$PPD" |awk '{print $2}' | sed 's/"//g'`
fi
if [ -n "$outdir" ] ; then
cat > "$outdir/$driver.prn"
if [ -n "$md5dir" ] ; then
(cd "$outdir"; cat "$driver.prn") | md5sum | sed "s/-/\*$driver/" > "$md5dir/$driver.md5"
fi
elif [ -n "$md5dir" ] ; then
cat | md5sum | sed "s/-/\*$driver/" > "$md5dir/$driver.md5"
else
cat > /dev/null
fi
}
if [ -d ppd/C ] ; then
for f in `get_ppds $args` ; do
skip=''
if [ -n "$single" ] ; then
is_duplicate $f
fi
if [ -z "$skip" ] ; then
echo "$f "
PPD=$f
export PPD
if [ -x "$cupsdir/cgpdftoraster" ] ; then
output="`($cupsdir/cgpdftoraster 1 1 1 1 $pages < $sdir/../../doc/gutenprint-users-manual.pdf 2>/dev/null | run_rastertogp | do_output) 2>&1`"
elif [ -f "$tfile" ] ; then
output="`($cupsdir/pstops 1 1 1 1 \"$cupsargs\" < $tfile 2>/dev/null | $cupsdir/pstoraster 2>/dev/null | run_rastertogp | do_output) 2>&1`"
elif [ -x "$cupsdir/pstoraster" ] ; then
output="`($cupsdir/pdftops 1 1 1 1 \"$pages$cupsargs\" < $sdir/../../doc/gutenprint-users-manual.pdf 2>/dev/null | $cupsdir/pstops 1 1 1 1 \"$pages$cupsargs\" 2>/dev/null | $cupsdir/pstoraster 2>/dev/null | run_rastertogp | do_output) 2>&1`"
else
output="`($cupsdir/imagetoraster 1 1 1 1 \"$pages$cupsargs\" < calibrate.ppm 2>/dev/null | run_rastertogp | do_output) 2>&1`"
fi
if [ $? -ne 0 ] ; then
retval=1
fi
echo "$output"
echo "$output" |grep ERROR
if [ $? -eq 0 ] ; then
retval=1
fi
fi
done
fi
if [ -f "$tfile" ] ; then
rm -f $tfile
fi
exit $retval
|