зеркало из https://github.com/mozilla/pjs.git
Test for bug 648935.
This commit is contained in:
Родитель
9eaad3743e
Коммит
6408e925bc
|
@ -75,6 +75,7 @@ IPDLTESTS = \
|
|||
TestRaceDeferral \
|
||||
TestRacyReentry \
|
||||
TestRacyRPCReplies \
|
||||
TestRacyUndefer \
|
||||
TestSanity \
|
||||
TestSelfManageRoot \
|
||||
TestShmem \
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -23,6 +23,7 @@ IPDLSRCS = \
|
|||
PTestRaceDeferral.ipdl \
|
||||
PTestRacyReentry.ipdl \
|
||||
PTestRacyRPCReplies.ipdl \
|
||||
PTestRacyUndefer.ipdl \
|
||||
PTestRPCErrorCleanup.ipdl \
|
||||
PTestRPCRaces.ipdl \
|
||||
PTestRPCShutdownRace.ipdl \
|
||||
|
|
Загрузка…
Ссылка в новой задаче