summaryrefslogtreecommitdiffstats
path: root/Tests/CTestTestMemcheck/memtester.cxx.in
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2013-05-05 15:00:24 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2013-05-09 17:22:00 (GMT)
commitbcc0f3fb05276c58387e6ea43c1cf913790db0ed (patch)
tree7754d238c51ba9e173742fca0738840ebcbb54ad /Tests/CTestTestMemcheck/memtester.cxx.in
parentcf4869ba080ead1077bf5f3aa67c5c67a19e1a0d (diff)
downloadCMake-bcc0f3fb05276c58387e6ea43c1cf913790db0ed.zip
CMake-bcc0f3fb05276c58387e6ea43c1cf913790db0ed.tar.gz
CMake-bcc0f3fb05276c58387e6ea43c1cf913790db0ed.tar.bz2
Tests: create output files for all memory checkers
The dummy memory tester implementation now understands the command line switches for all memory checkers to redirect the output to a file. This avoids triggering the error cases for BoundsChecker and Purify because the output file does not exist.
Diffstat (limited to 'Tests/CTestTestMemcheck/memtester.cxx.in')
-rw-r--r--Tests/CTestTestMemcheck/memtester.cxx.in52
1 files changed, 52 insertions, 0 deletions
diff --git a/Tests/CTestTestMemcheck/memtester.cxx.in b/Tests/CTestTestMemcheck/memtester.cxx.in
new file mode 100644
index 0000000..64b72d3
--- /dev/null
+++ b/Tests/CTestTestMemcheck/memtester.cxx.in
@@ -0,0 +1,52 @@
+#include <string>
+#include <cmSystemTools.h>
+
+#define RETVAL @_retval@
+
+int
+main(int argc, char **argv)
+{
+ std::string exename = argv[0];
+ std::string logarg;
+ bool nextarg = false;
+
+ if (exename.find("valgrind") != exename.npos)
+ logarg = "--log-file=";
+ else if (exename.find("purify") != exename.npos)
+#ifdef _WIN32
+ logarg = "/SAVETEXTDATA=";
+#else
+ logarg = "-log-file=";
+#endif
+ else if (exename.find("BC") != exename.npos)
+ {
+ nextarg = true;
+ logarg = "/X";
+ }
+
+ if (!logarg.empty()) {
+ std::string logfile;
+ for (int i = 1; i < argc; i++) {
+ std::string arg = argv[i];
+ if (arg.find(logarg) == 0)
+ {
+ if (nextarg)
+ {
+ if (i == argc - 1)
+ return 1; // invalid command line
+ logfile = argv[i + 1];
+ }
+ else
+ {
+ logfile = arg.substr(logarg.length());
+ }
+ break;
+ }
+ }
+
+ if (!logfile.empty())
+ cmSystemTools::Touch(logfile.c_str(), true);
+ }
+
+ return RETVAL;
+}