зеркало из https://github.com/mozilla/gecko-dev.git
Bug 549888: Test
This commit is contained in:
Родитель
36162b5b9d
Коммит
eb4b1d88db
|
@ -5,11 +5,18 @@ rpc protocol PTestRPCRaces {
|
||||||
both:
|
both:
|
||||||
rpc Race() returns (bool hasReply);
|
rpc Race() returns (bool hasReply);
|
||||||
rpc StackFrame() returns ();
|
rpc StackFrame() returns ();
|
||||||
|
rpc StackFrame3() returns ();
|
||||||
|
|
||||||
parent:
|
parent:
|
||||||
sync StartRace();
|
sync StartRace();
|
||||||
|
rpc Parent();
|
||||||
|
sync GetAnsweredParent() returns (bool answeredParent);
|
||||||
|
|
||||||
child:
|
child:
|
||||||
Start();
|
Start();
|
||||||
Wakeup();
|
Wakeup();
|
||||||
|
Wakeup3();
|
||||||
|
rpc Child();
|
||||||
__delete__();
|
__delete__();
|
||||||
|
|
||||||
state START:
|
state START:
|
||||||
|
@ -37,9 +44,26 @@ state RACE2:
|
||||||
call Race goto DUMMY2_1;
|
call Race goto DUMMY2_1;
|
||||||
answer Race goto DUMMY2_2;
|
answer Race goto DUMMY2_2;
|
||||||
state DUMMY2_1:
|
state DUMMY2_1:
|
||||||
answer Race goto DYING;
|
answer Race goto TEST3;
|
||||||
state DUMMY2_2:
|
state DUMMY2_2:
|
||||||
call Race goto DYING;
|
call Race goto TEST3;
|
||||||
|
|
||||||
|
// Third test: resolve race using custom policy
|
||||||
|
state TEST3:
|
||||||
|
call StackFrame3 goto MORESTACK3;
|
||||||
|
state MORESTACK3:
|
||||||
|
answer StackFrame3 goto STARTRACE3;
|
||||||
|
state STARTRACE3:
|
||||||
|
send Wakeup3 goto RACE3;
|
||||||
|
state RACE3:
|
||||||
|
call Child goto DUMMY3_1;
|
||||||
|
answer Parent goto DUMMY3_2;
|
||||||
|
state DUMMY3_1:
|
||||||
|
answer Parent goto CHECK;
|
||||||
|
state DUMMY3_2:
|
||||||
|
call Child goto CHECK;
|
||||||
|
state CHECK:
|
||||||
|
recv GetAnsweredParent goto DYING;
|
||||||
|
|
||||||
state DYING:
|
state DYING:
|
||||||
send __delete__;
|
send __delete__;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "IPDLUnitTests.h" // fail etc.
|
#include "IPDLUnitTests.h" // fail etc.
|
||||||
|
|
||||||
|
using mozilla::ipc::RPCChannel;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct RunnableMethodTraits<mozilla::_ipdltest::TestRPCRacesParent>
|
struct RunnableMethodTraits<mozilla::_ipdltest::TestRPCRacesParent>
|
||||||
|
@ -14,6 +15,14 @@ struct RunnableMethodTraits<mozilla::_ipdltest::TestRPCRacesParent>
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace _ipdltest {
|
namespace _ipdltest {
|
||||||
|
|
||||||
|
RPCChannel::RacyRPCPolicy
|
||||||
|
MediateRace(const RPCChannel::Message& parent,
|
||||||
|
const RPCChannel::Message& child)
|
||||||
|
{
|
||||||
|
return (PTestRPCRaces::Msg_Child__ID == parent.type()) ?
|
||||||
|
RPCChannel::RRPParentWins : RPCChannel::RRPChildWins;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// parent
|
// parent
|
||||||
void
|
void
|
||||||
|
@ -70,7 +79,9 @@ TestRPCRacesParent::Test2()
|
||||||
|
|
||||||
puts(" passed");
|
puts(" passed");
|
||||||
|
|
||||||
Close();
|
MessageLoop::current()->PostTask(
|
||||||
|
FROM_HERE,
|
||||||
|
NewRunnableMethod(this, &TestRPCRacesParent::Test3));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -89,6 +100,45 @@ TestRPCRacesParent::AnswerStackFrame()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TestRPCRacesParent::Test3()
|
||||||
|
{
|
||||||
|
puts("Test 3");
|
||||||
|
|
||||||
|
if (!CallStackFrame3())
|
||||||
|
fail("can't set up a stack frame");
|
||||||
|
|
||||||
|
puts(" passed");
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TestRPCRacesParent::AnswerStackFrame3()
|
||||||
|
{
|
||||||
|
if (!SendWakeup3())
|
||||||
|
fail("can't wake up the child");
|
||||||
|
|
||||||
|
if (!CallChild())
|
||||||
|
fail("can't set up race condition");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TestRPCRacesParent::AnswerParent()
|
||||||
|
{
|
||||||
|
mAnsweredParent = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TestRPCRacesParent::RecvGetAnsweredParent(bool* answeredParent)
|
||||||
|
{
|
||||||
|
*answeredParent = mAnsweredParent;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// child
|
// child
|
||||||
bool
|
bool
|
||||||
|
@ -144,5 +194,37 @@ TestRPCRacesChild::RecvWakeup()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TestRPCRacesChild::AnswerStackFrame3()
|
||||||
|
{
|
||||||
|
if (!CallStackFrame3())
|
||||||
|
fail("can't set up stack frame");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TestRPCRacesChild::RecvWakeup3()
|
||||||
|
{
|
||||||
|
if (!CallParent())
|
||||||
|
fail("can't set up race condition");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TestRPCRacesChild::AnswerChild()
|
||||||
|
{
|
||||||
|
bool parentAnsweredParent;
|
||||||
|
// the parent is supposed to win the race, which means its
|
||||||
|
// message, Child(), is supposed to be processed before the
|
||||||
|
// child's message, Parent()
|
||||||
|
if (!SendGetAnsweredParent(&parentAnsweredParent))
|
||||||
|
fail("sending GetAnsweredParent");
|
||||||
|
|
||||||
|
if (parentAnsweredParent)
|
||||||
|
fail("parent was supposed to win the race!");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace _ipdltest
|
} // namespace _ipdltest
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -9,12 +9,17 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace _ipdltest {
|
namespace _ipdltest {
|
||||||
|
|
||||||
|
mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||||
|
MediateRace(const mozilla::ipc::RPCChannel::Message& parent,
|
||||||
|
const mozilla::ipc::RPCChannel::Message& child);
|
||||||
|
|
||||||
class TestRPCRacesParent :
|
class TestRPCRacesParent :
|
||||||
public PTestRPCRacesParent
|
public PTestRPCRacesParent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestRPCRacesParent() : mHasReply(false), mChildHasReply(false)
|
TestRPCRacesParent() : mHasReply(false),
|
||||||
|
mChildHasReply(false),
|
||||||
|
mAnsweredParent(false)
|
||||||
{ }
|
{ }
|
||||||
virtual ~TestRPCRacesParent() { }
|
virtual ~TestRPCRacesParent() { }
|
||||||
|
|
||||||
|
@ -33,6 +38,25 @@ protected:
|
||||||
virtual bool
|
virtual bool
|
||||||
AnswerStackFrame();
|
AnswerStackFrame();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual bool
|
||||||
|
AnswerStackFrame3();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual bool
|
||||||
|
AnswerParent();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual bool
|
||||||
|
RecvGetAnsweredParent(bool* answeredParent);
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||||
|
MediateRPCRace(const Message& parent, const Message& child)
|
||||||
|
{
|
||||||
|
return MediateRace(parent, child);
|
||||||
|
}
|
||||||
|
|
||||||
NS_OVERRIDE
|
NS_OVERRIDE
|
||||||
virtual void ActorDestroy(ActorDestroyReason why)
|
virtual void ActorDestroy(ActorDestroyReason why)
|
||||||
{
|
{
|
||||||
|
@ -48,9 +72,11 @@ private:
|
||||||
void OnRaceTime();
|
void OnRaceTime();
|
||||||
|
|
||||||
void Test2();
|
void Test2();
|
||||||
|
void Test3();
|
||||||
|
|
||||||
bool mHasReply;
|
bool mHasReply;
|
||||||
bool mChildHasReply;
|
bool mChildHasReply;
|
||||||
|
bool mAnsweredParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,10 +100,29 @@ protected:
|
||||||
virtual bool
|
virtual bool
|
||||||
AnswerStackFrame();
|
AnswerStackFrame();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual bool
|
||||||
|
AnswerStackFrame3();
|
||||||
|
|
||||||
NS_OVERRIDE
|
NS_OVERRIDE
|
||||||
virtual bool
|
virtual bool
|
||||||
RecvWakeup();
|
RecvWakeup();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual bool
|
||||||
|
RecvWakeup3();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual bool
|
||||||
|
AnswerChild();
|
||||||
|
|
||||||
|
NS_OVERRIDE
|
||||||
|
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||||
|
MediateRPCRace(const Message& parent, const Message& child)
|
||||||
|
{
|
||||||
|
return MediateRace(parent, child);
|
||||||
|
}
|
||||||
|
|
||||||
NS_OVERRIDE
|
NS_OVERRIDE
|
||||||
virtual void ActorDestroy(ActorDestroyReason why)
|
virtual void ActorDestroy(ActorDestroyReason why)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче