summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-16 17:15:52 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-16 17:15:52 -0400
commitbc2983928dc8f98051321846d8c8fa374c8181b6 (patch)
tree0583aa92ab796ba6c4167618ff1f757e58c9e174
parent5e1870e259e866f3720bddbf757dec0c781cc967 (diff)
downloadfork-ledger-bc2983928dc8f98051321846d8c8fa374c8181b6.tar.gz
fork-ledger-bc2983928dc8f98051321846d8c8fa374c8181b6.tar.bz2
fork-ledger-bc2983928dc8f98051321846d8c8fa374c8181b6.zip
Compilation verification code only with debugging
Previously, --verify would work even if the sources were built with default options. However, in the interests of performance, --verify is now only available if --enable-debug was passed to configure.
-rw-r--r--src/main.cc4
-rw-r--r--src/utils.cc2
-rw-r--r--src/utils.h1
-rw-r--r--test/UnitTests.cc10
4 files changed, 14 insertions, 3 deletions
diff --git a/src/main.cc b/src/main.cc
index 26f3fe31..58b3f169 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -62,7 +62,9 @@ int main(int argc, char * argv[], char * envp[])
// --debug CATEGORY ; turns on debug logging
// --trace LEVEL ; turns on trace logging
handle_debug_options(argc, argv);
+#if defined(VERIFY_ON)
IF_VERIFY() initialize_memory_tracing();
+#endif
INFO("Ledger starting");
@@ -193,7 +195,9 @@ int main(int argc, char * argv[], char * envp[])
global_scope.reset();
INFO("Ledger ended (Boost/libstdc++ may still hold memory)");
+#if defined(VERIFY_ON)
shutdown_memory_tracing();
+#endif
} else {
// Don't free anything, just let it all leak.
global_scope.release();
diff --git a/src/utils.cc b/src/utils.cc
index d20d585a..d42ed79c 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -463,12 +463,14 @@ bool logger_func(log_level_t level)
*_log_stream << std::right << std::setw(5)
<< (CURRENT_TIME() - logger_start).total_milliseconds() << "ms";
+#if defined(VERIFY_ON)
IF_VERIFY() {
*_log_stream << std::right << std::setw(6) << std::setprecision(3);
stream_memory_size(*_log_stream, current_objects_size());
*_log_stream << std::right << std::setw(6) << std::setprecision(3);
stream_memory_size(*_log_stream, current_memory_size());
}
+#endif
*_log_stream << " " << std::left << std::setw(7);
diff --git a/src/utils.h b/src/utils.h
index 93cb9a4a..4beff305 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -60,7 +60,6 @@
#define NO_ASSERTS 1
#define NO_LOGGING 1
#else
-#define VERIFY_ON 1 // compiled in, use --verify to enable
#define TRACING_ON 1 // use --trace X to enable
#define TIMERS_ON 1
#endif
diff --git a/test/UnitTests.cc b/test/UnitTests.cc
index 9095da85..8b19a6fe 100644
--- a/test/UnitTests.cc
+++ b/test/UnitTests.cc
@@ -48,10 +48,12 @@ int main(int argc, char* argv[])
{
int index = 1;
+#if defined(VERIFY_ON)
if (argc > index && std::string(argv[index]) == "--verify") {
ledger::verify_enabled = true;
index++;
}
+#endif
// Retreive test path from command line first argument. Default to
// "" which resolves to the top level suite.
@@ -77,19 +79,23 @@ int main(int argc, char* argv[])
CPPUNIT_NS::TestRunner runner;
runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
try {
+#if defined(VERIFY_ON)
IF_VERIFY()
ledger::initialize_memory_tracing();
+#endif
runner.run(controller, testPath);
+#if defined(VERIFY_ON)
IF_VERIFY()
ledger::shutdown_memory_tracing();
+#endif
+#if 1
// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
outputter.write();
-
-#if 0
+#else
// Uncomment this for XML output
std::ofstream file("tests.xml");
CPPUNIT_NS::XmlOutputter xml(&result, file);