From b58a63543ea0bf9c5e35e707eadb07dc7e768fd9 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne <edward@nmr-relax.com> Date: Tue, 30 Jul 2019 14:54:45 +0200 Subject: [PATCH] TestSuite: Implementation of the --log-split command line option. --- test_suite/fgCompilerOutputter.cxx | 18 ++++++++++++------ test_suite/logging.cxx | 22 +++++++++++++++------- test_suite/logging.hxx | 2 +- test_suite/testSuite.cxx | 9 ++++++++- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/test_suite/fgCompilerOutputter.cxx b/test_suite/fgCompilerOutputter.cxx index 27f6c84c1..7226595ca 100644 --- a/test_suite/fgCompilerOutputter.cxx +++ b/test_suite/fgCompilerOutputter.cxx @@ -65,12 +65,18 @@ void fgCompilerOutputter::printFailureDetail(CppUnit::TestFailure *failure) test_io = *test_iter; // SG_LOG IO streams. - fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, "+test_io.log_priority+" priority", test_io.sg_interleaved, true); - //fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_BULK only priority", test_io.sg_bulk_only); - //fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_DEBUG only priority", test_io.sg_debug_only); - //fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_INFO only priority", test_io.sg_info_only); - //fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_WARN only priority", test_io.sg_warn_only); - //fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_ALERT only priority", test_io.sg_alert_only); + if (!test_io.sg_interleaved.empty()) + fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, "+test_io.log_priority+" priority", test_io.sg_interleaved, true); + if (!test_io.sg_bulk_only.empty()) + fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_BULK only priority", test_io.sg_bulk_only); + if (!test_io.sg_debug_only.empty()) + fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_DEBUG only priority", test_io.sg_debug_only); + if (!test_io.sg_info_only.empty()) + fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_INFO only priority", test_io.sg_info_only); + if (!test_io.sg_warn_only.empty()) + fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_WARN only priority", test_io.sg_warn_only); + if (!test_io.sg_alert_only.empty()) + fgCompilerOutputter::printIOStreamMessages("SG_LOG, SG_ALL class, SG_ALERT only priority", test_io.sg_alert_only); // Default IO streams. fgCompilerOutputter::printIOStreamMessages("STDOUT and STDERR", test_io.stdio); diff --git a/test_suite/logging.cxx b/test_suite/logging.cxx index 26a19c573..aa2ccb98b 100644 --- a/test_suite/logging.cxx +++ b/test_suite/logging.cxx @@ -82,7 +82,7 @@ capturedIO & getIOstreams(sgDebugPriority p) // Set up to capture all the simgear logging priorities as separate streams. -void setupLogging(sgDebugPriority p) +void setupLogging(sgDebugPriority p, bool split) { // Get the single logstream instance. logstream &log = sglog(); @@ -95,12 +95,20 @@ void setupLogging(sgDebugPriority p) // IO capture. capturedIO &obj = getIOstreams(p); - log.addCallback(obj.callback_interleaved); - log.addCallback(obj.callback_bulk_only); - log.addCallback(obj.callback_debug_only); - log.addCallback(obj.callback_info_only); - log.addCallback(obj.callback_warn_only); - log.addCallback(obj.callback_alert_only); + if (!split) + log.addCallback(obj.callback_interleaved); + else { + if (p <= SG_BULK) + log.addCallback(obj.callback_bulk_only); + if (p <= SG_DEBUG) + log.addCallback(obj.callback_debug_only); + if (p <= SG_INFO) + log.addCallback(obj.callback_info_only); + if (p <= SG_WARN) + log.addCallback(obj.callback_warn_only); + if (p <= SG_ALERT) + log.addCallback(obj.callback_alert_only); + } } diff --git a/test_suite/logging.hxx b/test_suite/logging.hxx index 026e57648..67a0df958 100644 --- a/test_suite/logging.hxx +++ b/test_suite/logging.hxx @@ -90,7 +90,7 @@ class capturedIO capturedIO & getIOstreams(sgDebugPriority p=SG_BULK); // Set up to capture all the simgear logging priorities as separate streams. -void setupLogging(sgDebugPriority); +void setupLogging(sgDebugPriority, bool); // Deactivate all the simgear logging priority IO captures. void stopLogging(); diff --git a/test_suite/testSuite.cxx b/test_suite/testSuite.cxx index bc8fe6c53..128efc149 100644 --- a/test_suite/testSuite.cxx +++ b/test_suite/testSuite.cxx @@ -90,6 +90,7 @@ int main(int argc, char **argv) // Declarations. int status_gui=-1, status_simgear=-1, status_system=-1, status_unit=-1, status_fgdata=-1; bool run_system=false, run_unit=false, run_gui=false, run_simgear=false, run_fgdata=false; + bool logSplit=false; bool verbose=false, ctest_output=false, debug=false, printSummary=true, help=false; char *subset_system=NULL, *subset_unit=NULL, *subset_gui=NULL, *subset_simgear=NULL, *subset_fgdata=NULL; char firstchar; @@ -166,6 +167,10 @@ int main(int argc, char **argv) return 1; } + // Log splitting. + } else if (arg == "--log-split") { + logSplit = true; + // Verbose output. } else if (arg == "-v" || arg == "--verbose") { verbose = true; @@ -217,6 +222,8 @@ int main(int argc, char **argv) std::cout << " Logging options:" << std::endl; std::cout << " --log-level={bulk,debug,info,warn,alert,popup,dev_warn,dev_alert}" << std::endl; std::cout << " specify the minimum logging level to output" << std::endl; + std::cout << " --log-split output the different non-interleaved log streams" << std::endl; + std::cout << " sequentially" << std::endl; std::cout << std::endl; std::cout << " Verbosity options:" << std::endl; std::cout << " -v, --verbose verbose output including names and timings for all" << std::endl; @@ -251,7 +258,7 @@ int main(int argc, char **argv) if (debug) sglog().setLogLevels(SG_ALL, logPriority); else - setupLogging(logPriority); + setupLogging(logPriority, logSplit); // Execute each of the test suite categories. if (run_system)