]> granicus.if.org Git - imagemagick/commitdiff
Add count of leftover temporary files to validate-formats-in-memory.log
authorglennrp <glennrp@git.imagemagick.org>
Tue, 11 Dec 2012 14:13:35 +0000 (14:13 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Tue, 11 Dec 2012 14:13:35 +0000 (14:13 +0000)
MagickCore/resource.c
MagickCore/resource_.h
tests/validate.c

index 9f206dc8c19b12ba6adeda3c931d8a15a7a0cb93..23f534e6ffb91cc8520f24e40a1fdc320ca7ac75 100644 (file)
@@ -337,7 +337,7 @@ static void *DestroyTemporaryResources(void *temporary_resource)
   return((void *) NULL);
 }
 
-static MagickBooleanType GetPathTemplate(char *path)
+MagickExport MagickBooleanType GetPathTemplate(char *path)
 {
   char
     *directory,
index abf1dbfad8faa215a6e05765a39bd76bf5c2ca10..6226e39fd2f75781d4218b2d9953d2d994b8e651 100644 (file)
@@ -42,6 +42,7 @@ extern MagickExport int
 
 extern MagickExport MagickBooleanType
   AcquireMagickResource(const ResourceType,const MagickSizeType),
+  GetPathTemplate(char *),
   ListMagickResourceInfo(FILE *,ExceptionInfo *),
   RelinquishUniqueFileResource(const char *),
   SetMagickResourceLimit(const ResourceType,const MagickSizeType);
index 6769e34466a98c4340e8f59af763bcc240a09e3b..8263c5a7f50e98e57a7344e3908cf7abd958d31e 100644 (file)
@@ -47,6 +47,7 @@
 #include <math.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 +450,21 @@ 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.
+ */
+#define 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 +496,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 +672,19 @@ 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,