testing: use glib log handler
client-test now uses the same process initialization as all other SyncEvolution binaries and thus uses the new glib log handler. Also removes some code duplication. The glib output redirection test became a bit redundant, but let's keep it. For that we need to restore the default glib log handler while that test runs.
This commit is contained in:
parent
f4528fc3c9
commit
0194598236
|
@ -569,6 +569,9 @@ static class RegisterTestEvolution {
|
|||
public:
|
||||
RegisterTestEvolution() :
|
||||
testClient("1") {
|
||||
|
||||
SyncContext::initMain("client-test");
|
||||
|
||||
struct sigaction act;
|
||||
|
||||
memset(&act, 0, sizeof(act));
|
||||
|
@ -577,13 +580,6 @@ public:
|
|||
sigaction(SIGSEGV, &act, NULL);
|
||||
sigaction(SIGILL, &act, NULL);
|
||||
|
||||
#if defined(HAVE_GLIB)
|
||||
// this is required when using glib directly or indirectly
|
||||
g_type_init();
|
||||
g_thread_init(NULL);
|
||||
g_set_prgname("client-test");
|
||||
#endif
|
||||
EDSAbiWrapperInit();
|
||||
testClient.registerTests();
|
||||
}
|
||||
|
||||
|
|
|
@ -706,6 +706,11 @@ public:
|
|||
// check that intercept all glib message and don't print anything to stdout
|
||||
int orig_stdout = -1;
|
||||
try {
|
||||
// need to restore the current state below; would be nice
|
||||
// to query it instead of assuming that Logger::glogFunc
|
||||
// is the current log handler
|
||||
g_log_set_default_handler(g_log_default_handler, NULL);
|
||||
|
||||
orig_stdout = dup(STDOUT_FILENO);
|
||||
dup2(new_stdout, STDOUT_FILENO);
|
||||
|
||||
|
@ -744,9 +749,11 @@ public:
|
|||
CPPUNIT_ASSERT(dev.find("normal message stderr") != dev.npos);
|
||||
CPPUNIT_ASSERT(debug.find("test warning") != debug.npos);
|
||||
} catch(...) {
|
||||
g_log_set_default_handler(Logger::glogFunc, NULL);
|
||||
dup2(orig_stdout, STDOUT_FILENO);
|
||||
throw;
|
||||
}
|
||||
g_log_set_default_handler(Logger::glogFunc, NULL);
|
||||
dup2(orig_stdout, STDOUT_FILENO);
|
||||
|
||||
lseek(new_stdout, 0, SEEK_SET);
|
||||
|
|
Loading…
Reference in New Issue