% March 2001 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#include <string.h>
#include <ctype.h>
#include <math.h>
+#include <locale.h>
#include "MagickWand/MagickWand.h"
#include "MagickCore/colorspace-private.h"
+#include "MagickCore/resource_.h"
#include "MagickCore/string-private.h"
#include "validate.h"
\f
%
*/
static size_t ValidateCompareCommand(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
**arguments,
}
status=CompareImagesCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
- for (j=0; j < number_arguments; j++)
+ for (j=0; j < (ssize_t) number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
%
*/
static size_t ValidateCompositeCommand(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
**arguments,
}
status=CompositeImageCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
- for (j=0; j < number_arguments; j++)
+ for (j=0; j < (ssize_t) number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
%
*/
static size_t ValidateConvertCommand(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
**arguments,
}
status=ConvertImageCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
- for (j=0; j < number_arguments; j++)
+ for (j=0; j < (ssize_t) number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
%
*/
static size_t ValidateIdentifyCommand(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
**arguments,
}
status=IdentifyImageCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
- for (j=0; j < number_arguments; j++)
+ for (j=0; j < (ssize_t) number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
% o exception: return any errors or warnings in this structure.
%
*/
+
+/*
+ Enable this to count remaining $TMPDIR/magick-* files. Note that the count
+ includes any files left over from other runs.
+*/
+#undef MagickCountTempFiles
+
static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
+#ifdef MagickCountTempFiles
+ SystemCommand[MaxTextExtent],
+ path[MaxTextExtent],
+#endif
size[MaxTextExtent];
const MagickInfo
Image
*difference_image,
- *reference_image,
- *reconstruct_image;
+ *ping_image,
+ *reconstruct_image,
+ *reference_image;
MagickBooleanType
status;
j;
size_t
- length;
+ length,
+ test;
unsigned char
*blob;
- size_t
- test;
-
test=0;
(void) FormatLocaleFile(stdout,"validate image formats in memory:\n");
+
+#ifdef MagickCountTempFiles
+ (void)GetPathTemplate(path);
+ /* Remove file template except for the leading "magick-" */
+ path[strlen(path)-17]='\0';
+ (void) FormatLocaleFile(stdout," tmp path is '%s*'\n",path);
+#endif
+
for (i=0; reference_formats[i].magick != (char *) NULL; i++)
{
magick_info=GetMagickInfo(reference_formats[i].magick,exception);
continue;
}
/*
- Read reference image.
+ Ping reference image.
*/
(void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
reference_formats[i].magick,output_filename);
+ ping_image=PingImage(image_info,exception);
+ if (ping_image == (Image *) NULL)
+ {
+ (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+ GetMagickModule());
+ (*fail)++;
+ continue;
+ }
+ ping_image=DestroyImage(ping_image);
+ /*
+ Read reference image.
+ */
reference_image=ReadImage(image_info,exception);
if (reference_image == (Image *) NULL)
{
reference_image=DestroyImage(reference_image);
continue;
}
+ /*
+ Ping reference blob.
+ */
+ ping_image=PingBlob(image_info,blob,length,exception);
+ if (ping_image == (Image *) NULL)
+ {
+ (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+ GetMagickModule());
+ (*fail)++;
+ blob=(unsigned char *) RelinquishMagickMemory(blob);
+ continue;
+ }
+ ping_image=DestroyImage(ping_image);
/*
Read reconstruct image.
*/
#if defined(MAGICKCORE_HDRI_SUPPORT)
fuzz+=0.003;
#endif
- if (IsRGBColorspace(reference_image->colorspace) == MagickFalse)
+ if (IssRGBColorspace(reference_image->colorspace) == MagickFalse)
fuzz+=0.3;
fuzz+=MagickEpsilon;
difference_image=CompareImages(reference_image,reconstruct_image,
- MeanSquaredErrorMetric,&distortion,exception);
+ RootMeanSquaredErrorMetric,&distortion,exception);
reconstruct_image=DestroyImage(reconstruct_image);
reference_image=DestroyImage(reference_image);
if (difference_image == (Image *) NULL)
continue;
}
difference_image=DestroyImage(difference_image);
- if ((distortion/QuantumRange) > fuzz)
+ if ((QuantumScale*distortion) > fuzz)
{
(void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
- distortion/QuantumRange);
+ QuantumScale*distortion);
(*fail)++;
continue;
}
- (void) FormatLocaleFile(stdout,"... pass.\n");
+#ifdef MagickCountTempFiles
+ (void) FormatLocaleFile(stdout,"... pass, ");
+ (void) fflush(stdout);
+ SystemCommand[0]='\0';
+ (void)strncat(SystemCommand,"echo `ls ",9);
+ (void)strncat(SystemCommand,path,MaxTextExtent-31);
+ (void)strncat(SystemCommand,"* | wc -w` tmp files.",20);
+ (void)system(SystemCommand);
+ (void) fflush(stdout);
+#else
+ (void) FormatLocaleFile(stdout,"... pass\n");
+#endif
}
}
(void) FormatLocaleFile(stdout,
%
*/
static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
size[MaxTextExtent];
#if defined(MAGICKCORE_HDRI_SUPPORT)
fuzz+=0.003;
#endif
- if (IsRGBColorspace(reference_image->colorspace) == MagickFalse)
+ if (IssRGBColorspace(reference_image->colorspace) == MagickFalse)
fuzz+=0.3;
fuzz+=MagickEpsilon;
difference_image=CompareImages(reference_image,reconstruct_image,
- MeanSquaredErrorMetric,&distortion,exception);
+ RootMeanSquaredErrorMetric,&distortion,exception);
reconstruct_image=DestroyImage(reconstruct_image);
reference_image=DestroyImage(reference_image);
if (difference_image == (Image *) NULL)
continue;
}
difference_image=DestroyImage(difference_image);
- if ((distortion/QuantumRange) > fuzz)
+ if ((QuantumScale*distortion) > fuzz)
{
(void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
- distortion/QuantumRange);
+ QuantumScale*distortion);
(*fail)++;
continue;
}
%
*/
static size_t ValidateImportExportPixels(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
double
distortion;
continue;
}
if (LocaleNCompare(reference_map[i],"cmy",3) == 0)
- reference_image->colorspace=CMYKColorspace;
+ (void) SetImageColorspace(reference_image,CMYKColorspace,exception);
length=strlen(reference_map[i])*reference_image->columns*
reference_image->rows*reference_storage[j].quantum;
pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels));
Compare reference to reconstruct image.
*/
difference_image=CompareImages(reference_image,reconstruct_image,
- MeanSquaredErrorMetric,&distortion,exception);
+ RootMeanSquaredErrorMetric,&distortion,exception);
reconstruct_image=DestroyImage(reconstruct_image);
reference_image=DestroyImage(reference_image);
if (difference_image == (Image *) NULL)
continue;
}
difference_image=DestroyImage(difference_image);
- if ((distortion/QuantumRange) > 0.0)
+ if ((QuantumScale*distortion) > 0.0)
{
(void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
- distortion/QuantumRange);
+ QuantumScale*distortion);
(*fail)++;
continue;
}
%
*/
static size_t ValidateMontageCommand(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
**arguments,
}
status=MontageImageCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
- for (j=0; j < number_arguments; j++)
+ for (j=0; j < (ssize_t) number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
%
*/
static size_t ValidateStreamCommand(ImageInfo *image_info,
- const char *reference_filename,const char *output_filename,
- size_t *fail,ExceptionInfo *exception)
+ const char *reference_filename,const char *output_filename,size_t *fail,
+ ExceptionInfo *exception)
{
char
**arguments,
}
status=StreamImageCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
- for (j=0; j < number_arguments; j++)
+ for (j=0; j < (ssize_t) number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
regard_warnings,
status;
+ MagickSizeType
+ memory_resource,
+ map_resource;
+
register ssize_t
i;
/*
Validate the ImageMagick image processing suite.
*/
- MagickCoreGenesis(*argv,MagickFalse);
+ MagickCoreGenesis(*argv,MagickTrue);
+ (void) setlocale(LC_ALL,"");
+ (void) setlocale(LC_NUMERIC,"C");
iterations=1;
status=MagickFalse;
type=AllValidate;
tests+=ValidateConvertCommand(image_info,reference_filename,
output_filename,&fail,exception);
if ((type & FormatsInMemoryValidate) != 0)
- tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
- output_filename,&fail,exception);
+ {
+ (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
+ tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
+ output_filename,&fail,exception);
+ (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
+ memory_resource=SetMagickResourceLimit(MemoryResource,0);
+ tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
+ output_filename,&fail,exception);
+ (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
+ map_resource=SetMagickResourceLimit(MapResource,0);
+ tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
+ output_filename,&fail,exception);
+ (void) SetMagickResourceLimit(MemoryResource,memory_resource);
+ (void) SetMagickResourceLimit(MapResource,map_resource);
+ }
if ((type & FormatsOnDiskValidate) != 0)
- tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
- output_filename,&fail,exception);
+ {
+ (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
+ tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
+ output_filename,&fail,exception);
+ (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
+ memory_resource=SetMagickResourceLimit(MemoryResource,0);
+ tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
+ output_filename,&fail,exception);
+ (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
+ map_resource=SetMagickResourceLimit(MapResource,0);
+ tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
+ output_filename,&fail,exception);
+ (void) SetMagickResourceLimit(MemoryResource,memory_resource);
+ (void) SetMagickResourceLimit(MapResource,map_resource);
+ }
if ((type & IdentifyValidate) != 0)
tests+=ValidateIdentifyCommand(image_info,reference_filename,
output_filename,&fail,exception);