Skip to content

Commit

Permalink
Add MythSystem unit test for kMSAnonLog
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed May 30, 2013
1 parent 53044f8 commit d2305c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 23 additions & 1 deletion mythtv/libs/libmythbase/test/test_mythsystem/test_mythsystem.h
Expand Up @@ -25,9 +25,16 @@
#include <iostream>
using namespace std;

#include "mythlogging_extra.h"
#include "debugloghandler.h"
#include "mythcorecontext.h"
#include "mythsystem.h"

static DebugLogHandler *console_dbg(void)
{
return DebugLogHandler::Get("ConsoleLogHandler");
}

class TestMythSystem: public QObject
{
Q_OBJECT
Expand All @@ -37,6 +44,10 @@ class TestMythSystem: public QObject
void initTestCase(void)
{
gCoreContext = new MythCoreContext("bin_version", NULL);
DebugLogHandler::AddReplacement("ConsoleLogHandler");
myth_logging::initialize_logging(
VB_GENERAL, LOG_INFO, kNoFacility, /*use_threads*/false,
/*logfile*/ QString(), /*logprefix*/QString());
}

// called at the end of these sets of tests
Expand Down Expand Up @@ -152,8 +163,19 @@ class TestMythSystem: public QObject
// TODO delete flag
// kMSNoRunShell -- do NOT run process through shell

// kMSAnonLog -- anonymize the logs
void logs_anonymized_when_requested(void)
{
console_dbg()->Clear();
MythSystem cmd(QString("echo %1").arg(__FUNCTION__), kMSAnonLog);
cmd.Run();
(void) cmd.Wait();
DebugLogHandlerEntry l = console_dbg()->LastEntry(kHandleLog);
QVERIFY(!l.entry().GetMessage().contains(__FUNCTION__));
QVERIFY(!cmd.GetLogCmd().contains(__FUNCTION__));
}

// TODO flags to test
// TODO kMSAnonLog -- anonymize the logs
// TODO kMSAbortOnJump -- abort this process on a jumppoint
// TODO kMSSetPGID -- set the process group id
// TODO kMSAutoCleanup -- automatically delete if backgrounded
Expand Down
Expand Up @@ -11,8 +11,8 @@ QT += testlib

TEMPLATE = app
TARGET = test_mythsystem
DEPENDPATH += . ../..
INCLUDEPATH += . ../..
DEPENDPATH += . ../.. ../../logging
INCLUDEPATH += . ../.. ../../logging
LIBS += -L../.. -lmythbase-$$LIBVERSION
LIBS += -Wl,-rpath,$${PWD}/../..

Expand Down

0 comments on commit d2305c0

Please sign in to comment.