fix build bustage and test SEGFAULTs

This commit is contained in:
Chris Jones 2009-11-06 17:07:52 -06:00
parent d10ccd2c5a
commit 5412e0bc87
3 changed files with 42 additions and 18 deletions

View File

@ -15,7 +15,7 @@
ChromiumLogger::~ChromiumLogger()
{
if (mMsg) {
PR_LOG(gChromiumPRLog, mSeverity, ("%s", mMsg));
PR_LOG(GetLog(), mSeverity, ("%s", mMsg));
PR_Free(mMsg);
}
}
@ -29,7 +29,14 @@ ChromiumLogger::printf(const char* fmt, ...) const
va_end(args);
}
PRLogModuleInfo* ChromiumLogger::gChromiumPRLog = PR_NewLogModule("chromium");
PRLogModuleInfo* ChromiumLogger::gChromiumPRLog;
PRLogModuleInfo* ChromiumLogger::GetLog()
{
if (!gChromiumPRLog)
gChromiumPRLog = PR_NewLogModule("chromium");
return gChromiumPRLog;
}
const ChromiumLogger&
operator<<(const ChromiumLogger& log, const char* s)

View File

@ -43,6 +43,7 @@ public:
private:
static PRLogModuleInfo* gChromiumPRLog;
static PRLogModuleInfo* GetLog();
PRLogModuleLevel mSeverity;
mutable char* mMsg;

View File

@ -43,34 +43,50 @@
#include "base/process.h"
#include "chrome/common/ipc_channel.h"
#include "nsDebug.h"
#define MOZ_IPDL_TESTFAIL_LABEL "TEST-UNEXPECTED-FAIL"
#define MOZ_IPDL_TESTPASS_LABEL "TEST-PASS"
// NB: these are named like the similar functions in
// xpcom/test/TestHarness.h. The names should nominally be kept in
// sync.
#define fail(fmt, ...) \
do { \
fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | " fmt "\n", \
IPDLUnitTestName(), ## __VA_ARGS__); \
NS_RUNTIMEABORT("failed test"); \
} while (0)
#define passed(fmt, ...) \
fprintf(stderr, MOZ_IPDL_TESTPASS_LABEL " | %s | " fmt "\n", \
IPDLUnitTestName(), ## __VA_ARGS__)
namespace mozilla {
namespace _ipdltest {
//-----------------------------------------------------------------------------
// both processes
const char* const IPDLUnitTestName();
// NB: these are named like the similar functions in
// xpcom/test/TestHarness.h. The names should nominally be kept in
// sync.
inline void fail(const char* fmt, ...)
{
va_list ap;
fprintf(stderr, MOZ_IPDL_TESTFAIL_LABEL " | %s | ", IPDLUnitTestName());
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fputc('\n', stderr);
NS_RUNTIMEABORT("failed test");
}
inline void passed(const char* fmt, ...)
{
va_list ap;
printf(MOZ_IPDL_TESTPASS_LABEL " | %s | ", IPDLUnitTestName());
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
fputc('\n', stdout);
}
//-----------------------------------------------------------------------------
// parent process only