]> git.ipfire.org Git - thirdparty/cups.git/blob - filter/testraster.c
48085c4fbca6e701331ad6c02ae5927ccc4e5a2b
[thirdparty/cups.git] / filter / testraster.c
1 /*
2 * "$Id: testraster.c 7376 2008-03-19 21:07:45Z mike $"
3 *
4 * Raster test program routines for CUPS.
5 *
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 *
17 * Contents:
18 *
19 * main() - Test the raster functions.
20 * do_ppd_tests() - Test the default option commands in a PPD file.
21 * do_ps_tests() - Test standard PostScript commands.
22 * do_raster_tests() - Test reading and writing of raster data.
23 * print_changes() - Print differences in the page header.
24 */
25
26 /*
27 * Include necessary headers...
28 */
29
30 #include "image-private.h"
31
32
33 /*
34 * Test PS commands and header...
35 */
36
37 static const char *dsc_code =
38 "[{\n"
39 "%%BeginFeature: *PageSize Tabloid\n"
40 "<</PageSize[792 1224]>>setpagedevice\n"
41 "%%EndFeature\n"
42 "} stopped cleartomark\n";
43 static const char *setpagedevice_code =
44 "<<"
45 "/MediaClass(Media Class)"
46 "/MediaColor((Media Color))"
47 "/MediaType(Media\\\\Type)"
48 "/OutputType<416263>"
49 "/AdvanceDistance 1000"
50 "/AdvanceMedia 1"
51 "/Collate false"
52 "/CutMedia 2"
53 "/Duplex true"
54 "/HWResolution[100 200]"
55 "/InsertSheet true"
56 "/Jog 3"
57 "/LeadingEdge 1"
58 "/ManualFeed true"
59 "/MediaPosition 8#777"
60 "/MediaWeight 16#fe01"
61 "/MirrorPrint true"
62 "/NegativePrint true"
63 "/NumCopies 1"
64 "/Orientation 1"
65 "/OutputFaceUp true"
66 "/PageSize[612 792.1]"
67 "/Separations true"
68 "/TraySwitch true"
69 "/Tumble true"
70 "/cupsMediaType 2"
71 "/cupsColorOrder 1"
72 "/cupsColorSpace 1"
73 "/cupsCompression 1"
74 "/cupsRowCount 1"
75 "/cupsRowFeed 1"
76 "/cupsRowStep 1"
77 "/cupsBorderlessScalingFactor 1.001"
78 "/cupsInteger0 1"
79 "/cupsInteger1 2"
80 "/cupsInteger2 3"
81 "/cupsInteger3 4"
82 "/cupsInteger4 5"
83 "/cupsInteger5 6"
84 "/cupsInteger6 7"
85 "/cupsInteger7 8"
86 "/cupsInteger8 9"
87 "/cupsInteger9 10"
88 "/cupsInteger10 11"
89 "/cupsInteger11 12"
90 "/cupsInteger12 13"
91 "/cupsInteger13 14"
92 "/cupsInteger14 15"
93 "/cupsInteger15 16"
94 "/cupsReal0 1.1"
95 "/cupsReal1 2.1"
96 "/cupsReal2 3.1"
97 "/cupsReal3 4.1"
98 "/cupsReal4 5.1"
99 "/cupsReal5 6.1"
100 "/cupsReal6 7.1"
101 "/cupsReal7 8.1"
102 "/cupsReal8 9.1"
103 "/cupsReal9 10.1"
104 "/cupsReal10 11.1"
105 "/cupsReal11 12.1"
106 "/cupsReal12 13.1"
107 "/cupsReal13 14.1"
108 "/cupsReal14 15.1"
109 "/cupsReal15 16.1"
110 "/cupsString0(1)"
111 "/cupsString1(2)"
112 "/cupsString2(3)"
113 "/cupsString3(4)"
114 "/cupsString4(5)"
115 "/cupsString5(6)"
116 "/cupsString6(7)"
117 "/cupsString7(8)"
118 "/cupsString8(9)"
119 "/cupsString9(10)"
120 "/cupsString10(11)"
121 "/cupsString11(12)"
122 "/cupsString12(13)"
123 "/cupsString13(14)"
124 "/cupsString14(15)"
125 "/cupsString15(16)"
126 "/cupsMarkerType(Marker Type)"
127 "/cupsRenderingIntent(Rendering Intent)"
128 "/cupsPageSizeName(Letter)"
129 "/cupsPreferredBitsPerColor 17"
130 ">> setpagedevice";
131
132 static cups_page_header2_t setpagedevice_header =
133 {
134 "Media Class", /* MediaClass */
135 "(Media Color)", /* MediaColor */
136 "Media\\Type", /* MediaType */
137 "Abc", /* OutputType */
138 1000, /* AdvanceDistance */
139 CUPS_ADVANCE_FILE, /* AdvanceMedia */
140 CUPS_FALSE, /* Collate */
141 CUPS_CUT_JOB, /* CutMedia */
142 CUPS_TRUE, /* Duplex */
143 { 100, 200 }, /* HWResolution */
144 { 0, 0, 0, 0 }, /* ImagingBoundingBox */
145 CUPS_TRUE, /* InsertSheet */
146 CUPS_JOG_SET, /* Jog */
147 CUPS_EDGE_RIGHT, /* LeadingEdge */
148 { 0, 0 }, /* Margins */
149 CUPS_TRUE, /* ManualFeed */
150 0777, /* MediaPosition */
151 0xfe01, /* MediaWeight */
152 CUPS_TRUE, /* MirrorPrint */
153 CUPS_TRUE, /* NegativePrint */
154 1, /* NumCopies */
155 CUPS_ORIENT_90, /* Orientation */
156 CUPS_TRUE, /* OutputFaceUp */
157 { 612, 792 }, /* PageSize */
158 CUPS_TRUE, /* Separations */
159 CUPS_TRUE, /* TraySwitch */
160 CUPS_TRUE, /* Tumble */
161 0, /* cupsWidth */
162 0, /* cupsHeight */
163 2, /* cupsMediaType */
164 0, /* cupsBitsPerColor */
165 0, /* cupsBitsPerPixel */
166 0, /* cupsBytesPerLine */
167 CUPS_ORDER_BANDED, /* cupsColorOrder */
168 CUPS_CSPACE_RGB, /* cupsColorSpace */
169 1, /* cupsCompression */
170 1, /* cupsRowCount */
171 1, /* cupsRowFeed */
172 1, /* cupsRowStep */
173 0, /* cupsNumColors */
174 1.001, /* cupsBorderlessScalingFactor */
175 { 612.0, 792.1 }, /* cupsPageSize */
176 { 0.0, 0.0, 0.0, 0.0 }, /* cupsImagingBBox */
177 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
178 /* cupsInteger[16] */
179 { 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1, 11.1, 12.1, 13.1,
180 14.1, 15.1, 16.1 }, /* cupsReal[16] */
181 { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
182 "14", "15", "16" }, /* cupsString[16] */
183 "Marker Type", /* cupsMarkerType */
184 "Rendering Intent", /* cupsRenderingIntent */
185 "Letter" /* cupsPageSizeName */
186 };
187
188
189 /*
190 * Local functions...
191 */
192
193 static int do_ppd_tests(const char *filename, int num_options,
194 cups_option_t *options);
195 static int do_ps_tests(void);
196 static int do_raster_tests(cups_mode_t mode);
197 static void print_changes(cups_page_header2_t *header,
198 cups_page_header2_t *expected);
199
200
201 /*
202 * 'main()' - Test the raster functions.
203 */
204
205 int /* O - Exit status */
206 main(int argc, /* I - Number of command-line args */
207 char *argv[]) /* I - Command-line arguments */
208 {
209 int errors; /* Number of errors */
210
211
212 if (argc == 1)
213 {
214 errors = do_ps_tests();
215 errors += do_raster_tests(CUPS_RASTER_WRITE);
216 errors += do_raster_tests(CUPS_RASTER_WRITE_COMPRESSED);
217 errors += do_raster_tests(CUPS_RASTER_WRITE_PWG);
218 }
219 else
220 {
221 int i; /* Looping var */
222 int num_options; /* Number of options */
223 cups_option_t *options; /* Options */
224
225
226 for (errors = 0, num_options = 0, options = NULL, i = 1; i < argc; i ++)
227 {
228 if (argv[i][0] == '-')
229 {
230 if (argv[i][1] == 'o')
231 {
232 if (argv[i][2])
233 num_options = cupsParseOptions(argv[i] + 2, num_options, &options);
234 else
235 {
236 i ++;
237 if (i < argc)
238 num_options = cupsParseOptions(argv[i], num_options, &options);
239 else
240 {
241 puts("Usage: testraster [-o name=value ...] [filename.ppd ...]");
242 return (1);
243 }
244 }
245 }
246 else
247 {
248 puts("Usage: testraster [-o name=value ...] [filename.ppd ...]");
249 return (1);
250 }
251 }
252 else
253 errors += do_ppd_tests(argv[i], num_options, options);
254 }
255
256 cupsFreeOptions(num_options, options);
257 }
258
259 return (errors);
260 }
261
262
263 /*
264 * 'do_ppd_tests()' - Test the default option commands in a PPD file.
265 */
266
267 static int /* O - Number of errors */
268 do_ppd_tests(const char *filename, /* I - PPD file */
269 int num_options, /* I - Number of options */
270 cups_option_t *options) /* I - Options */
271 {
272 ppd_file_t *ppd; /* PPD file data */
273 cups_page_header2_t header; /* Page header */
274
275
276 printf("\"%s\": ", filename);
277 fflush(stdout);
278
279 if ((ppd = ppdOpenFile(filename)) == NULL)
280 {
281 ppd_status_t status; /* Status from PPD loader */
282 int line; /* Line number containing error */
283
284
285 status = ppdLastError(&line);
286
287 puts("FAIL (bad PPD file)");
288 printf(" %s on line %d\n", ppdErrorString(status), line);
289
290 return (1);
291 }
292
293 ppdMarkDefaults(ppd);
294 cupsMarkOptions(ppd, num_options, options);
295
296 if (cupsRasterInterpretPPD(&header, ppd, 0, NULL, NULL))
297 {
298 puts("FAIL (error from function)");
299 puts(cupsRasterErrorString());
300
301 return (1);
302 }
303 else
304 {
305 puts("PASS");
306
307 return (0);
308 }
309 }
310
311
312 /*
313 * 'do_ps_tests()' - Test standard PostScript commands.
314 */
315
316 static int
317 do_ps_tests(void)
318 {
319 cups_page_header2_t header; /* Page header */
320 int preferred_bits; /* Preferred bits */
321 int errors = 0; /* Number of errors */
322
323
324 /*
325 * Test PS exec code...
326 */
327
328 fputs("_cupsRasterExecPS(\"setpagedevice\"): ", stdout);
329 fflush(stdout);
330
331 memset(&header, 0, sizeof(header));
332 header.Collate = CUPS_TRUE;
333 preferred_bits = 0;
334
335 if (_cupsRasterExecPS(&header, &preferred_bits, setpagedevice_code))
336 {
337 puts("FAIL (error from function)");
338 puts(cupsRasterErrorString());
339 errors ++;
340 }
341 else if (preferred_bits != 17 ||
342 memcmp(&header, &setpagedevice_header, sizeof(header)))
343 {
344 puts("FAIL (bad header)");
345
346 if (preferred_bits != 17)
347 printf(" cupsPreferredBitsPerColor %d, expected 17\n",
348 preferred_bits);
349
350 print_changes(&setpagedevice_header, &header);
351 errors ++;
352 }
353 else
354 puts("PASS");
355
356 fputs("_cupsRasterExecPS(\"roll\"): ", stdout);
357 fflush(stdout);
358
359 if (_cupsRasterExecPS(&header, &preferred_bits,
360 "792 612 0 0 0\n"
361 "pop pop pop\n"
362 "<</PageSize[5 -2 roll]/ImagingBBox null>>"
363 "setpagedevice\n"))
364 {
365 puts("FAIL (error from function)");
366 puts(cupsRasterErrorString());
367 errors ++;
368 }
369 else if (header.PageSize[0] != 792 || header.PageSize[1] != 612)
370 {
371 printf("FAIL (PageSize [%d %d], expected [792 612])\n", header.PageSize[0],
372 header.PageSize[1]);
373 errors ++;
374 }
375 else
376 puts("PASS");
377
378 fputs("_cupsRasterExecPS(\"dup index\"): ", stdout);
379 fflush(stdout);
380
381 if (_cupsRasterExecPS(&header, &preferred_bits,
382 "true false dup\n"
383 "<</Collate 4 index"
384 "/Duplex 5 index"
385 "/Tumble 6 index>>setpagedevice\n"
386 "pop pop pop"))
387 {
388 puts("FAIL (error from function)");
389 puts(cupsRasterErrorString());
390 errors ++;
391 }
392 else
393 {
394 if (!header.Collate)
395 {
396 printf("FAIL (Collate false, expected true)\n");
397 errors ++;
398 }
399
400 if (header.Duplex)
401 {
402 printf("FAIL (Duplex true, expected false)\n");
403 errors ++;
404 }
405
406 if (header.Tumble)
407 {
408 printf("FAIL (Tumble true, expected false)\n");
409 errors ++;
410 }
411
412 if(header.Collate && !header.Duplex && !header.Tumble)
413 puts("PASS");
414 }
415
416 fputs("_cupsRasterExecPS(\"%%Begin/EndFeature code\"): ", stdout);
417 fflush(stdout);
418
419 if (_cupsRasterExecPS(&header, &preferred_bits, dsc_code))
420 {
421 puts("FAIL (error from function)");
422 puts(cupsRasterErrorString());
423 errors ++;
424 }
425 else if (header.PageSize[0] != 792 || header.PageSize[1] != 1224)
426 {
427 printf("FAIL (bad PageSize [%d %d], expected [792 1224])\n",
428 header.PageSize[0], header.PageSize[1]);
429 errors ++;
430 }
431 else
432 puts("PASS");
433
434 #if 0
435 fputs("_cupsRasterExecPS(\"\"): ", stdout);
436 fflush(stdout);
437
438 if (_cupsRasterExecPS(&header, &preferred_bits,
439 ""))
440 {
441 puts("FAIL (error from function)");
442 errors ++;
443 }
444 else if (header.)
445 {
446 printf("FAIL ()\n");
447 errors ++;
448 }
449 else
450 puts("PASS");
451
452 fputs("_cupsRasterExecPS(\"\"): ", stdout);
453 fflush(stdout);
454
455 if (_cupsRasterExecPS(&header, &preferred_bits,
456 ""))
457 {
458 puts("FAIL (error from function)");
459 errors ++;
460 }
461 else if (header.)
462 {
463 printf("FAIL ()\n");
464 errors ++;
465 }
466 else
467 puts("PASS");
468
469 fputs("_cupsRasterExecPS(\"\"): ", stdout);
470 fflush(stdout);
471
472 if (_cupsRasterExecPS(&header, &preferred_bits,
473 ""))
474 {
475 puts("FAIL (error from function)");
476 errors ++;
477 }
478 else if (header.)
479 {
480 printf("FAIL ()\n");
481 errors ++;
482 }
483 else
484 puts("PASS");
485
486 fputs("_cupsRasterExecPS(\"\"): ", stdout);
487 fflush(stdout);
488
489 if (_cupsRasterExecPS(&header, &preferred_bits,
490 ""))
491 {
492 puts("FAIL (error from function)");
493 errors ++;
494 }
495 else if (header.)
496 {
497 printf("FAIL ()\n");
498 errors ++;
499 }
500 else
501 puts("PASS");
502
503 fputs("_cupsRasterExecPS(\"\"): ", stdout);
504 fflush(stdout);
505
506 if (_cupsRasterExecPS(&header, &preferred_bits,
507 ""))
508 {
509 puts("FAIL (error from function)");
510 errors ++;
511 }
512 else if (header.)
513 {
514 printf("FAIL ()\n");
515 errors ++;
516 }
517 else
518 puts("PASS");
519 #endif /* 0 */
520
521 return (errors);
522 }
523
524
525 /*
526 * 'do_raster_tests()' - Test reading and writing of raster data.
527 */
528
529 static int /* O - Number of errors */
530 do_raster_tests(cups_mode_t mode) /* O - Write mode */
531 {
532 int page, x, y; /* Looping vars */
533 FILE *fp; /* Raster file */
534 cups_raster_t *r; /* Raster stream */
535 cups_page_header2_t header, /* Page header */
536 expected; /* Expected page header */
537 unsigned char data[2048]; /* Raster data */
538 int errors = 0; /* Number of errors */
539
540
541 /*
542 * Test writing...
543 */
544
545 printf("cupsRasterOpen(%s): ",
546 mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE" :
547 mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE_COMPRESSED" :
548 "CUPS_RASTER_WRITE_PWG");
549 fflush(stdout);
550
551 if ((fp = fopen("test.raster", "wb")) == NULL)
552 {
553 printf("FAIL (%s)\n", strerror(errno));
554 return (1);
555 }
556
557 if ((r = cupsRasterOpen(fileno(fp), mode)) == NULL)
558 {
559 printf("FAIL (%s)\n", strerror(errno));
560 fclose(fp);
561 return (1);
562 }
563
564 puts("PASS");
565
566 for (page = 0; page < 4; page ++)
567 {
568 memset(&header, 0, sizeof(header));
569 header.cupsWidth = 256;
570 header.cupsHeight = 256;
571 header.cupsBytesPerLine = 256;
572
573 if (page & 1)
574 {
575 header.cupsBytesPerLine *= 2;
576 header.cupsColorSpace = CUPS_CSPACE_CMYK;
577 header.cupsColorOrder = CUPS_ORDER_CHUNKED;
578 header.cupsNumColors = 4;
579 }
580 else
581 {
582 header.cupsColorSpace = CUPS_CSPACE_K;
583 header.cupsColorOrder = CUPS_ORDER_BANDED;
584 header.cupsNumColors = 1;
585 }
586
587 if (page & 2)
588 {
589 header.cupsBytesPerLine *= 2;
590 header.cupsBitsPerColor = 16;
591 header.cupsBitsPerPixel = (page & 1) ? 64 : 16;
592 }
593 else
594 {
595 header.cupsBitsPerColor = 8;
596 header.cupsBitsPerPixel = (page & 1) ? 32 : 8;
597 }
598
599 if (cupsRasterWriteHeader2(r, &header))
600 puts("cupsRasterWriteHeader2: PASS");
601 else
602 {
603 puts("cupsRasterWriteHeader2: FAIL");
604 errors ++;
605 }
606
607 fputs("cupsRasterWritePixels: ", stdout);
608 fflush(stdout);
609
610 memset(data, 0, header.cupsBytesPerLine);
611 for (y = 0; y < 64; y ++)
612 if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
613 break;
614
615 if (y < 64)
616 {
617 puts("FAIL");
618 errors ++;
619 }
620 else
621 {
622 for (x = 0; x < header.cupsBytesPerLine; x ++)
623 data[x] = x;
624
625 for (y = 0; y < 64; y ++)
626 if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
627 break;
628
629 if (y < 64)
630 {
631 puts("FAIL");
632 errors ++;
633 }
634 else
635 {
636 memset(data, 255, header.cupsBytesPerLine);
637 for (y = 0; y < 64; y ++)
638 if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
639 break;
640
641 if (y < 64)
642 {
643 puts("FAIL");
644 errors ++;
645 }
646 else
647 {
648 for (x = 0; x < header.cupsBytesPerLine; x ++)
649 data[x] = x / 4;
650
651 for (y = 0; y < 64; y ++)
652 if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
653 break;
654
655 if (y < 64)
656 {
657 puts("FAIL");
658 errors ++;
659 }
660 else
661 puts("PASS");
662 }
663 }
664 }
665 }
666
667 cupsRasterClose(r);
668 fclose(fp);
669
670 /*
671 * Test reading...
672 */
673
674 fputs("cupsRasterOpen(CUPS_RASTER_READ): ", stdout);
675 fflush(stdout);
676
677 if ((fp = fopen("test.raster", "rb")) == NULL)
678 {
679 printf("FAIL (%s)\n", strerror(errno));
680 return (1);
681 }
682
683 if ((r = cupsRasterOpen(fileno(fp), CUPS_RASTER_READ)) == NULL)
684 {
685 printf("FAIL (%s)\n", strerror(errno));
686 fclose(fp);
687 return (1);
688 }
689
690 puts("PASS");
691
692 for (page = 0; page < 4; page ++)
693 {
694 memset(&expected, 0, sizeof(expected));
695 expected.cupsWidth = 256;
696 expected.cupsHeight = 256;
697 expected.cupsBytesPerLine = 256;
698
699 if (page & 1)
700 {
701 expected.cupsBytesPerLine *= 2;
702 expected.cupsColorSpace = CUPS_CSPACE_CMYK;
703 expected.cupsColorOrder = CUPS_ORDER_CHUNKED;
704 expected.cupsNumColors = 4;
705 }
706 else
707 {
708 expected.cupsColorSpace = CUPS_CSPACE_K;
709 expected.cupsColorOrder = CUPS_ORDER_BANDED;
710 expected.cupsNumColors = 1;
711 }
712
713 if (page & 2)
714 {
715 expected.cupsBytesPerLine *= 2;
716 expected.cupsBitsPerColor = 16;
717 expected.cupsBitsPerPixel = (page & 1) ? 64 : 16;
718 }
719 else
720 {
721 expected.cupsBitsPerColor = 8;
722 expected.cupsBitsPerPixel = (page & 1) ? 32 : 8;
723 }
724
725 fputs("cupsRasterReadHeader2: ", stdout);
726 fflush(stdout);
727
728 if (!cupsRasterReadHeader2(r, &header))
729 {
730 puts("FAIL (read error)");
731 errors ++;
732 break;
733 }
734
735 if (memcmp(&header, &expected, sizeof(header)))
736 {
737 puts("FAIL (bad page header)");
738 errors ++;
739 print_changes(&header, &expected);
740 }
741
742 fputs("cupsRasterReadPixels: ", stdout);
743 fflush(stdout);
744
745 for (y = 0; y < 64; y ++)
746 {
747 if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine))
748 {
749 puts("FAIL (read error)");
750 errors ++;
751 break;
752 }
753
754 if (data[0] != 0 || memcmp(data, data + 1, header.cupsBytesPerLine - 1))
755 {
756 printf("FAIL (raster line %d corrupt)\n", y);
757 errors ++;
758 break;
759 }
760 }
761
762 if (y == 64)
763 {
764 for (y = 0; y < 64; y ++)
765 {
766 if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine))
767 {
768 puts("FAIL (read error)");
769 errors ++;
770 break;
771 }
772
773 for (x = 0; x < header.cupsBytesPerLine; x ++)
774 if (data[x] != (x & 255))
775 break;
776
777 if (x < header.cupsBytesPerLine)
778 {
779 printf("FAIL (raster line %d corrupt)\n", y + 64);
780 errors ++;
781 break;
782 }
783 }
784
785 if (y == 64)
786 {
787 for (y = 0; y < 64; y ++)
788 {
789 if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine))
790 {
791 puts("FAIL (read error)");
792 errors ++;
793 break;
794 }
795
796 if (data[0] != 255 || memcmp(data, data + 1, header.cupsBytesPerLine - 1))
797 {
798 printf("fail (raster line %d corrupt)\n", y + 128);
799 errors ++;
800 break;
801 }
802 }
803
804 if (y == 64)
805 {
806 for (y = 0; y < 64; y ++)
807 {
808 if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine))
809 {
810 puts("FAIL (read error)");
811 errors ++;
812 break;
813 }
814
815 for (x = 0; x < header.cupsBytesPerLine; x ++)
816 if (data[x] != ((x / 4) & 255))
817 break;
818
819 if (x < header.cupsBytesPerLine)
820 {
821 printf("FAIL (raster line %d corrupt)\n", y + 192);
822 errors ++;
823 break;
824 }
825 }
826
827 if (y == 64)
828 puts("PASS");
829 }
830 }
831 }
832 }
833
834 cupsRasterClose(r);
835 fclose(fp);
836
837 return (errors);
838 }
839
840
841 /*
842 * 'print_changes()' - Print differences in the page header.
843 */
844
845 static void
846 print_changes(
847 cups_page_header2_t *header, /* I - Actual page header */
848 cups_page_header2_t *expected) /* I - Expected page header */
849 {
850 int i; /* Looping var */
851
852
853 if (strcmp(header->MediaClass, expected->MediaClass))
854 printf(" MediaClass (%s), expected (%s)\n", header->MediaClass,
855 expected->MediaClass);
856
857 if (strcmp(header->MediaColor, expected->MediaColor))
858 printf(" MediaColor (%s), expected (%s)\n", header->MediaColor,
859 expected->MediaColor);
860
861 if (strcmp(header->MediaType, expected->MediaType))
862 printf(" MediaType (%s), expected (%s)\n", header->MediaType,
863 expected->MediaType);
864
865 if (strcmp(header->OutputType, expected->OutputType))
866 printf(" OutputType (%s), expected (%s)\n", header->OutputType,
867 expected->OutputType);
868
869 if (header->AdvanceDistance != expected->AdvanceDistance)
870 printf(" AdvanceDistance %d, expected %d\n", header->AdvanceDistance,
871 expected->AdvanceDistance);
872
873 if (header->AdvanceMedia != expected->AdvanceMedia)
874 printf(" AdvanceMedia %d, expected %d\n", header->AdvanceMedia,
875 expected->AdvanceMedia);
876
877 if (header->Collate != expected->Collate)
878 printf(" Collate %d, expected %d\n", header->Collate,
879 expected->Collate);
880
881 if (header->CutMedia != expected->CutMedia)
882 printf(" CutMedia %d, expected %d\n", header->CutMedia,
883 expected->CutMedia);
884
885 if (header->Duplex != expected->Duplex)
886 printf(" Duplex %d, expected %d\n", header->Duplex,
887 expected->Duplex);
888
889 if (header->HWResolution[0] != expected->HWResolution[0] ||
890 header->HWResolution[1] != expected->HWResolution[1])
891 printf(" HWResolution [%d %d], expected [%d %d]\n",
892 header->HWResolution[0], header->HWResolution[1],
893 expected->HWResolution[0], expected->HWResolution[1]);
894
895 if (memcmp(header->ImagingBoundingBox, expected->ImagingBoundingBox,
896 sizeof(header->ImagingBoundingBox)))
897 printf(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]\n",
898 header->ImagingBoundingBox[0],
899 header->ImagingBoundingBox[1],
900 header->ImagingBoundingBox[2],
901 header->ImagingBoundingBox[3],
902 expected->ImagingBoundingBox[0],
903 expected->ImagingBoundingBox[1],
904 expected->ImagingBoundingBox[2],
905 expected->ImagingBoundingBox[3]);
906
907 if (header->InsertSheet != expected->InsertSheet)
908 printf(" InsertSheet %d, expected %d\n", header->InsertSheet,
909 expected->InsertSheet);
910
911 if (header->Jog != expected->Jog)
912 printf(" Jog %d, expected %d\n", header->Jog,
913 expected->Jog);
914
915 if (header->LeadingEdge != expected->LeadingEdge)
916 printf(" LeadingEdge %d, expected %d\n", header->LeadingEdge,
917 expected->LeadingEdge);
918
919 if (header->Margins[0] != expected->Margins[0] ||
920 header->Margins[1] != expected->Margins[1])
921 printf(" Margins [%d %d], expected [%d %d]\n",
922 header->Margins[0], header->Margins[1],
923 expected->Margins[0], expected->Margins[1]);
924
925 if (header->ManualFeed != expected->ManualFeed)
926 printf(" ManualFeed %d, expected %d\n", header->ManualFeed,
927 expected->ManualFeed);
928
929 if (header->MediaPosition != expected->MediaPosition)
930 printf(" MediaPosition %d, expected %d\n", header->MediaPosition,
931 expected->MediaPosition);
932
933 if (header->MediaWeight != expected->MediaWeight)
934 printf(" MediaWeight %d, expected %d\n", header->MediaWeight,
935 expected->MediaWeight);
936
937 if (header->MirrorPrint != expected->MirrorPrint)
938 printf(" MirrorPrint %d, expected %d\n", header->MirrorPrint,
939 expected->MirrorPrint);
940
941 if (header->NegativePrint != expected->NegativePrint)
942 printf(" NegativePrint %d, expected %d\n", header->NegativePrint,
943 expected->NegativePrint);
944
945 if (header->NumCopies != expected->NumCopies)
946 printf(" NumCopies %d, expected %d\n", header->NumCopies,
947 expected->NumCopies);
948
949 if (header->Orientation != expected->Orientation)
950 printf(" Orientation %d, expected %d\n", header->Orientation,
951 expected->Orientation);
952
953 if (header->OutputFaceUp != expected->OutputFaceUp)
954 printf(" OutputFaceUp %d, expected %d\n", header->OutputFaceUp,
955 expected->OutputFaceUp);
956
957 if (header->PageSize[0] != expected->PageSize[0] ||
958 header->PageSize[1] != expected->PageSize[1])
959 printf(" PageSize [%d %d], expected [%d %d]\n",
960 header->PageSize[0], header->PageSize[1],
961 expected->PageSize[0], expected->PageSize[1]);
962
963 if (header->Separations != expected->Separations)
964 printf(" Separations %d, expected %d\n", header->Separations,
965 expected->Separations);
966
967 if (header->TraySwitch != expected->TraySwitch)
968 printf(" TraySwitch %d, expected %d\n", header->TraySwitch,
969 expected->TraySwitch);
970
971 if (header->Tumble != expected->Tumble)
972 printf(" Tumble %d, expected %d\n", header->Tumble,
973 expected->Tumble);
974
975 if (header->cupsWidth != expected->cupsWidth)
976 printf(" cupsWidth %d, expected %d\n", header->cupsWidth,
977 expected->cupsWidth);
978
979 if (header->cupsHeight != expected->cupsHeight)
980 printf(" cupsHeight %d, expected %d\n", header->cupsHeight,
981 expected->cupsHeight);
982
983 if (header->cupsMediaType != expected->cupsMediaType)
984 printf(" cupsMediaType %d, expected %d\n", header->cupsMediaType,
985 expected->cupsMediaType);
986
987 if (header->cupsBitsPerColor != expected->cupsBitsPerColor)
988 printf(" cupsBitsPerColor %d, expected %d\n", header->cupsBitsPerColor,
989 expected->cupsBitsPerColor);
990
991 if (header->cupsBitsPerPixel != expected->cupsBitsPerPixel)
992 printf(" cupsBitsPerPixel %d, expected %d\n", header->cupsBitsPerPixel,
993 expected->cupsBitsPerPixel);
994
995 if (header->cupsBytesPerLine != expected->cupsBytesPerLine)
996 printf(" cupsBytesPerLine %d, expected %d\n", header->cupsBytesPerLine,
997 expected->cupsBytesPerLine);
998
999 if (header->cupsColorOrder != expected->cupsColorOrder)
1000 printf(" cupsColorOrder %d, expected %d\n", header->cupsColorOrder,
1001 expected->cupsColorOrder);
1002
1003 if (header->cupsColorSpace != expected->cupsColorSpace)
1004 printf(" cupsColorSpace %d, expected %d\n", header->cupsColorSpace,
1005 expected->cupsColorSpace);
1006
1007 if (header->cupsCompression != expected->cupsCompression)
1008 printf(" cupsCompression %d, expected %d\n", header->cupsCompression,
1009 expected->cupsCompression);
1010
1011 if (header->cupsRowCount != expected->cupsRowCount)
1012 printf(" cupsRowCount %d, expected %d\n", header->cupsRowCount,
1013 expected->cupsRowCount);
1014
1015 if (header->cupsRowFeed != expected->cupsRowFeed)
1016 printf(" cupsRowFeed %d, expected %d\n", header->cupsRowFeed,
1017 expected->cupsRowFeed);
1018
1019 if (header->cupsRowStep != expected->cupsRowStep)
1020 printf(" cupsRowStep %d, expected %d\n", header->cupsRowStep,
1021 expected->cupsRowStep);
1022
1023 if (header->cupsNumColors != expected->cupsNumColors)
1024 printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors,
1025 expected->cupsNumColors);
1026
1027 if (header->cupsBorderlessScalingFactor !=
1028 expected->cupsBorderlessScalingFactor)
1029 printf(" cupsBorderlessScalingFactor %g, expected %g\n",
1030 header->cupsBorderlessScalingFactor,
1031 expected->cupsBorderlessScalingFactor);
1032
1033 if (header->cupsPageSize[0] != expected->cupsPageSize[0] ||
1034 header->cupsPageSize[1] != expected->cupsPageSize[1])
1035 printf(" cupsPageSize [%g %g], expected [%g %g]\n",
1036 header->cupsPageSize[0], header->cupsPageSize[1],
1037 expected->cupsPageSize[0], expected->cupsPageSize[1]);
1038
1039 if (header->cupsImagingBBox[0] != expected->cupsImagingBBox[0] ||
1040 header->cupsImagingBBox[1] != expected->cupsImagingBBox[1] ||
1041 header->cupsImagingBBox[2] != expected->cupsImagingBBox[2] ||
1042 header->cupsImagingBBox[3] != expected->cupsImagingBBox[3])
1043 printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n",
1044 header->cupsImagingBBox[0], header->cupsImagingBBox[1],
1045 header->cupsImagingBBox[2], header->cupsImagingBBox[3],
1046 expected->cupsImagingBBox[0], expected->cupsImagingBBox[1],
1047 expected->cupsImagingBBox[2], expected->cupsImagingBBox[3]);
1048
1049 for (i = 0; i < 16; i ++)
1050 if (header->cupsInteger[i] != expected->cupsInteger[i])
1051 printf(" cupsInteger%d %d, expected %d\n", i, header->cupsInteger[i],
1052 expected->cupsInteger[i]);
1053
1054 for (i = 0; i < 16; i ++)
1055 if (header->cupsReal[i] != expected->cupsReal[i])
1056 printf(" cupsReal%d %g, expected %g\n", i, header->cupsReal[i],
1057 expected->cupsReal[i]);
1058
1059 for (i = 0; i < 16; i ++)
1060 if (strcmp(header->cupsString[i], expected->cupsString[i]))
1061 printf(" cupsString%d (%s), expected (%s)\n", i,
1062 header->cupsString[i], expected->cupsString[i]);
1063
1064 if (strcmp(header->cupsMarkerType, expected->cupsMarkerType))
1065 printf(" cupsMarkerType (%s), expected (%s)\n", header->cupsMarkerType,
1066 expected->cupsMarkerType);
1067
1068 if (strcmp(header->cupsRenderingIntent, expected->cupsRenderingIntent))
1069 printf(" cupsRenderingIntent (%s), expected (%s)\n",
1070 header->cupsRenderingIntent,
1071 expected->cupsRenderingIntent);
1072
1073 if (strcmp(header->cupsPageSizeName, expected->cupsPageSizeName))
1074 printf(" cupsPageSizeName (%s), expected (%s)\n",
1075 header->cupsPageSizeName,
1076 expected->cupsPageSizeName);
1077 }
1078
1079
1080 /*
1081 * End of "$Id: testraster.c 7376 2008-03-19 21:07:45Z mike $".
1082 */