]> granicus.if.org Git - imagemagick/blobdiff - tests/validate.c
(no commit message)
[imagemagick] / tests / validate.c
index 69c0b1f0f23e6926b87c0f98c7abdada150dafad..ef1547ebbe7c2fbb5c368946fd57bb9e79df3bfb 100644 (file)
@@ -18,7 +18,7 @@
 %                               March 2001                                    %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 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
@@ -449,11 +451,22 @@ static size_t ValidateIdentifyCommand(ImageInfo *image_info,
 %    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)
 {
   char
+#ifdef MagickCountTempFiles
+    SystemCommand[MaxTextExtent],
+    path[MaxTextExtent],
+#endif
     size[MaxTextExtent];
 
   const MagickInfo
@@ -485,6 +498,14 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
 
   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);
@@ -653,7 +674,18 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
           (*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,
@@ -1321,6 +1353,10 @@ int main(int argc,char **argv)
     regard_warnings,
     status;
 
+  MagickSizeType
+    memory_resource,
+    map_resource;
+
   register ssize_t
     i;
 
@@ -1338,7 +1374,9 @@ int main(int argc,char **argv)
   /*
     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;
@@ -1480,21 +1518,36 @@ int main(int argc,char **argv)
             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)
             {
               (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
               tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
                 output_filename,&fail,exception);
               (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
-              (void) SetMagickResourceLimit(MemoryResource,0);
+              memory_resource=SetMagickResourceLimit(MemoryResource,0);
               tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
                 output_filename,&fail,exception);
               (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
-              (void) SetMagickResourceLimit(MapResource,0);
+              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,