mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Test for bug 648935.
This commit is contained in:
parent
705e9bc07a
commit
eb1da4388e
@ -75,6 +75,7 @@ IPDLTESTS = \
|
||||
TestRaceDeferral \
|
||||
TestRacyReentry \
|
||||
TestRacyRPCReplies \
|
||||
TestRacyUndefer \
|
||||
TestSanity \
|
||||
TestSelfManageRoot \
|
||||
TestShmem \
|
||||
|
28
ipc/ipdl/test/cxx/PTestRacyUndefer.ipdl
Normal file
28
ipc/ipdl/test/cxx/PTestRacyUndefer.ipdl
Normal 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
|
115
ipc/ipdl/test/cxx/TestRacyUndefer.cpp
Normal file
115
ipc/ipdl/test/cxx/TestRacyUndefer.cpp
Normal 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
|
76
ipc/ipdl/test/cxx/TestRacyUndefer.h
Normal file
76
ipc/ipdl/test/cxx/TestRacyUndefer.h
Normal 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
|
@ -23,6 +23,7 @@ IPDLSRCS = \
|
||||
PTestRaceDeferral.ipdl \
|
||||
PTestRacyReentry.ipdl \
|
||||
PTestRacyRPCReplies.ipdl \
|
||||
PTestRacyUndefer.ipdl \
|
||||
PTestRPCErrorCleanup.ipdl \
|
||||
PTestRPCRaces.ipdl \
|
||||
PTestRPCShutdownRace.ipdl \
|
||||
|
Loading…
Reference in New Issue
Block a user