From 4084cda465bf1f01d00c2f6e4a6d6f446889cad4 Mon Sep 17 00:00:00 2001 From: glennrp Date: Tue, 11 Dec 2012 14:13:35 +0000 Subject: [PATCH] Add count of leftover temporary files to validate-formats-in-memory.log --- MagickCore/resource.c | 2 +- MagickCore/resource_.h | 1 + tests/validate.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/MagickCore/resource.c b/MagickCore/resource.c index 9f206dc8c..23f534e6f 100644 --- a/MagickCore/resource.c +++ b/MagickCore/resource.c @@ -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, diff --git a/MagickCore/resource_.h b/MagickCore/resource_.h index abf1dbfad..6226e39fd 100644 --- a/MagickCore/resource_.h +++ b/MagickCore/resource_.h @@ -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); diff --git a/tests/validate.c b/tests/validate.c index 6769e3446..8263c5a7f 100644 --- a/tests/validate.c +++ b/tests/validate.c @@ -47,6 +47,7 @@ #include #include "MagickWand/MagickWand.h" #include "MagickCore/colorspace-private.h" +#include "MagickCore/resource_.h" #include "MagickCore/string-private.h" #include "validate.h" @@ -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, -- 2.40.0