/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % V a l i d a t e M o n t a g e C o m m a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ValidateMontageCommand() validates the ImageMagick montage command line % program and returns the number of validation tests that passed and failed. % % The format of the ValidateMontageCommand method is: % % unsigned long ValidateMontageCommand(ImageInfo *image_info, % const char *reference_filename,const char *output_filename, % unsigned long *fail,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o reference_filename: the reference image filename. % % o output_filename: the output image filename. % % o fail: return the number of validation tests that pass. % % o exception: return any errors or warnings in this structure. % */ static unsigned long ValidateMontageCommand(ImageInfo *image_info, const char *reference_filename,const char *output_filename, unsigned long *fail,ExceptionInfo *exception) { char **arguments, command[MaxTextExtent]; int number_arguments; MagickBooleanType status; register long i, j; unsigned long test; test=0; (void) fprintf(stdout,"validate montage command line program:\n"); for (i=0; montage_options[i] != (char *) NULL; i++) { CatchException(exception); (void) fprintf(stdout," test %lu: %s",test++,montage_options[i]); (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s", reference_filename,montage_options[i],reference_filename, output_filename); arguments=StringToArgv(command,&number_arguments); if (arguments == (char **) NULL) { (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule()); (*fail)++; continue; } status=MontageImageCommand(image_info,number_arguments,arguments, (char **) NULL,exception); for (j=0; j < number_arguments; j++) arguments[j]=DestroyString(arguments[j]); arguments=(char **) RelinquishMagickMemory(arguments); if (status != MagickFalse) { (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule()); (*fail)++; continue; } (void) fprintf(stdout,"... pass.\n"); } (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n", test,test-(*fail),*fail); return(test); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a i n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ int main(int argc,char **argv) { char *option; ExceptionInfo exception; ImageInfo *image_info; MagickBooleanType status; register long i; InitializeMagick(*argv); GetExceptionInfo(&exception); for (i=1; i < (long) argc; i++) { option=argv[i]; if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) continue; if ((LocaleCompare("debug",option+1) == 0) && (i < (long) (argc-1))) (void) SetLogEventMask(argv[++i]); if (LocaleCompare("version",option+1) == 0) { (void) fprintf(stdout,"Version: %s\n", GetMagickVersion((unsigned long *) NULL)); (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright()); exit(0); } } image_info=CloneImageInfo((ImageInfo *) NULL); status=MontageImageCommand(image_info,argc,argv,(char **) NULL,&exception); if (exception.severity != UndefinedException) CatchException(&exception); image_info=DestroyImageInfo(image_info); DestroyExceptionInfo(&exception); DestroyMagick(); exit(!status); return(MagickFalse); }