summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2010-05-27 14:21:46 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2010-05-27 14:21:46 +0200
commit0d48a797334cd9c0734c6e7b8e446ac7be68c62f (patch)
tree8ce1a817e7859e520c3ee43811778f4846f8e90c /src
parentb4865677f5330b6b844190cacec794f1bfb3d380 (diff)
output redirection: detect glib output despite app name
When an application name is set (as introduced for client-test by some recent changes), testing against "** (process:" as glib prefix is insufficient, because "process" will be replaced by the actual application name. This was detected by the unit tests. This patch fixes the problem by relaxing the glib testing (check for "** (" prefix and " **:") and extends the unit test.
Diffstat (limited to 'src')
-rw-r--r--src/syncevo/LogRedirect.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/syncevo/LogRedirect.cpp b/src/syncevo/LogRedirect.cpp
index eb17d7b3..66dd2522 100644
--- a/src/syncevo/LogRedirect.cpp
+++ b/src/syncevo/LogRedirect.cpp
@@ -393,10 +393,11 @@ bool LogRedirect::process(FDs &fds) throw()
while (*text == '\n') {
text++;
}
- const char *glib_debug_prefix = "** (process:";
+ const char *glib_debug_prefix = "** ("; // ** (client-test:875): WARNING **:
const char *glib_msg_prefix = "** Message:";
prefix = "stderr";
- if (!strncmp(text, glib_debug_prefix, strlen(glib_debug_prefix)) ||
+ if ((!strncmp(text, glib_debug_prefix, strlen(glib_debug_prefix)) &&
+ strstr(text, " **:")) ||
!strncmp(text, glib_msg_prefix, strlen(glib_msg_prefix))) {
level = Logger::DEBUG;
prefix = "glib";
@@ -662,10 +663,19 @@ public:
buffer.m_redirect->process();
- std::string debug = buffer.m_streams[Logger::DEBUG].str();
+ std::string error = buffer.m_streams[Logger::ERROR].str();
+ std::string warning = buffer.m_streams[Logger::WARNING].str();
+ std::string show = buffer.m_streams[Logger::SHOW].str();
+ std::string info = buffer.m_streams[Logger::INFO].str();
std::string dev = buffer.m_streams[Logger::DEV].str();
- CPPUNIT_ASSERT(debug.find("test warning") != debug.npos);
+ std::string debug = buffer.m_streams[Logger::DEBUG].str();
+ CPPUNIT_ASSERT_EQUAL(string(""), error);
+ CPPUNIT_ASSERT_EQUAL(string(""), warning);
+ CPPUNIT_ASSERT_EQUAL(string(""), show);
+ CPPUNIT_ASSERT_EQUAL(string(""), info);
+ CPPUNIT_ASSERT_EQUAL(string(""), error);
CPPUNIT_ASSERT(dev.find("normal message stderr") != dev.npos);
+ CPPUNIT_ASSERT(debug.find("test warning") != debug.npos);
} catch(...) {
dup2(orig_stdout, STDOUT_FILENO);
throw;