Test for bug 648935.

This commit is contained in:
Chris Jones 2011-05-04 15:55:54 -05:00
parent 705e9bc07a
commit eb1da4388e
5 changed files with 221 additions and 0 deletions

View File

@ -75,6 +75,7 @@ IPDLTESTS = \
TestRaceDeferral \
TestRacyReentry \
TestRacyRPCReplies \
TestRacyUndefer \
TestSanity \
TestSelfManageRoot \
TestShmem \

View File

@ -0,0 +1,28 @@
namespace mozilla {
namespace _ipdltest {
rpc protocol PTestRacyUndefer {
child:
async Start();
async AwakenSpam();
async AwakenRaceWinTwice();
rpc Race();
async __delete__();
parent:
rpc Spam();
rpc RaceWinTwice();
async Done();
};
} // namespace mozilla
} // namespace _ipdltest

View File

@ -0,0 +1,115 @@
#include "base/basictypes.h"
#include "TestRacyUndefer.h"
#include "IPDLUnitTests.h" // fail etc.
namespace mozilla {
namespace _ipdltest {
//-----------------------------------------------------------------------------
// parent
TestRacyUndeferParent::TestRacyUndeferParent()
{
MOZ_COUNT_CTOR(TestRacyUndeferParent);
}
TestRacyUndeferParent::~TestRacyUndeferParent()
{
MOZ_COUNT_DTOR(TestRacyUndeferParent);
}
void
TestRacyUndeferParent::Main()
{
if (!SendStart())
fail("sending Start");
}
bool
TestRacyUndeferParent::AnswerSpam()
{
static bool spammed = false;
static bool raced = false;
if (!spammed) {
spammed = true;
if (!SendAwakenSpam())
fail("sending AwakenSpam");
}
else if (!raced) {
raced = true;
if (!SendAwakenRaceWinTwice())
fail("sending WinRaceTwice");
if (!CallRace())
fail("calling Race1");
}
return true;
}
bool
TestRacyUndeferParent::AnswerRaceWinTwice()
{
return true;
}
bool
TestRacyUndeferParent::RecvDone()
{
Close();
return true;
}
//-----------------------------------------------------------------------------
// child
TestRacyUndeferChild::TestRacyUndeferChild()
{
MOZ_COUNT_CTOR(TestRacyUndeferChild);
}
TestRacyUndeferChild::~TestRacyUndeferChild()
{
MOZ_COUNT_DTOR(TestRacyUndeferChild);
}
bool
TestRacyUndeferChild::RecvStart()
{
if (!CallSpam())
fail("calling Spam");
if (!SendDone())
fail("sending Done");
return true;
}
bool
TestRacyUndeferChild::RecvAwakenSpam()
{
if (!CallSpam())
fail("calling Spam");
return true;
}
bool
TestRacyUndeferChild::RecvAwakenRaceWinTwice()
{
if (!CallRaceWinTwice())
fail("calling RaceWinTwice");
return true;
}
bool
TestRacyUndeferChild::AnswerRace()
{
return true;
}
} // namespace _ipdltest
} // namespace mozilla

View File

@ -0,0 +1,76 @@
#ifndef mozilla__ipdltest_TestRacyUndefer_h
#define mozilla__ipdltest_TestRacyUndefer_h 1
#include "mozilla/_ipdltest/IPDLUnitTests.h"
#include "mozilla/_ipdltest/PTestRacyUndeferParent.h"
#include "mozilla/_ipdltest/PTestRacyUndeferChild.h"
namespace mozilla {
namespace _ipdltest {
class TestRacyUndeferParent :
public PTestRacyUndeferParent
{
public:
TestRacyUndeferParent();
virtual ~TestRacyUndeferParent();
void Main();
protected:
NS_OVERRIDE
virtual bool AnswerSpam();
NS_OVERRIDE
virtual bool AnswerRaceWinTwice();
NS_OVERRIDE
virtual bool RecvDone();
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why)
{
if (NormalShutdown != why)
fail("unexpected destruction!");
passed("ok");
QuitParent();
}
};
class TestRacyUndeferChild :
public PTestRacyUndeferChild
{
public:
TestRacyUndeferChild();
virtual ~TestRacyUndeferChild();
protected:
NS_OVERRIDE
virtual bool RecvStart();
NS_OVERRIDE
virtual bool RecvAwakenSpam();
NS_OVERRIDE
virtual bool RecvAwakenRaceWinTwice();
NS_OVERRIDE
virtual bool AnswerRace();
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why)
{
if (NormalShutdown != why)
fail("unexpected destruction!");
QuitChild();
}
};
} // namespace _ipdltest
} // namespace mozilla
#endif // ifndef mozilla__ipdltest_TestRacyUndefer_h

View File

@ -23,6 +23,7 @@ IPDLSRCS = \
PTestRaceDeferral.ipdl \
PTestRacyReentry.ipdl \
PTestRacyRPCReplies.ipdl \
PTestRacyUndefer.ipdl \
PTestRPCErrorCleanup.ipdl \
PTestRPCRaces.ipdl \
PTestRPCShutdownRace.ipdl \