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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
#!/bin/sh
# -------------------------------------------------
# LSB test for presence and functionality of foomatic-rip
# -------------------------------------------------
# Modification History:
# 11/15/2007 - Till Kamppeter - till.kamppeter@gmail.com
# -------------------------------------------------
tet_startup="startup" # startup function
tet_cleanup="cleanup" # cleanup function
iclist="ic1 ic2 ic3 ic4 ic5 ic6 ic7 ic8 ic9 ic10 ic11 ic12 ic13"
ic1="tp1"
ic2="tp2"
ic3="tp3"
ic4="tp4"
ic5="tp5"
ic6="tp6"
ic7="tp7"
ic8="tp8"
ic9="tp9"
ic10="tp10"
ic11="tp11"
ic12="tp12"
ic13="tp13"
FOOMATICRIP=`which foomatic-rip`
export PPD=`pwd`"/foomatic-test.ppd"
INPUTFILE=`pwd`"/foomatic-test-input-ps.ps"
IFILE=$INPUTFILE
BASECMDLINE="$FOOMATICRIP --ppd $PPD -o FilterPath="`pwd`"/"
PREVCMDLINE=''
HOSTNAME=`hostname`
JOBTITLE="$USER@$HOSTNAME"
PRIVATECUPSDIR="../../../cups"
if [ -x $PRIVATECUPSDIR/sbin/cupsd ]; then
PSTOPS="$PRIVATECUPSDIR/lib/cups/filter/pstops"
CUPSDCONF="$PRIVATECUPSDIR/etc/cups/cupsd.conf"
CUPSINIT1="xxx"
CUPSINIT2="xxx"
CUPSD="cupsd"
LPADMIN="$PRIVATECUPSDIR/sbin/lpadmin"
LPSTAT="$PRIVATECUPSDIR/bin/lpstat"
LPR="$PRIVATECUPSDIR/bin/lpr"
elif cups-config --version > /dev/null 2>&1; then
PSTOPS=`cups-config --serverbin`"/filter/pstops"
CUPSDCONF=`cups-config --serverroot`"/cupsd.conf"
CUPSINIT1="/etc/init.d/cups"
CUPSINIT2="/etc/init.d/cupsys"
CUPSD="cupsd"
LPADMIN="lpadmin"
LPSTAT="lpstat"
LPR="lpr"
else
PSTOPS="/usr/lib/cups/filter/pstops"
CUPSDCONF="/etc/cups/cupsd.conf"
CUPSINIT1="/etc/init.d/cups"
CUPSINIT2="/etc/init.d/cupsys"
CUPSD="cupsd"
LPADMIN="lpadmin"
LPSTAT="lpstat"
LPR="lpr"
fi
if cups-config --version > /dev/null 2>&1; then
CUPSFILTER=`cups-config --serverbin`"/filter"
else
CUPSFILTER="/usr/lib/cups/filter"
fi
tp1() {
tpstart "Reference III.8.1"
tet_infoline "The implementation provides an exec-able version"
tet_infoline "of the foomatic-rip command in the PATH and in"
tet_infoline "the system's CUPS filter directory (symlink)"
test -x $FOOMATICRIP 2>out.stderr
check_exit_value $? 0
check_nostderr
test -x "$CUPSFILTER/foomatic-rip" 2>out.stderr
check_exit_value $? 0
check_nostderr
tpresult # set result code
}
tp2() {
tpstart "Reference III.8.2"
tet_infoline "foomatic-rip inserts standard PPD options correctly into"
tet_infoline "the PostScript data stream."
test_foomatic_rip 'Option1 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option1\s+Choice2\s*[\n\r]+\s*\<\<\/HWResolution \[1200 600\]\>\> setpagedevice \% Option1: Choice2\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option2 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option2\s+Choice3\s*[\n\r]+\s*\% Option2: Choice3[\n\r]+ \<\<\/Test \[Example3\]\>\> setpagedevice[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option3 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option3\s+Choice1\s*[\n\r]+\s*\% Option3: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option4 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option4\s+Choice1\s*[\n\r]+\s*\% Option4: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option5 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option5\s+Choice1\s*[\n\r]+\s*\% Option5: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option6 (PJL) inserted' '' \
'\@PJL\s+SET\s+TEST6=CHOICE1\s*[\n\r]+'
test_foomatic_rip 'Option7 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option7\s+\S+\s*[\n\r]+\s*\% Option7: True\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option8 (PostScript) inserted' '' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option8\s+\S+\s*[\n\r]+\s*\% Option8: False\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
tpresult # set result code
}
tp3() {
tpstart "Reference III.8.2"
tet_infoline "foomatic-rip inserts standard PPD options into the correct"
tet_infoline "sections of a DSC-compliant PostScript file and withing the"
tet_infoline "sections also in the correct order."
test_foomatic_rip 'JCLSetup: Option6' '' \
'\%\-12345X\@PJL' \
'\@PJL\s+SET\s+TEST6=CHOICE\d' \
'\%\!PS'
test_foomatic_rip 'Prolog: Option5' '' \
'\%\%BeginProlog' \
'\%\%BeginFeature:\s*\*Option5\s+Choice\d' \
'\%\%EndProlog'
test_foomatic_rip 'Setup: PageSize Option1 Option7 Option8 Option2 Option3' '' \
'\%\%BeginSetup' \
'\%\%BeginFeature:\s*\*PageSize\s+\S+' \
'\%\%BeginFeature:\s*\*Option1\s+\S+' \
'\%\%BeginFeature:\s*\*Option7\s+\S+' \
'\%\%BeginFeature:\s*\*Option8\s+\S+' \
'\%\%BeginFeature:\s*\*Option2\s+\S+' \
'\%\%BeginFeature:\s*\*Option3\s+\S+' \
'\%\%EndSetup'
test_foomatic_rip 'PageSetup: Page 1: Option4, Page 2: Option4, Page 3: Option4, Page 4: Option4' '' \
'\%\%Page:\s*1\s+1' \
'\%\%BeginFeature:\s*\*Option4\s+Choice\d' \
'gsave' \
'\%\%Page:\s*2\s+2' \
'\%\%BeginFeature:\s*\*Option4\s+Choice\d' \
'gsave' \
'\%\%Page:\s*3\s+3' \
'\%\%BeginFeature:\s*\*Option4\s+Choice\d' \
'gsave' \
'\%\%Page:\s*4\s+4' \
'\%\%BeginFeature:\s*\*Option4\s+Choice\d' \
'gsave'
tpresult # set result code
}
tp4() {
tpstart "Reference III.8.2"
tet_infoline "foomatic-rip applies user-supplied option settings when"
tet_infoline "inserting PPD option code"
test_foomatic_rip 'Option1 (PostScript) with setting Choice1 inserted' \
'-o Option1=Choice1' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option1\s+Choice1\s*[\n\r]+\s*\<\<\/HWResolution \[1200 1200\]\>\> setpagedevice \% Option1: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option4 (PostScript) with setting Choice3 inserted for all 4 pages' \
'-o Option4=Choice3' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option4\s+Choice3\s*[\n\r]+\s*\% Option4: Choice3\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option4\s+Choice3\s*[\n\r]+\s*\% Option4: Choice3\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option4\s+Choice3\s*[\n\r]+\s*\% Option4: Choice3\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option4\s+Choice3\s*[\n\r]+\s*\% Option4: Choice3\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option6 (PJL) with Choice2 inserted' \
'-o Option6=Choice2' \
'\@PJL\s+SET\s+TEST6=CHOICE2\s*[\n\r]+'
test_foomatic_rip 'Option7 (PostScript) with setting False inserted' \
'-o Option7=False' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option7\s+\S+\s*[\n\r]+\s*\% Option7: False\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option8 (PostScript) with setting True inserted' \
'-o Option8=True' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option8\s+\S+\s*[\n\r]+\s*\% Option8: True\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'Option1 (PostScript) inserted, invalid setting Choice4 ignored' \
'-o Option1=Choice4' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option1\s+Choice2\s*[\n\r]+\s*\<\<\/HWResolution \[1200 600\]\>\> setpagedevice \% Option1: Choice2\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
tpresult # set result code
}
tp5() {
tpstart "Reference III.8.2"
tet_infoline "foomatic-rip applies option settings to the renderer"
tet_infoline "command line"
test_foomatic_rip 'Renderer command line with arguments controlled by PPD options: FoomaticOption1 FoomaticOption7 FoomaticOption8 FoomaticOptionB FoomaticOptionE, check for presence, correct value, and order' \
'' \
'foomatic-test-renderer[^\n\r]* --option1=choice1[^\n\r]* --FoomaticOption7[^\n\r]* --option9=choiceC[^\n\r]* --optionA=choiceF[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE[^\n\r]* --FoomaticOptionE'
test_foomatic_rip 'Changed settings: FoomaticOption1=Choice3' \
'-o FoomaticOption1=Choice3' \
'foomatic-test-renderer[^\n\r]* --option1=choice3[^\n\r]* --FoomaticOption7[^\n\r]* --option9=choiceC[^\n\r]* --optionA=choiceF[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE[^\n\r]* --FoomaticOptionE'
tpresult
}
tp6() {
tpstart "Reference III.8.2"
tet_infoline "foomatic-rip supports composite options, where one option"
tet_infoline "sets all member options"
test_foomatic_rip 'Composite options: FoomaticOption8 (Members FoomaticOption9 FoomaticOptionA), FoomaticOptionB (Members: FoomaticOptionC FoomaticOptionD)' \
'' \
'foomatic-test-renderer[^\n\r]* --option9=choiceC[^\n\r]* --optionA=choiceF[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE'
test_foomatic_rip 'Changing FoomaticOption8' \
'-o FoomaticOption8=Choice1' \
'foomatic-test-renderer[^\n\r]* --option9=choiceA[^\n\r]* --optionA=choiceD[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE'
test_foomatic_rip 'Changing FoomaticOptionB' \
'-o FoomaticOptionB=Choice1' \
'foomatic-test-renderer[^\n\r]* --option9=choiceC[^\n\r]* --optionA=choiceF[^\n\r]* --optionC=choiceA[^\n\r]* --optionD=choiceD'
test_foomatic_rip 'FoomaticOption8 is a normal composite option, member options can be set individually' \
'-o FoomaticOption9=ChoiceB' \
'foomatic-test-renderer[^\n\r]* --option9=choiceB[^\n\r]* --optionA=choiceF[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE'
test_foomatic_rip 'FoomaticOptionB is a forced composite option, member options exist but are not advertized in GUIs' \
'-o FoomaticOptionD=ChoiceF' \
'foomatic-test-renderer[^\n\r]* --option9=choiceC[^\n\r]* --optionA=choiceF[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceF'
tpresult
}
tp7() {
tpstart "Reference III.8.2"
tet_infoline "String and password options allow (nearly) arbitrary strings"
test_foomatic_rip 'FoomaticOption3 is a string option' \
'' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption3\s+Choice1\s*[\n\r]+\s*\% FoomaticOption3: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption3: Another predefined choice (Choice2)' \
'-o FoomaticOption3=Choice2' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption3\s+Choice2\s*[\n\r]+\s*\% FoomaticOption3: Choice2\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption3: A freely chosen string (DFhj_3-4)' \
'-o FoomaticOption3=DFhj_3-4' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption3\s+DFhj_3-4\s*[\n\r]+\s*\% FoomaticOption3: DFhj_3-4\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption3: Too many characters (DFhj_3-45)' \
'-o FoomaticOption3=DFhj_3-45' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption3\s+Choice1\s*[\n\r]+\s*\% FoomaticOption3: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption3: Invalid characters (DFhj;3:4)' \
'-o FoomaticOption3=DFhj;3:4' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption3\s+Choice1\s*[\n\r]+\s*\% FoomaticOption3: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption4 is a password option (same as string, but GUIs hide input)' \
'' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption4\s+Choice1\s*[\n\r]+\s*\% FoomaticOption4: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption4: Valid string (DFhj3545)' \
'-o FoomaticOption4=DFhj3545' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption4\s+DFhj3545\s*[\n\r]+\s*\% FoomaticOption4: DFhj3545\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption4: String does not match regexp (DFhj;3:4)' \
'-o FoomaticOption4=DFhj;3:4' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption4\s+Choice1\s*[\n\r]+\s*\% FoomaticOption4: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
tpresult
}
tp8() {
tpstart "Reference III.8.2"
tet_infoline "Numerical options allow any value in the range"
test_foomatic_rip 'FoomaticOption6 is a floating point numerical option, default 1.2 is not under the given choices' \
'' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption6\s+1.20*\s*[\n\r]+\s*\% FoomaticOption6: \s*1.20*\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption6 set to -2.2, also not under the given choices' \
'-o FoomaticOption6=-2.2' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption6\s+\-2.20*\s*[\n\r]+\s*\% FoomaticOption6: \s*\-2.20*\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption6 set to -4.6, value out of range, therefore ignored.' \
'-o FoomaticOption6=-4.6' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption6\s+1.20*\s*[\n\r]+\s*\% FoomaticOption6: \s*1.20*\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption6 set to 10, also out of range.' \
'-o FoomaticOption6=10' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption6\s+1.20*\s*[\n\r]+\s*\% FoomaticOption6: \s*1.20*\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption5 is an integer numerical option, default is 2' \
'' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption5\s+2\s*[\n\r]+\s*\% FoomaticOption5: \s*2\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption5 set to -7' \
'-o FoomaticOption5=-7' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption5\s+\-7\s*[\n\r]+\s*\% FoomaticOption5: \s*\-7\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_foomatic_rip 'FoomaticOption5 set to 6.7, the digits after the decimal point get cut off.' \
'-o FoomaticOption5=6.7' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption5\s+6\S*\s*[\n\r]+\s*\% FoomaticOption5: \s*6\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
tpresult
}
tp9() {
tpstart "Reference III.8.2"
tet_infoline "Disabled per Bug 1841 (http://bugs.linuxbase.org/show_bug.cgi?id=1841)"
tpresult UNTESTED
return
tet_infoline "Special entities get substituted by job parameters"
test_foomatic_rip 'Job parameters' \
'' \
'foomatic-test-renderer[^\n\r]* --FoomaticOptionE --user='$USER' --host='$HOSTNAME' --title='$USER'\@'$HOSTNAME' --copies=1 --options=\(FilterPath=[^\n\r]* \) --date=\d\d\/\d\d\/\d+ --time=\d\d\:\d\d\:\d\d --special=\&\<\>\"'
tpresult
}
tp10() {
tpstart "Reference III.8.2"
tet_infoline "PJL options from the PPD file get merged into PJL header"
tet_infoline "generated by the printer driver"
test_foomatic_rip 'FoomaticOption2 (PJL) inserted' '' \
'\@PJL\s+SET\s+TEST2=CHOICE1\s*[\n\r]+'
test_foomatic_rip 'Option6 and FoomaticOption2 (both PJL) merged into driver-generated PJL header' \
'-o FoomaticPJLMergeTest=DriverPJL' \
'\%-12345X\@PJL\s+SET\s+TEST2=CHOICE1\s*[\n\r]+\s*\@PJL\s+SET\s+TEST6=CHOICE1\s*[\n\r]+\s*\@PJL\s+SET\s+RESOLUTION=600\s*[\n\r]+\s*\@PJL\s+ENTER\s+LANGUAGE=POSTSCRIPT\s*[\n\r]+'
tpresult
}
tp11() {
tpstart "Reference III.8.2"
tet_infoline "Option settings can be applied to selected pages"
tet_infoline "(page overrides)"
test_foomatic_rip 'PageSetup: Page 1: Option4=Choice1, Page 2: Option4=Choice1, Page 3: Option4=Choice3, Page 4: Option4=Choice1' \
'-o 3:Option4=Choice3' \
'\%\%Page:\s*1\s+1' \
'\%\%BeginFeature:\s*\*Option4\s+Choice1' \
'gsave' \
'\%\%Page:\s*2\s+2' \
'\%\%BeginFeature:\s*\*Option4\s+Choice1' \
'gsave' \
'\%\%Page:\s*3\s+3' \
'\%\%BeginFeature:\s*\*Option4\s+Choice3' \
'gsave' \
'\%\%Page:\s*4\s+4' \
'\%\%BeginFeature:\s*\*Option4\s+Choice1' \
'gsave'
test_foomatic_rip 'FoomaticOption1=Choice3 for pages 2-4' \
'-o 2-4:FoomaticOption1=Choice3' \
'\%\%Page:\s*1\s+1' \
'foomatic-test-renderer[^\n\r]* --option1=choice1' \
'\%\%Page:\s*2\s+2' \
'\%\%Page:\s*3\s+3' \
'\%\%Page:\s*4\s+4' \
'foomatic-test-renderer[^\n\r]* --option1=choice3'
test_foomatic_rip 'FoomaticOption1=Choice3 for odd pages' \
'-o odd:FoomaticOption1=Choice3' \
'\%\%Page:\s*1\s+1' \
'foomatic-test-renderer[^\n\r]* --option1=choice3' \
'\%\%Page:\s*2\s+2' \
'foomatic-test-renderer[^\n\r]* --option1=choice1' \
'\%\%Page:\s*3\s+3' \
'foomatic-test-renderer[^\n\r]* --option1=choice3' \
'\%\%Page:\s*4\s+4' \
'foomatic-test-renderer[^\n\r]* --option1=choice1'
test_foomatic_rip 'FoomaticOption1=Choice3 for pages 1-2 and 4' \
'-o 1-2,4:FoomaticOption1=Choice3' \
'\%\%Page:\s*1\s+1' \
'\%\%Page:\s*2\s+2' \
'foomatic-test-renderer[^\n\r]* --option1=choice3' \
'\%\%Page:\s*3\s+3' \
'foomatic-test-renderer[^\n\r]* --option1=choice1' \
'\%\%Page:\s*4\s+4' \
'foomatic-test-renderer[^\n\r]* --option1=choice3'
tpresult
}
tp12() {
tpstart "Reference III.8.2"
tet_infoline "PostScript code of options in the PostScript data stream"
tet_infoline "gets taken into account, foomatic-rip executes Foomatic"
tet_infoline "options"
IFILE=""
# The CUPS filter pstops inserts the PostScript code of the options
# of the PPD file given by the $PPD environment variable. Usually
# the default option settings are used. Non-default option settings
# can be supplied by the fifth command line argument.
# Note: The environment variable $PPD to tell pstops which PPD to use
# was already set in the beginning of this script
$PSTOPS 0 x y 1 "FoomaticOption2=Choice2" \
$INPUTFILE 2> /dev/null | \
test_foomatic_rip 'FoomaticOption2 with setting Choice2 inserted' \
'' \
'\@PJL\s+SET\s+TEST2=CHOICE2\s*[\n\r]+'
$PSTOPS 0 x y 1 "Option7=False" \
$INPUTFILE 2> /dev/null | \
test_foomatic_rip 'Option7 (PostScript) with setting False inserted' \
'' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option7\s+\S+\s*[\n\r]+\s*\% Option7: False\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
$PSTOPS 0 x y 1 "FoomaticOption8=Choice1" \
$INPUTFILE 2> /dev/null | \
test_foomatic_rip 'Changing FoomaticOption8 (composite option)' \
'' \
'foomatic-test-renderer[^\n\r]* --option9=choiceA[^\n\r]* --optionA=choiceD[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE'
tpresult
}
tp13() {
tpstart "Reference III.8.2"
tet_infoline "foomatic-rip acts as a CUPS filter and recognizes if it is"
tet_infoline "called as such. Also a test for the full printing workflow."
if ! grep -qi "FileDevice *yes" $CUPSDCONF; then
tet_infoline "Adding \"FileDevice Yes\" to cupsd.conf"
tet_infoline "This is needed so that we can print into a file."
echo "FileDevice yes" >> $CUPSDCONF
check_exit_value $? 0
check_nostderr
$CUPSINIT1 restart 2>/dev/null || \
$CUPSINIT2 restart 2>/dev/null || \
killall -HUP $CUPSD 2>/dev/null
check_exit_value $? 0
check_nostderr
sleep 3
FILEDEVICEYESADDED=1
fi
if [ -x $PRIVATECUPSDIR/sbin/cupsd ]; then
ln -s $FOOMATICRIP $PRIVATECUPSDIR/lib/cups/filter/
fi
if [ -e $HOME/.cupsrc ]; then
IPP_PORT=632
HOME=/tmp
export HOME IPP_PORT
fi
tet_infoline "Creating test print queue \"testprinter\""
$LPADMIN -p testprinter -E -v file:/tmp/out.prn -P $PPD
check_exit_value $? 0
check_nostderr
test_cups_job "Default option settings" \
'' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option1\s+Choice2\s*[\n\r]+\s*\<\<\/HWResolution \[1200 600\]\>\> setpagedevice \% Option1: Choice2\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_cups_job "Option setting Option1=Choice1" \
'-o Option1=Choice1' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*Option1\s+Choice1\s*[\n\r]+\s*\<\<\/HWResolution \[1200 1200\]\>\> setpagedevice \% Option1: Choice1\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_cups_job 'Changing FoomaticOption8' \
'-o FoomaticOption8=Choice1' \
'foomatic-test-renderer[^\n\r]* --option9=choiceA[^\n\r]* --optionA=choiceD[^\n\r]* --optionC=choiceB[^\n\r]* --optionD=choiceE'
test_cups_job 'FoomaticOption4: Valid string (DFhj3545)' \
'-o FoomaticOption4=DFhj3545' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption4\s+DFhj3545\s*[\n\r]+\s*\% FoomaticOption4: DFhj3545\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
test_cups_job 'FoomaticOption5 set to -7' \
'-o FoomaticOption5=-7' \
'\[\{\s*[\n\r]+\s*\%\%BeginFeature:\s*\*FoomaticOption5\s+\-7\s*[\n\r]+\s*\% FoomaticOption5: \s*\-7\s*[\n\r]+\s*\%\%EndFeature\s*[\n\r]+\s*\}\s*stopped\s+cleartomark'
tet_infoline "Next test is with --user option, does not run on all LSB-compliant systems, see http://bugs.linuxbase.org/show_bug.cgi?id=1841"
test_cups_job 'Job parameters' \
'' \
'foomatic-test-renderer[^\n\r]* --FoomaticOptionE --user='$USER' --host='$HOSTNAME' --title=TEST --copies=1 --options=\([^\n\r]*\) --date=\d\d\/\d\d\/\d+ --time=\d\d\:\d\d\:\d\d --special=\&\<\>\"'
test_cups_job 'FoomaticOption2 (PJL) inserted' '' \
'\@PJL\s+SET\s+TEST2=CHOICE1\s*[\n\r]+'
test_cups_job 'Option6 and FoomaticOption2 (both PJL) merged into driver-generated PJL header' \
'-o FoomaticPJLMergeTest=DriverPJL' \
'\%-12345X\@PJL\s+SET\s+TEST2=CHOICE1\s*[\n\r]+\s*\@PJL\s+SET\s+TEST6=CHOICE1\s*[\n\r]+\s*\@PJL\s+SET\s+RESOLUTION=600\s*[\n\r]+\s*\@PJL\s+ENTER\s+LANGUAGE=POSTSCRIPT\s*[\n\r]+'
test_cups_job 'FoomaticOption1=Choice3 for pages 1-2 and 4' \
'-o 1-2,4:FoomaticOption1=Choice3' \
'\%\%Page:\s*1\s+1' \
'\%\%Page:\s*2\s+2' \
'foomatic-test-renderer[^\n\r]* --option1=choice3' \
'\%\%Page:\s*3\s+3' \
'foomatic-test-renderer[^\n\r]* --option1=choice1' \
'\%\%Page:\s*4\s+4' \
'foomatic-test-renderer[^\n\r]* --option1=choice3'
tet_infoline "Removing test print queue \"testprinter\""
$LPADMIN -x testprinter
check_exit_value $? 0
check_nostderr
if [ -x $PRIVATECUPSDIR/sbin/cupsd ]; then
rm -f $PRIVATECUPSDIR/lib/cups/filter/foomatic-rip
fi
if [ "$FILEDEVICEYESADDED" = "1" ]; then
tet_infoline "Removing \"FileDevice yes\" from cupsd.conf"
perl -p -i -e 's/FileDevice yes\n//sm' $CUPSDCONF
check_exit_value $? 0
check_nostderr
$CUPSINIT1 restart 2>/dev/null || \
$CUPSINIT2 restart 2>/dev/null || \
killall -HUP $CUPSD 2>/dev/null
check_exit_value $? 0
check_nostderr
fi
tpresult
}
test_foomatic_rip() {
COMMENT=$1
shift
EXTRAOPTS=$1
shift
CMDLINE="$BASECMDLINE $EXTRAOPTS $IFILE"
if [ "$CMDLINE" != "$PREVCMDLINE" ]
then
tet_infoline "Executing $CMDLINE"
$CMDLINE > out.stdout 2>out.stderr
PREVCMDLINE="$CMDLINE"
fi
check_exit_value $? 0
check_nostderr
SEARCHTERM=''
while [ -n "$1" ]
do
if [ -n "$SEARCHTERM" ]
then
SEARCHTERM=$SEARCHTERM'.*'
fi
SEARCHTERM=$SEARCHTERM`/bin/echo "$1" | sed 's/ /\\\\x20/g'`
shift
done
tet_infoline "Checking: $COMMENT"
check_stdout_binary_P $SEARCHTERM
}
test_cups_job () {
COMMENT=$1
shift
EXTRAOPTS=$1
shift
SEARCHTERM=''
while [ -n "$1" ]
do
if [ -n "$SEARCHTERM" ]
then
SEARCHTERM=$SEARCHTERM'.*'
fi
SEARCHTERM=$SEARCHTERM`/bin/echo "$1" | sed 's/ /\\\\x20/g'`
shift
done
tet_infoline "$COMMENT"
tet_infoline "Sending print job with option settings \"$EXTRAOPTS\""
$LPR -P testprinter -J "TEST" -o FilterPath=`pwd`'/' $EXTRAOPTS $INPUTFILE
check_exit_value $? 0
check_nostderr
counter=30
while [ "`$LPSTAT -o testprinter | wc -l`" != "0" ]; do
counter=$(($counter - 1))
if [ "$counter" = "0" ]; then
tet_infoline "Print job timeout"
FAIL=Y
break
fi
sleep 1
done
chown $USER out.stdout
check_exit_value $? 0
check_nostderr
cat /tmp/out.prn | perl -e 'my $a = join("",<>); exit !($a =~ /'$SEARCHTERM'/sm)'
if [ $? -ne 0 ]
then
tet_infoline "Output written to stdout did not contain \""`echo $SEARCHTERM | perl -p -e 's/\\\\/\\\\\\\\/g'`"\""
FAIL=Y
fi
}
# This is a derived function from LIB/shfuncs.sh/check_stdout()
# It checks whether string $1 is present in file out.stdout
# Differences:
# 1. It does not output file when check_stdout failed
# 2. It's using Perl rather than grep (grep -P is not available in all distros)
check_stdout_binary_P() # check that a string went to stdout
{
case $1 in
"")
if [ ! -s out.stdout ]
then
tet_infoline "Expected output to stdout, but none written"
FAIL=Y
fi
;;
*)
cat out.stdout | perl -e 'my $a = join("",<>); exit !($a =~ /'$1'/sm)'
if [ $? -ne 0 ]
then
tet_infoline "Output written to stdout did not contain \""`echo $1 | perl -p -e 's/\\\\/\\\\\\\\/g'`"\""
FAIL=Y
fi
;;
esac
}
startup() {
rm -f tet_xres
}
cleanup() {
if [ -f tet_xres ];then
#mv tet_xres journal.gs-test
rm -f out.stdout
rm -f out.stderr
rm -f /tmp/out.prn
fi
}
# source common shell functions
. ./shfuncs.sh
. ./lsbfuncs.sh
# execute shell test case manager - must be last line
. ./tcm.sh
|