summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/SystemInformation/DumpInformation.cxx92
-rw-r--r--Tests/SystemInformation/DumpInformation.h.in9
2 files changed, 63 insertions, 38 deletions
diff --git a/Tests/SystemInformation/DumpInformation.cxx b/Tests/SystemInformation/DumpInformation.cxx
index 2976a3a..86f4698 100644
--- a/Tests/SystemInformation/DumpInformation.cxx
+++ b/Tests/SystemInformation/DumpInformation.cxx
@@ -1,49 +1,71 @@
-#include <stdio.h>
#include "DumpInformation.h"
+#include <stdio.h>
+#include <sys/stat.h>
-int DumpFile(char* filename, char* comment)
+void cmDumpInformationPrintFile(const char* name, FILE* fout)
{
- FILE* file = fopen(filename, "r");
- if(!file)
+ fprintf(fout,
+ "================================================================\n");
+ struct stat fs;
+ if(stat(name, &fs) != 0)
{
- printf("Error, could not open file %s\n", filename);
- return 1;
+ fprintf(fout, "The file \"%s\" does not exist.\n", name);
+ fflush(fout);
+ return;
}
- printf("%s", comment);
- while(!feof(file))
+
+ FILE* fin = fopen(name, "rb");
+ if(fin)
{
- int ch = fgetc(file);
- if(ch != EOF)
+ fprintf(fout,
+ "Contents of \"%s\":\n"
+ "----------------------------------------------------------------\n",
+ name);
+ const int bufferSize = 4096;
+ char buffer[bufferSize];
+ int n;
+ while((n = fread(buffer, 1, bufferSize, fin)) > 0)
{
- if(ch == '<')
+ for(char* c = buffer; c < buffer+n; ++c)
{
- printf("&lt;");
- }
- else if(ch == '>')
- {
- printf("&gt;");
- }
- else if(ch == '&')
- {
- printf("&amp;");
- }
- else
- {
- putc(ch, stdout);
+ switch(*c)
+ {
+ case '<': fprintf(fout, "&lt;"); break;
+ case '>': fprintf(fout, "&gt;"); break;
+ case '&': fprintf(fout, "&amp;"); break;
+ default: putc(*c, fout); break;
+ }
}
+ fflush(fout);
}
+ fclose(fin);
+ }
+ else
+ {
+ fprintf(fout, "Error opening \"%s\" for reading.\n", name);
+ fflush(fout);
}
- printf("\n");
- fclose(file);
- return 0;
}
-
-int main(int, char*[])
+int main(int,char *[])
{
- int res = 0;
- res += DumpFile(CMAKE_DUMP_FILE, "#CMake System Variables are:");
- res += DumpFile(CMAKE_CACHE_FILE, "#CMake Cache is:");
- res += DumpFile(CMAKE_ALL_VARIABLES, "#CMake Variables are:");
- return res;
-}
+ const char* files[] =
+ {
+ DumpInformation_BINARY_DIR "/SystemInformation.out",
+ DumpInformation_BINARY_DIR "/AllVariables.txt",
+ DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
+ DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
+ DumpInformation_BINARY_DIR "/../../CMakeOutput.log",
+ DumpInformation_BINARY_DIR "/../../CMakeError.log",
+ DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
+ 0
+ };
+
+ const char** f;
+ for(f = files; *f; ++f)
+ {
+ cmDumpInformationPrintFile(*f, stdout);
+ }
+
+ return 0;
+}
diff --git a/Tests/SystemInformation/DumpInformation.h.in b/Tests/SystemInformation/DumpInformation.h.in
index 42cfe1f..afbd2e1 100644
--- a/Tests/SystemInformation/DumpInformation.h.in
+++ b/Tests/SystemInformation/DumpInformation.h.in
@@ -1,3 +1,6 @@
-#define CMAKE_DUMP_FILE "${DumpInformation_BINARY_DIR}/SystemInformation.out"
-#define CMAKE_CACHE_FILE "${CMAKE_BINARY_DIR}/../../CMakeCache.txt"
-#define CMAKE_ALL_VARIABLES "${CMAKE_BINARY_DIR}/AllVariables.txt"
+#ifndef _DumpInformation_h
+#define _DumpInformation_h
+
+#define DumpInformation_BINARY_DIR "@DumpInformation_BINARY_DIR@"
+
+#endif