blob: 9fb7094fb93a8cabf16bb4d2dec88748cb2d3a06 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% %
7% V V AAA L IIIII DDDD AAA TTTTT EEEEE %
8% V V A A L I D D A A T E %
9% V V AAAAA L I D D AAAAA T EEE %
10% V V A A L I D D A A T E %
11% V A A LLLLL IIIII DDDD A A T EEEEE %
12% %
13% %
14% ImageMagick Validation Suite %
15% %
16% Software Design %
17% John Cristy %
18% March 2001 %
19% %
20% %
21% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
22% dedicated to making software imaging solutions freely available. %
23% %
24% You may not use this file except in compliance with the License. You may %
25% obtain a copy of the License at %
26% %
27% http://www.imagemagick.org/script/license.php %
28% %
29% Unless required by applicable law or agreed to in writing, software %
30% distributed under the License is distributed on an "AS IS" BASIS, %
31% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
32% see the License for the specific language governing permissions and %
33% limitations under the License. %
34% %
35%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36%
37%
38*/
39
40/*
41 Include declarations.
42*/
43#include <stdio.h>
44#include <string.h>
45#include <math.h>
46#include "wand/MagickWand.h"
47#include "validate.h"
48
49/*
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51% %
52% %
53% %
54% V a l i d a t e C o m p a r e C o m m a n d %
55% %
56% %
57% %
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59%
60% ValidateCompareCommand() validates the ImageMagick compare command line
61% program and returns the number of validation tests that passed and failed.
62%
63% The format of the ValidateCompareCommand method is:
64%
65% unsigned long ValidateCompareCommand(ImageInfo *image_info,
66% const char *reference_filename,const char *output_filename,
67% unsigned long *fail,ExceptionInfo *exception)
68%
69% A description of each parameter follows:
70%
71% o image_info: the image info.
72%
73% o reference_filename: the reference image filename.
74%
75% o output_filename: the output image filename.
76%
77% o fail: return the number of validation tests that pass.
78%
79% o exception: return any errors or warnings in this structure.
80%
81*/
82static unsigned long ValidateCompareCommand(ImageInfo *image_info,
83 const char *reference_filename,const char *output_filename,
84 unsigned long *fail,ExceptionInfo *exception)
85{
86 char
87 **arguments,
88 command[MaxTextExtent];
89
90 int
91 number_arguments;
92
93 MagickBooleanType
94 status;
95
96 register long
97 i,
98 j;
99
100 unsigned long
101 test;
102
103 test=0;
104 (void) fprintf(stdout,"validate compare command line program:\n");
105 for (i=0; compare_options[i] != (char *) NULL; i++)
106 {
107 CatchException(exception);
108 (void) fprintf(stdout," test %lu: %s",test++,compare_options[i]);
109 (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
110 compare_options[i],reference_filename,reference_filename,output_filename);
111 arguments=StringToArgv(command,&number_arguments);
112 if (arguments == (char **) NULL)
113 {
114 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
115 (*fail)++;
116 continue;
117 }
118 status=CompareImageCommand(image_info,number_arguments,arguments,
119 (char **) NULL,exception);
120 for (j=0; j < number_arguments; j++)
121 arguments[j]=DestroyString(arguments[j]);
122 arguments=(char **) RelinquishMagickMemory(arguments);
123 if (status != MagickFalse)
124 {
125 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
126 (*fail)++;
127 continue;
128 }
129 (void) fprintf(stdout,"... pass.\n");
130 }
131 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
132 test,test-(*fail),*fail);
133 return(test);
134}
135
136/*
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138% %
139% %
140% %
141% V a l i d a t e C o m p o s i t e C o m m a n d %
142% %
143% %
144% %
145%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146%
147% ValidateCompositeCommand() validates the ImageMagick composite command line
148% program and returns the number of validation tests that passed and failed.
149%
150% The format of the ValidateCompositeCommand method is:
151%
152% unsigned long ValidateCompositeCommand(ImageInfo *image_info,
153% const char *reference_filename,const char *output_filename,
154% unsigned long *fail,ExceptionInfo *exception)
155%
156% A description of each parameter follows:
157%
158% o image_info: the image info.
159%
160% o reference_filename: the reference image filename.
161%
162% o output_filename: the output image filename.
163%
164% o fail: return the number of validation tests that pass.
165%
166% o exception: return any errors or warnings in this structure.
167%
168*/
169static unsigned long ValidateCompositeCommand(ImageInfo *image_info,
170 const char *reference_filename,const char *output_filename,
171 unsigned long *fail,ExceptionInfo *exception)
172{
173 char
174 **arguments,
175 command[MaxTextExtent];
176
177 int
178 number_arguments;
179
180 MagickBooleanType
181 status;
182
183 register long
184 i,
185 j;
186
187 unsigned long
188 test;
189
190 test=0;
191 (void) fprintf(stdout,"validate composite command line program:\n");
192 for (i=0; composite_options[i] != (char *) NULL; i++)
193 {
194 CatchException(exception);
195 (void) fprintf(stdout," test %lu: %s",test++,composite_options[i]);
196 (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
197 reference_filename,composite_options[i],reference_filename,
198 output_filename);
199 arguments=StringToArgv(command,&number_arguments);
200 if (arguments == (char **) NULL)
201 {
202 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
203 (*fail)++;
204 continue;
205 }
206 status=CompositeImageCommand(image_info,number_arguments,arguments,
207 (char **) NULL,exception);
208 for (j=0; j < number_arguments; j++)
209 arguments[j]=DestroyString(arguments[j]);
210 arguments=(char **) RelinquishMagickMemory(arguments);
211 if (status != MagickFalse)
212 {
213 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
214 (*fail)++;
215 continue;
216 }
217 (void) fprintf(stdout,"... pass.\n");
218 }
219 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
220 test,test-(*fail),*fail);
221 return(test);
222}
223
224/*
225%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226% %
227% %
228% %
229% V a l i d a t e C o n v e r t C o m m a n d %
230% %
231% %
232% %
233%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234%
235% ValidateConvertCommand() validates the ImageMagick convert command line
236% program and returns the number of validation tests that passed and failed.
237%
238% The format of the ValidateConvertCommand method is:
239%
240% unsigned long ValidateConvertCommand(ImageInfo *image_info,
241% const char *reference_filename,const char *output_filename,
242% unsigned long *fail,ExceptionInfo *exception)
243%
244% A description of each parameter follows:
245%
246% o image_info: the image info.
247%
248% o reference_filename: the reference image filename.
249%
250% o output_filename: the output image filename.
251%
252% o fail: return the number of validation tests that pass.
253%
254% o exception: return any errors or warnings in this structure.
255%
256*/
257static unsigned long ValidateConvertCommand(ImageInfo *image_info,
258 const char *reference_filename,const char *output_filename,
259 unsigned long *fail,ExceptionInfo *exception)
260{
261 char
262 **arguments,
263 command[MaxTextExtent];
264
265 int
266 number_arguments;
267
268 MagickBooleanType
269 status;
270
271 register long
272 i,
273 j;
274
275 unsigned long
276 test;
277
278 test=0;
279 (void) fprintf(stdout,"validate convert command line program:\n");
280 for (i=0; convert_options[i] != (char *) NULL; i++)
281 {
282 CatchException(exception);
283 (void) fprintf(stdout," test %lu: %s",test++,convert_options[i]);
284 (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
285 reference_filename,convert_options[i],reference_filename,output_filename);
286 arguments=StringToArgv(command,&number_arguments);
287 if (arguments == (char **) NULL)
288 {
289 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
290 (*fail)++;
291 continue;
292 }
293 status=ConvertImageCommand(image_info,number_arguments,arguments,
294 (char **) NULL,exception);
295 for (j=0; j < number_arguments; j++)
296 arguments[j]=DestroyString(arguments[j]);
297 arguments=(char **) RelinquishMagickMemory(arguments);
298 if (status != MagickFalse)
299 {
300 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
301 (*fail)++;
302 continue;
303 }
304 (void) fprintf(stdout,"... pass.\n");
305 }
306 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
307 test,test-(*fail),*fail);
308 return(test);
309}
310
311/*
312%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313% %
314% %
315% %
316% V a l i d a t e I d e n t i f y C o m m a n d %
317% %
318% %
319% %
320%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321%
322% ValidateIdentifyCommand() validates the ImageMagick identify command line
323% program and returns the number of validation tests that passed and failed.
324%
325% The format of the ValidateIdentifyCommand method is:
326%
327% unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
328% const char *reference_filename,const char *output_filename,
329% unsigned long *fail,ExceptionInfo *exception)
330%
331% A description of each parameter follows:
332%
333% o image_info: the image info.
334%
335% o reference_filename: the reference image filename.
336%
337% o output_filename: the output image filename.
338%
339% o fail: return the number of validation tests that pass.
340%
341% o exception: return any errors or warnings in this structure.
342%
343*/
344static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
345 const char *reference_filename,const char *output_filename,
346 unsigned long *fail,ExceptionInfo *exception)
347{
348 char
349 **arguments,
350 command[MaxTextExtent];
351
352 int
353 number_arguments;
354
355 MagickBooleanType
356 status;
357
358 register long
359 i,
360 j;
361
362 unsigned long
363 test;
364
365 (void) output_filename;
366 test=0;
367 (void) fprintf(stdout,"validate identify command line program:\n");
368 for (i=0; identify_options[i] != (char *) NULL; i++)
369 {
370 CatchException(exception);
371 (void) fprintf(stdout," test %lu: %s",test++,identify_options[i]);
372 (void) FormatMagickString(command,MaxTextExtent,"%s %s",
373 identify_options[i],reference_filename);
374 arguments=StringToArgv(command,&number_arguments);
375 if (arguments == (char **) NULL)
376 {
377 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
378 (*fail)++;
379 continue;
380 }
381 status=IdentifyImageCommand(image_info,number_arguments,arguments,
382 (char **) NULL,exception);
383 for (j=0; j < number_arguments; j++)
384 arguments[j]=DestroyString(arguments[j]);
385 arguments=(char **) RelinquishMagickMemory(arguments);
386 if (status != MagickFalse)
387 {
388 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
389 (*fail)++;
390 continue;
391 }
392 (void) fprintf(stdout,"... pass.\n");
393 }
394 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
395 test,test-(*fail),*fail);
396 return(test);
397}
398
399/*
400%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401% %
402% %
403% %
404% V a l i d a t e I m a g e F o r m a t s I n M e m o r y %
405% %
406% %
407% %
408%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409%
410% ValidateImageFormatsInMemory() validates the ImageMagick image formats in
411% memory and returns the number of validation tests that passed and failed.
412%
413% The format of the ValidateImageFormatsInMemory method is:
414%
415% unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
416% const char *reference_filename,const char *output_filename,
417% unsigned long *fail,ExceptionInfo *exception)
418%
419% A description of each parameter follows:
420%
421% o image_info: the image info.
422%
423% o reference_filename: the reference image filename.
424%
425% o output_filename: the output image filename.
426%
427% o fail: return the number of validation tests that pass.
428%
429% o exception: return any errors or warnings in this structure.
430%
431*/
432static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
433 const char *reference_filename,const char *output_filename,
434 unsigned long *fail,ExceptionInfo *exception)
435{
436 char
437 size[MaxTextExtent];
438
439 const MagickInfo
440 *magick_info;
441
442 double
443 distortion,
444 fuzz;
445
446 Image
447 *difference_image,
448 *reference_image,
449 *reconstruct_image;
450
451 MagickBooleanType
452 status;
453
454 register long
455 i,
456 j;
457
458 size_t
459 length;
460
461 unsigned char
462 *blob;
463
464 unsigned long
465 test;
466
467 test=0;
468 (void) fprintf(stdout,"validate image formats in memory:\n");
469 for (i=0; reference_formats[i].magick != (char *) NULL; i++)
470 {
471 magick_info=GetMagickInfo(reference_formats[i].magick,exception);
472 if ((magick_info == (const MagickInfo *) NULL) ||
473 (magick_info->decoder == (DecodeImageHandler *) NULL) ||
474 (magick_info->encoder == (EncodeImageHandler *) NULL))
475 continue;
476 for (j=0; reference_types[j].type != UndefinedType; j++)
477 {
478 /*
479 Generate reference image.
480 */
481 CatchException(exception);
482 (void) fprintf(stdout," test %lu: %s/%s/%lu-bits",test++,
483 reference_formats[i].magick,MagickOptionToMnemonic(MagickTypeOptions,
484 reference_types[j].type),reference_types[j].depth);
485 (void) CopyMagickString(image_info->filename,reference_filename,
486 MaxTextExtent);
487 reference_image=ReadImage(image_info,exception);
488 if (reference_image == (Image *) NULL)
489 {
490 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
491 (*fail)++;
492 continue;
493 }
494 /*
495 Write reference image.
496 */
497 (void) FormatMagickString(size,MaxTextExtent,"%lux%lu",
498 reference_image->columns,reference_image->rows);
499 (void) CloneString(&image_info->size,size);
500 image_info->depth=reference_types[j].depth;
501 (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
502 reference_formats[i].magick,output_filename);
503 status=SetImageType(reference_image,reference_types[j].type);
504 InheritException(exception,&reference_image->exception);
505 if (status == MagickFalse)
506 {
507 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
508 (*fail)++;
509 reference_image=DestroyImage(reference_image);
510 continue;
511 }
512 status=SetImageDepth(reference_image,reference_types[j].depth);
513 InheritException(exception,&reference_image->exception);
514 if (status == MagickFalse)
515 {
516 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
517 (*fail)++;
518 reference_image=DestroyImage(reference_image);
519 continue;
520 }
521 status=WriteImage(image_info,reference_image);
522 InheritException(exception,&reference_image->exception);
523 reference_image=DestroyImage(reference_image);
524 if (status == MagickFalse)
525 {
526 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
527 (*fail)++;
528 continue;
529 }
530 /*
531 Read reference image.
532 */
533 (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
534 reference_formats[i].magick,output_filename);
535 reference_image=ReadImage(image_info,exception);
536 if (reference_image == (Image *) NULL)
537 {
538 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
539 (*fail)++;
540 continue;
541 }
542 /*
543 Write reference image.
544 */
545 (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
546 reference_formats[i].magick,output_filename);
547 (void) CopyMagickString(image_info->magick,reference_formats[i].magick,
548 MaxTextExtent);
549 reference_image->depth=reference_types[j].depth;
550 length=8192;
551 blob=ImageToBlob(image_info,reference_image,&length,exception);
552 if (blob == (unsigned char *) NULL)
553 {
554 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
555 (*fail)++;
556 reference_image=DestroyImage(reference_image);
557 continue;
558 }
559 /*
560 Read reconstruct image.
561 */
562 (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
563 reference_formats[i].magick,output_filename);
564 reconstruct_image=BlobToImage(image_info,blob,length,exception);
565 blob=(unsigned char *) RelinquishMagickMemory(blob);
566 if (reconstruct_image == (Image *) NULL)
567 {
568 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
569 (*fail)++;
570 reference_image=DestroyImage(reference_image);
571 continue;
572 }
573 /*
574 Compare reference to reconstruct image.
575 */
576 fuzz=0.0;
577 if (reference_formats[i].fuzz != 0.0)
578 fuzz=reference_formats[i].fuzz;
579#if defined(MAGICKCORE_HDRI_SUPPORT)
580 fuzz+=0.003;
581#endif
582 if (reference_image->colorspace != RGBColorspace)
583 fuzz+=0.3;
584 fuzz+=MagickEpsilon;
585 difference_image=CompareImageChannels(reference_image,reconstruct_image,
586 AllChannels,MeanSquaredErrorMetric,&distortion,exception);
587 reconstruct_image=DestroyImage(reconstruct_image);
588 reference_image=DestroyImage(reference_image);
589 if (difference_image == (Image *) NULL)
590 {
591 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
592 (*fail)++;
593 continue;
594 }
595 difference_image=DestroyImage(difference_image);
596 if ((distortion/QuantumRange) > fuzz)
597 {
598 (void) fprintf(stdout,"... fail (with distortion %g).\n",distortion/
599 QuantumRange);
600 (*fail)++;
601 continue;
602 }
603 (void) fprintf(stdout,"... pass.\n");
604 }
605 }
606 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
607 test,test-(*fail),*fail);
608 return(test);
609}
610
611/*
612%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613% %
614% %
615% %
616% V a l i d a t e I m a g e F o r m a t s O n D i s k %
617% %
618% %
619% %
620%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621%
622% ValidateImageFormatsOnDisk() validates the ImageMagick image formats on disk
623% and returns the number of validation tests that passed and failed.
624%
625% The format of the ValidateImageFormatsOnDisk method is:
626%
627% unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
628% const char *reference_filename,const char *output_filename,
629% unsigned long *fail,ExceptionInfo *exception)
630%
631% A description of each parameter follows:
632%
633% o image_info: the image info.
634%
635% o reference_filename: the reference image filename.
636%
637% o output_filename: the output image filename.
638%
639% o fail: return the number of validation tests that pass.
640%
641% o exception: return any errors or warnings in this structure.
642%
643*/
644static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
645 const char *reference_filename,const char *output_filename,
646 unsigned long *fail,ExceptionInfo *exception)
647{
648 char
649 size[MaxTextExtent];
650
651 const MagickInfo
652 *magick_info;
653
654 double
655 distortion,
656 fuzz;
657
658 Image
659 *difference_image,
660 *reference_image,
661 *reconstruct_image;
662
663 MagickBooleanType
664 status;
665
666 register long
667 i,
668 j;
669
670 unsigned long
671 test;
672
673 test=0;
674 (void) fprintf(stdout,"validate image formats on disk:\n");
675 for (i=0; reference_formats[i].magick != (char *) NULL; i++)
676 {
677 magick_info=GetMagickInfo(reference_formats[i].magick,exception);
678 if ((magick_info == (const MagickInfo *) NULL) ||
679 (magick_info->decoder == (DecodeImageHandler *) NULL) ||
680 (magick_info->encoder == (EncodeImageHandler *) NULL))
681 continue;
682 for (j=0; reference_types[j].type != UndefinedType; j++)
683 {
684 /*
685 Generate reference image.
686 */
687 CatchException(exception);
688 (void) fprintf(stdout," test %lu: %s/%s/%lu-bits",test++,
689 reference_formats[i].magick,MagickOptionToMnemonic(MagickTypeOptions,
690 reference_types[j].type),reference_types[j].depth);
691 (void) CopyMagickString(image_info->filename,reference_filename,
692 MaxTextExtent);
693 reference_image=ReadImage(image_info,exception);
694 if (reference_image == (Image *) NULL)
695 {
696 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
697 (*fail)++;
698 continue;
699 }
700 /*
701 Write reference image.
702 */
703 (void) FormatMagickString(size,MaxTextExtent,"%lux%lu",
704 reference_image->columns,reference_image->rows);
705 (void) CloneString(&image_info->size,size);
706 image_info->depth=reference_types[j].depth;
707 (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
708 reference_formats[i].magick,output_filename);
709 status=SetImageType(reference_image,reference_types[j].type);
710 InheritException(exception,&reference_image->exception);
711 if (status == MagickFalse)
712 {
713 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
714 (*fail)++;
715 reference_image=DestroyImage(reference_image);
716 continue;
717 }
718 status=SetImageDepth(reference_image,reference_types[j].depth);
719 InheritException(exception,&reference_image->exception);
720 if (status == MagickFalse)
721 {
722 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
723 (*fail)++;
724 reference_image=DestroyImage(reference_image);
725 continue;
726 }
727 status=WriteImage(image_info,reference_image);
728 InheritException(exception,&reference_image->exception);
729 reference_image=DestroyImage(reference_image);
730 if (status == MagickFalse)
731 {
732 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
733 (*fail)++;
734 continue;
735 }
736 /*
737 Read reference image.
738 */
739 (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
740 reference_formats[i].magick,output_filename);
741 reference_image=ReadImage(image_info,exception);
742 if (reference_image == (Image *) NULL)
743 {
744 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
745 (*fail)++;
746 continue;
747 }
748 /*
749 Write reference image.
750 */
751 (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
752 reference_formats[i].magick,output_filename);
753 reference_image->depth=reference_types[j].depth;
754 status=WriteImage(image_info,reference_image);
755 InheritException(exception,&reference_image->exception);
756 if (status == MagickFalse)
757 {
758 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
759 (*fail)++;
760 reference_image=DestroyImage(reference_image);
761 continue;
762 }
763 /*
764 Read reconstruct image.
765 */
766 (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
767 reference_formats[i].magick,output_filename);
768 reconstruct_image=ReadImage(image_info,exception);
769 if (reconstruct_image == (Image *) NULL)
770 {
771 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
772 (*fail)++;
773 reference_image=DestroyImage(reference_image);
774 continue;
775 }
776 /*
777 Compare reference to reconstruct image.
778 */
779 fuzz=0.0;
780 if (reference_formats[i].fuzz != 0.0)
781 fuzz=reference_formats[i].fuzz;
782#if defined(MAGICKCORE_HDRI_SUPPORT)
783 fuzz+=0.003;
784#endif
785 if (reference_image->colorspace != RGBColorspace)
786 fuzz+=0.3;
787 fuzz+=MagickEpsilon;
788 difference_image=CompareImageChannels(reference_image,reconstruct_image,
789 AllChannels,MeanSquaredErrorMetric,&distortion,exception);
790 reconstruct_image=DestroyImage(reconstruct_image);
791 reference_image=DestroyImage(reference_image);
792 if (difference_image == (Image *) NULL)
793 {
794 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
795 (*fail)++;
796 continue;
797 }
798 difference_image=DestroyImage(difference_image);
799 if ((distortion/QuantumRange) > fuzz)
800 {
801 (void) fprintf(stdout,"... fail (with distortion %g).\n",distortion/
802 QuantumRange);
803 (*fail)++;
804 continue;
805 }
806 (void) fprintf(stdout,"... pass.\n");
807 }
808 }
809 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
810 test,test-(*fail),*fail);
811 return(test);
812}
813
814/*
815%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
816% %
817% %
818% %
819% V a l i d a t e I m p o r t E x p o r t P i x e l s %
820% %
821% %
822% %
823%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
824%
825% ValidateImportExportPixels() validates the pixel import and export methods.
826% It returns the number of validation tests that passed and failed.
827%
828% The format of the ValidateImportExportPixels method is:
829%
830% unsigned long ValidateImportExportPixels(ImageInfo *image_info,
831% const char *reference_filename,const char *output_filename,
832% unsigned long *fail,ExceptionInfo *exception)
833%
834% A description of each parameter follows:
835%
836% o image_info: the image info.
837%
838% o reference_filename: the reference image filename.
839%
840% o output_filename: the output image filename.
841%
842% o fail: return the number of validation tests that pass.
843%
844% o exception: return any errors or warnings in this structure.
845%
846*/
847static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
848 const char *reference_filename,const char *output_filename,
849 unsigned long *fail,ExceptionInfo *exception)
850{
851 double
852 distortion;
853
854 Image
855 *difference_image,
856 *reference_image,
857 *reconstruct_image;
858
859 MagickBooleanType
860 status;
861
862 register long
863 i,
864 j;
865
866 size_t
867 length;
868
869 unsigned char
870 *pixels;
871
872 unsigned long
873 test;
874
875 (void) output_filename;
876 test=0;
877 (void) fprintf(stdout,"validate the import and export of image pixels:\n");
878 for (i=0; reference_map[i] != (char *) NULL; i++)
879 {
880 for (j=0; reference_storage[j].type != UndefinedPixel; j++)
881 {
882 /*
883 Generate reference image.
884 */
885 CatchException(exception);
886 (void) fprintf(stdout," test %lu: %s/%s",test++,
887 reference_map[i],MagickOptionToMnemonic(MagickStorageOptions,
888 reference_storage[j].type));
889 (void) CopyMagickString(image_info->filename,reference_filename,
890 MaxTextExtent);
891 reference_image=ReadImage(image_info,exception);
892 if (reference_image == (Image *) NULL)
893 {
894 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
895 (*fail)++;
896 continue;
897 }
898 if (LocaleNCompare(reference_map[i],"cmy",3) == 0)
899 (void) TransformImageColorspace(reference_image,CMYKColorspace);
900 length=strlen(reference_map[i])*reference_image->columns*
901 reference_image->rows*reference_storage[j].quantum;
902 pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels));
903 if (pixels == (unsigned char *) NULL)
904 {
905 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
906 (*fail)++;
907 reference_image=DestroyImage(reference_image);
908 continue;
909 }
910 (void) ResetMagickMemory(pixels,0,length*sizeof(*pixels));
911 status=ExportImagePixels(reference_image,0,0,reference_image->columns,
912 reference_image->rows,reference_map[i],reference_storage[j].type,pixels,
913 exception);
914 if (status == MagickFalse)
915 {
916 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
917 (*fail)++;
918 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
919 reference_image=DestroyImage(reference_image);
920 continue;
921 }
922 (void) SetImageBackgroundColor(reference_image);
923 status=ImportImagePixels(reference_image,0,0,reference_image->columns,
924 reference_image->rows,reference_map[i],reference_storage[j].type,
925 pixels);
926 InheritException(exception,&reference_image->exception);
927 if (status == MagickFalse)
928 {
929 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
930 (*fail)++;
931 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
932 reference_image=DestroyImage(reference_image);
933 continue;
934 }
935 /*
936 Read reconstruct image.
937 */
938 reconstruct_image=AcquireImage(image_info);
939 (void) SetImageExtent(reconstruct_image,reference_image->columns,
940 reference_image->rows);
941 (void) SetImageColorspace(reconstruct_image,reference_image->colorspace);
942 (void) SetImageBackgroundColor(reconstruct_image);
943 status=ImportImagePixels(reconstruct_image,0,0,reconstruct_image->columns,
944 reconstruct_image->rows,reference_map[i],reference_storage[j].type,
945 pixels);
946 InheritException(exception,&reconstruct_image->exception);
947 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
948 if (status == MagickFalse)
949 {
950 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
951 (*fail)++;
952 reference_image=DestroyImage(reference_image);
953 continue;
954 }
955 /*
956 Compare reference to reconstruct image.
957 */
958 difference_image=CompareImageChannels(reference_image,reconstruct_image,
959 AllChannels,MeanSquaredErrorMetric,&distortion,exception);
960 reconstruct_image=DestroyImage(reconstruct_image);
961 reference_image=DestroyImage(reference_image);
962 if (difference_image == (Image *) NULL)
963 {
964 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
965 (*fail)++;
966 continue;
967 }
968 difference_image=DestroyImage(difference_image);
969 if ((distortion/QuantumRange) > 0.0)
970 {
971 (void) fprintf(stdout,"... fail (with distortion %g).\n",distortion/
972 QuantumRange);
973 (*fail)++;
974 continue;
975 }
976 (void) fprintf(stdout,"... pass.\n");
977 }
978 }
979 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
980 test,test-(*fail),*fail);
981 return(test);
982}
983
984/*
985%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
986% %
987% %
988% %
989% V a l i d a t e M o n t a g e C o m m a n d %
990% %
991% %
992% %
993%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994%
995% ValidateMontageCommand() validates the ImageMagick montage command line
996% program and returns the number of validation tests that passed and failed.
997%
998% The format of the ValidateMontageCommand method is:
999%
1000% unsigned long ValidateMontageCommand(ImageInfo *image_info,
1001% const char *reference_filename,const char *output_filename,
1002% unsigned long *fail,ExceptionInfo *exception)
1003%
1004% A description of each parameter follows:
1005%
1006% o image_info: the image info.
1007%
1008% o reference_filename: the reference image filename.
1009%
1010% o output_filename: the output image filename.
1011%
1012% o fail: return the number of validation tests that pass.
1013%
1014% o exception: return any errors or warnings in this structure.
1015%
1016*/
1017static unsigned long ValidateMontageCommand(ImageInfo *image_info,
1018 const char *reference_filename,const char *output_filename,
1019 unsigned long *fail,ExceptionInfo *exception)
1020{
1021 char
1022 **arguments,
1023 command[MaxTextExtent];
1024
1025 int
1026 number_arguments;
1027
1028 MagickBooleanType
1029 status;
1030
1031 register long
1032 i,
1033 j;
1034
1035 unsigned long
1036 test;
1037
1038 test=0;
1039 (void) fprintf(stdout,"validate montage command line program:\n");
1040 for (i=0; montage_options[i] != (char *) NULL; i++)
1041 {
1042 CatchException(exception);
1043 (void) fprintf(stdout," test %lu: %s",test++,montage_options[i]);
1044 (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
1045 reference_filename,montage_options[i],reference_filename,
1046 output_filename);
1047 arguments=StringToArgv(command,&number_arguments);
1048 if (arguments == (char **) NULL)
1049 {
1050 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
1051 (*fail)++;
1052 continue;
1053 }
1054 status=MontageImageCommand(image_info,number_arguments,arguments,
1055 (char **) NULL,exception);
1056 for (j=0; j < number_arguments; j++)
1057 arguments[j]=DestroyString(arguments[j]);
1058 arguments=(char **) RelinquishMagickMemory(arguments);
1059 if (status != MagickFalse)
1060 {
1061 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
1062 (*fail)++;
1063 continue;
1064 }
1065 (void) fprintf(stdout,"... pass.\n");
1066 }
1067 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
1068 test,test-(*fail),*fail);
1069 return(test);
1070}
1071
1072/*
1073%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1074% %
1075% %
1076% %
1077% V a l i d a t e S t r e a m C o m m a n d %
1078% %
1079% %
1080% %
1081%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1082%
1083% ValidateStreamCommand() validates the ImageMagick stream command line
1084% program and returns the number of validation tests that passed and failed.
1085%
1086% The format of the ValidateStreamCommand method is:
1087%
1088% unsigned long ValidateStreamCommand(ImageInfo *image_info,
1089% const char *reference_filename,const char *output_filename,
1090% unsigned long *fail,ExceptionInfo *exception)
1091%
1092% A description of each parameter follows:
1093%
1094% o image_info: the image info.
1095%
1096% o reference_filename: the reference image filename.
1097%
1098% o output_filename: the output image filename.
1099%
1100% o fail: return the number of validation tests that pass.
1101%
1102% o exception: return any errors or warnings in this structure.
1103%
1104*/
1105static unsigned long ValidateStreamCommand(ImageInfo *image_info,
1106 const char *reference_filename,const char *output_filename,
1107 unsigned long *fail,ExceptionInfo *exception)
1108{
1109 char
1110 **arguments,
1111 command[MaxTextExtent];
1112
1113 int
1114 number_arguments;
1115
1116 MagickBooleanType
1117 status;
1118
1119 register long
1120 i,
1121 j;
1122
1123 unsigned long
1124 test;
1125
1126 test=0;
1127 (void) fprintf(stdout,"validate stream command line program:\n");
1128 for (i=0; stream_options[i] != (char *) NULL; i++)
1129 {
1130 CatchException(exception);
1131 (void) fprintf(stdout," test %lu: %s",test++,stream_options[i]);
1132 (void) FormatMagickString(command,MaxTextExtent,"%s %s %s",
1133 stream_options[i],reference_filename,output_filename);
1134 arguments=StringToArgv(command,&number_arguments);
1135 if (arguments == (char **) NULL)
1136 {
1137 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
1138 (*fail)++;
1139 continue;
1140 }
1141 status=StreamImageCommand(image_info,number_arguments,arguments,
1142 (char **) NULL,exception);
1143 for (j=0; j < number_arguments; j++)
1144 arguments[j]=DestroyString(arguments[j]);
1145 arguments=(char **) RelinquishMagickMemory(arguments);
1146 if (status != MagickFalse)
1147 {
1148 (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
1149 (*fail)++;
1150 continue;
1151 }
1152 (void) fprintf(stdout,"... pass.\n");
1153 }
1154 (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
1155 test,test-(*fail),*fail);
1156 return(test);
1157}
1158
1159/*
1160%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1161% %
1162% %
1163% %
1164% M a i n %
1165% %
1166% %
1167% %
1168%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1169%
1170%
1171*/
1172
1173static MagickBooleanType ValidateUsage(void)
1174{
1175 const char
1176 **p;
1177
1178 static const char
1179 *miscellaneous[]=
1180 {
1181 "-debug events display copious debugging information",
1182 "-help print program options",
1183 "-log format format of debugging information",
1184 "-validate type validation type",
1185 "-version print version information",
1186 (char *) NULL
1187 },
1188 *settings[]=
1189 {
1190 "-regard-warnings pay attention to warning messages",
1191 "-verbose print detailed information about the image",
1192 (char *) NULL
1193 };
1194
1195 (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
1196 (void) printf("Copyright: %s\n\n",GetMagickCopyright());
1197 (void) printf("Usage: %s [options ...] reference-file\n",GetClientName());
1198 (void) printf("\nValidate Settings:\n");
1199 for (p=settings; *p != (char *) NULL; p++)
1200 (void) printf(" %s\n",*p);
1201 (void) printf("\nMiscellaneous Options:\n");
1202 for (p=miscellaneous; *p != (char *) NULL; p++)
1203 (void) printf(" %s\n",*p);
1204 return(MagickTrue);
1205}
1206
1207int main(int argc,char **argv)
1208{
1209#define DestroyValidate() \
1210{ \
1211 timer=DestroyTimerInfo(timer); \
1212 image_info=DestroyImageInfo(image_info); \
1213 exception=DestroyExceptionInfo(exception); \
1214}
1215#define ThrowValidateException(asperity,tag,option) \
1216{ \
1217 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
1218 option); \
1219 CatchException(exception); \
1220 DestroyValidate(); \
1221 return(MagickFalse); \
1222}
1223
1224 char
1225 output_filename[MaxTextExtent],
1226 reference_filename[MaxTextExtent],
1227 *option;
1228
1229 double
1230 elapsed_time,
1231 user_time;
1232
1233 ExceptionInfo
1234 *exception;
1235
1236 Image
1237 *reference_image;
1238
1239 ImageInfo
1240 *image_info;
1241
1242 MagickBooleanType
1243 regard_warnings,
1244 status;
1245
1246 register long
1247 i;
1248
1249 TimerInfo
1250 *timer;
1251
1252 unsigned long
1253 fail,
1254 iterations,
1255 tests;
1256
1257 ValidateType
1258 type;
1259
1260 /*
1261 Validate the ImageMagick image processing suite.
1262 */
1263 MagickCoreGenesis(*argv,MagickFalse);
1264 iterations=1;
1265 status=MagickFalse;
1266 type=AllValidate;
1267 regard_warnings=MagickFalse;
1268 exception=AcquireExceptionInfo();
1269 image_info=AcquireImageInfo();
1270 (void) CopyMagickString(image_info->filename,ReferenceFilename,MaxTextExtent);
1271 timer=AcquireTimerInfo();
1272 GetTimerInfo(timer);
1273 for (i=1; i < (long) argc; i++)
1274 {
1275 option=argv[i];
1276 if (IsMagickOption(option) == MagickFalse)
1277 {
1278 (void) CopyMagickString(image_info->filename,option,MaxTextExtent);
1279 continue;
1280 }
1281 switch (*(option+1))
1282 {
1283 case 'b':
1284 {
1285 if (LocaleCompare("bench",option+1) == 0)
1286 {
1287 iterations=(unsigned long) atol(argv[++i]);
1288 break;
1289 }
1290 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1291 }
1292 case 'd':
1293 {
1294 if (LocaleCompare("debug",option+1) == 0)
1295 {
1296 (void) SetLogEventMask(argv[++i]);
1297 break;
1298 }
1299 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1300 }
1301 case 'h':
1302 {
1303 if (LocaleCompare("help",option+1) == 0)
1304 {
1305 (void) ValidateUsage();
1306 return(0);
1307 }
1308 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1309 }
1310 case 'l':
1311 {
1312 if (LocaleCompare("log",option+1) == 0)
1313 {
1314 if (*option != '+')
1315 (void) SetLogFormat(argv[i+1]);
1316 break;
1317 }
1318 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1319 }
1320 case 'r':
1321 {
1322 if (LocaleCompare("regard-warnings",option+1) == 0)
1323 {
1324 regard_warnings=MagickTrue;
1325 break;
1326 }
1327 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1328 }
1329 case 'v':
1330 {
1331 if (LocaleCompare("validate",option+1) == 0)
1332 {
1333 long
1334 validate;
1335
1336 if (*option == '+')
1337 break;
1338 i++;
1339 if (i == (long) argc)
1340 ThrowValidateException(OptionError,"MissingArgument",option);
1341 validate=ParseMagickOption(MagickValidateOptions,MagickFalse,
1342 argv[i]);
1343 if (validate < 0)
1344 ThrowValidateException(OptionError,"UnrecognizedValidateType",
1345 argv[i]);
1346 type=(ValidateType) validate;
1347 break;
1348 }
1349 if ((LocaleCompare("version",option+1) == 0) ||
1350 (LocaleCompare("-version",option+1) == 0))
1351 {
1352 (void) fprintf(stdout,"Version: %s\n",
1353 GetMagickVersion((unsigned long *) NULL));
1354 (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright());
1355 return(0);
1356 }
1357 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1358 }
1359 default:
1360 ThrowValidateException(OptionError,"UnrecognizedOption",option)
1361 }
1362 }
1363 reference_image=ReadImage(image_info,exception);
1364 tests=0;
1365 fail=0;
1366 if (reference_image == (Image *) NULL)
1367 fail++;
1368 else
1369 {
1370 if (LocaleCompare(image_info->filename,ReferenceFilename) == 0)
1371 (void) CopyMagickString(reference_image->magick,ReferenceImageFormat,
1372 MaxTextExtent);
1373 (void) AcquireUniqueFilename(reference_filename);
1374 (void) AcquireUniqueFilename(output_filename);
1375 (void) CopyMagickString(reference_image->filename,reference_filename,
1376 MaxTextExtent);
1377 status=WriteImage(image_info,reference_image);
1378 InheritException(exception,&reference_image->exception);
1379 reference_image=DestroyImage(reference_image);
1380 if (status == MagickFalse)
1381 fail++;
1382 else
1383 {
1384 (void) fprintf(stdout,"Version: %s\n",
1385 GetMagickVersion((unsigned long *) NULL));
1386 (void) fprintf(stdout,"Copyright: %s\n\n",
1387 GetMagickCopyright());
1388 (void) fprintf(stdout,"ImageMagick Validation Suite (%s)\n\n",
1389 MagickOptionToMnemonic(MagickValidateOptions,(long) type));
1390 if ((type & CompareValidate) != 0)
1391 tests+=ValidateCompareCommand(image_info,reference_filename,
1392 output_filename,&fail,exception);
1393 if ((type & CompositeValidate) != 0)
1394 tests+=ValidateCompositeCommand(image_info,reference_filename,
1395 output_filename,&fail,exception);
1396 if ((type & ConvertValidate) != 0)
1397 tests+=ValidateConvertCommand(image_info,reference_filename,
1398 output_filename,&fail,exception);
1399 if ((type & FormatsInMemoryValidate) != 0)
1400 tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
1401 output_filename,&fail,exception);
1402 if ((type & FormatsOnDiskValidate) != 0)
1403 tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
1404 output_filename,&fail,exception);
1405 if ((type & IdentifyValidate) != 0)
1406 tests+=ValidateIdentifyCommand(image_info,reference_filename,
1407 output_filename,&fail,exception);
1408 if ((type & ImportExportValidate) != 0)
1409 tests+=ValidateImportExportPixels(image_info,reference_filename,
1410 output_filename,&fail,exception);
1411 if ((type & MontageValidate) != 0)
1412 tests+=ValidateMontageCommand(image_info,reference_filename,
1413 output_filename,&fail,exception);
1414 if ((type & StreamValidate) != 0)
1415 tests+=ValidateStreamCommand(image_info,reference_filename,
1416 output_filename,&fail,exception);
1417 (void) fprintf(stdout,"validation suite: %lu tests; %lu passed; "
1418 "%lu failed.\n",tests,tests-fail,fail);
1419 }
1420 (void) RelinquishUniqueFileResource(output_filename);
1421 (void) RelinquishUniqueFileResource(reference_filename);
1422 }
1423 if (exception->severity != UndefinedException)
1424 CatchException(exception);
1425 if (iterations > 1)
1426 {
1427 elapsed_time=GetElapsedTime(timer);
1428 user_time=GetUserTime(timer);
1429 (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld\n",
1430 iterations,1.0*iterations/elapsed_time,user_time,(long)
1431 (elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0)));
1432 }
1433 DestroyValidate();
1434 MagickCoreTerminus();
1435 return(fail == 0 ? 0 : 1);
1436}