Bug 1142109 - Fix IPDL tests (r=dvander)

This commit is contained in:
Bill McCloskey 2015-03-11 20:32:29 -07:00
parent ac7930ade5
commit b7d08e1e69
4 changed files with 35 additions and 52 deletions

View File

@ -7,9 +7,7 @@ parent:
prio(high) sync Test1_Start() returns (uint32_t result);
prio(high) sync Test1_InnerEvent() returns (uint32_t result);
async Test2_Start();
prio(high) sync Test2_Msg2();
prio(high) sync Test2_FirstUrgent();
prio(high) sync Test2_SecondUrgent();
prio(high) sync Test2_OutOfOrder();
sync Test3_Start() returns (uint32_t result);
prio(high) sync Test3_InnerEvent() returns (uint32_t result);
@ -17,8 +15,8 @@ child:
async Start();
prio(high) sync Test1_InnerQuery() returns (uint32_t result);
prio(high) sync Test1_NoReenter() returns (uint32_t result);
prio(high) sync Test2_Msg1();
prio(high) sync Test2_Msg3();
prio(high) sync Test2_FirstUrgent();
prio(high) sync Test2_SecondUrgent();
prio(high) sync Test3_WakeUp() returns (uint32_t result);
};

View File

@ -84,6 +84,8 @@ TestHangsParent::ShouldContinueFromReplyTimeout()
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableMethod(this, &TestHangsParent::CleanUp));
GetIPCChannel()->CloseWithTimeout();
return false;
}

View File

@ -14,6 +14,8 @@ namespace _ipdltest {
// parent
TestRPCParent::TestRPCParent()
: reentered_(false),
resolved_first_cpow_(false)
{
MOZ_COUNT_CTOR(TestRPCParent);
}
@ -59,30 +61,25 @@ TestRPCParent::RecvTest1_InnerEvent(uint32_t* aResult)
bool
TestRPCParent::RecvTest2_Start()
{
if (!SendTest2_Msg1())
fail("SendTest2_Msg1");
// Send a CPOW. During this time, we must NOT process the RPC message, as
// we could start receiving CPOW replies out-of-order.
if (!SendTest2_FirstUrgent())
fail("SendTest2_FirstUrgent");
MOZ_ASSERT(!reentered_);
resolved_first_cpow_ = true;
return true;
}
bool
TestRPCParent::RecvTest2_Msg2()
TestRPCParent::RecvTest2_OutOfOrder()
{
if (!SendTest2_Msg3())
fail("SendTest2_Msg3");
// Send a CPOW. If this RPC call was initiated while waiting for the first
// CPOW to resolve, replies will be processed out of order, and we'll crash.
if (!SendTest2_SecondUrgent())
fail("SendTest2_SecondUrgent");
return true;
}
bool
TestRPCParent::RecvTest2_FirstUrgent()
{
return true;
}
bool
TestRPCParent::RecvTest2_SecondUrgent()
{
reentered_ = true;
return true;
}
@ -107,8 +104,6 @@ TestRPCParent::RecvTest3_InnerEvent(uint32_t* aResult)
TestRPCChild::TestRPCChild()
: reentered_(false),
resolved_first_cpow_(false)
{
MOZ_COUNT_CTOR(TestRPCChild);
}
@ -130,8 +125,8 @@ TestRPCChild::RecvStart()
if (!SendTest2_Start())
fail("SendTest2_Start");
if (!SendTest2_Msg2())
fail("SendTest2_Msg2");
if (!SendTest2_OutOfOrder())
fail("SendTest2_OutOfOrder");
result = 0;
if (!SendTest3_Start(&result))
@ -163,29 +158,15 @@ TestRPCChild::RecvTest1_NoReenter(uint32_t* aResult)
return true;
}
bool TestRPCChild::RecvTest2_Msg1()
bool
TestRPCChild::RecvTest2_FirstUrgent()
{
MOZ_ASSERT(resolved_first_cpow_);
// Send a CPOW. If this RPC call was initiated while waiting for the first
// CPOW to resolve, replies will be processed out of order, and we'll crash.
if (!SendTest2_SecondUrgent())
fail("SendTest2_SecondUrgent");
reentered_ = true;
return true;
}
bool
TestRPCChild::RecvTest2_Msg3()
TestRPCChild::RecvTest2_SecondUrgent()
{
// Send a CPOW. During this time, we must NOT process the RPC message, as
// we could start receiving CPOW replies out-of-order.
if (!SendTest2_FirstUrgent())
fail("SendTest2_FirstUrgent");
MOZ_ASSERT(!reentered_);
resolved_first_cpow_ = true;
return true;
}

View File

@ -25,9 +25,7 @@ public:
bool RecvTest1_Start(uint32_t* aResult) MOZ_OVERRIDE;
bool RecvTest1_InnerEvent(uint32_t* aResult) MOZ_OVERRIDE;
bool RecvTest2_Start() MOZ_OVERRIDE;
bool RecvTest2_Msg2() MOZ_OVERRIDE;
bool RecvTest2_FirstUrgent() MOZ_OVERRIDE;
bool RecvTest2_SecondUrgent() MOZ_OVERRIDE;
bool RecvTest2_OutOfOrder() MOZ_OVERRIDE;
bool RecvTest3_Start(uint32_t* aResult) MOZ_OVERRIDE;
bool RecvTest3_InnerEvent(uint32_t* aResult) MOZ_OVERRIDE;
@ -35,9 +33,17 @@ public:
{
if (NormalShutdown != why)
fail("unexpected destruction!");
if (!reentered_)
fail("never processed raced RPC call!");
if (!resolved_first_cpow_)
fail("never resolved first CPOW!");
passed("ok");
QuitParent();
}
private:
bool reentered_;
bool resolved_first_cpow_;
};
@ -51,8 +57,8 @@ public:
bool RecvStart() MOZ_OVERRIDE;
bool RecvTest1_InnerQuery(uint32_t* aResult) MOZ_OVERRIDE;
bool RecvTest1_NoReenter(uint32_t* aResult) MOZ_OVERRIDE;
bool RecvTest2_Msg1() MOZ_OVERRIDE;
bool RecvTest2_Msg3() MOZ_OVERRIDE;
bool RecvTest2_FirstUrgent() MOZ_OVERRIDE;
bool RecvTest2_SecondUrgent() MOZ_OVERRIDE;
bool RecvTest3_WakeUp(uint32_t* aResult) MOZ_OVERRIDE;
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
@ -61,10 +67,6 @@ public:
fail("unexpected destruction!");
QuitChild();
}
private:
bool reentered_;
bool resolved_first_cpow_;
};