Bug 1149971 Part 1: Follow-up to bug 1119878 to fix broken IPDL tests. r=dvander

This commit is contained in:
Bob Owen 2015-04-01 16:44:48 +01:00
parent a79ecf0091
commit c7dfe28a4a
8 changed files with 26 additions and 40 deletions

View File

@ -19,7 +19,7 @@ bool
IPDLUnitTestProcessChild::Init() IPDLUnitTestProcessChild::Init()
{ {
IPDLUnitTestChildInit(IOThreadChild::channel(), IPDLUnitTestChildInit(IOThreadChild::channel(),
ParentId(), ParentPid(),
IOThreadChild::message_loop()); IOThreadChild::message_loop());
if (NS_FAILED(nsRegion::InitStatic())) if (NS_FAILED(nsRegion::InitStatic()))

View File

@ -181,7 +181,7 @@ ${PARENT_ENABLED_CASES_PROC}
if (!transport) if (!transport)
fail("no transport"); fail("no transport");
base::ProcessHandle child = gSubprocess->GetChildProcessHandle(); base::ProcessId child = base::GetProcId(gSubprocess->GetChildProcessHandle());
switch (test) { switch (test) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -27,15 +27,10 @@ TestBridgeMainParent::Main()
PTestBridgeMainSubParent* PTestBridgeMainSubParent*
TestBridgeMainParent::AllocPTestBridgeMainSubParent(Transport* transport, TestBridgeMainParent::AllocPTestBridgeMainSubParent(Transport* transport,
ProcessId otherProcess) ProcessId otherPid)
{ {
ProcessHandle h;
if (!base::OpenProcessHandle(otherProcess, &h)) {
return nullptr;
}
nsAutoPtr<TestBridgeMainSubParent> a(new TestBridgeMainSubParent(transport)); nsAutoPtr<TestBridgeMainSubParent> a(new TestBridgeMainSubParent(transport));
if (!a->Open(transport, h, XRE_GetIOMessageLoop(), ipc::ParentSide)) { if (!a->Open(transport, otherPid, XRE_GetIOMessageLoop(), ipc::ParentSide)) {
return nullptr; return nullptr;
} }
return a.forget(); return a.forget();
@ -110,7 +105,7 @@ TestBridgeMainChild::RecvStart()
fail("no transport"); fail("no transport");
TestBridgeSubParent* bsp = new TestBridgeSubParent(); TestBridgeSubParent* bsp = new TestBridgeSubParent();
bsp->Open(transport, mSubprocess->GetChildProcessHandle()); bsp->Open(transport, base::GetProcId(mSubprocess->GetChildProcessHandle()));
bsp->Main(); bsp->Main();
return true; return true;
@ -178,15 +173,10 @@ TestBridgeSubChild::RecvPing()
PTestBridgeMainSubChild* PTestBridgeMainSubChild*
TestBridgeSubChild::AllocPTestBridgeMainSubChild(Transport* transport, TestBridgeSubChild::AllocPTestBridgeMainSubChild(Transport* transport,
ProcessId otherProcess) ProcessId otherPid)
{ {
ProcessHandle h;
if (!base::OpenProcessHandle(otherProcess, &h)) {
return nullptr;
}
nsAutoPtr<TestBridgeMainSubChild> a(new TestBridgeMainSubChild(transport)); nsAutoPtr<TestBridgeMainSubChild> a(new TestBridgeMainSubChild(transport));
if (!a->Open(transport, h, XRE_GetIOMessageLoop(), ipc::ChildSide)) { if (!a->Open(transport, otherPid, XRE_GetIOMessageLoop(), ipc::ChildSide)) {
return nullptr; return nullptr;
} }

View File

@ -494,7 +494,7 @@ TestDataStructuresChild::RecvStart()
Test15(); Test15();
Test16(); Test16();
Test17(); Test17();
if (OtherProcess() != 0) { if (OtherPid() != ipc::kCurrentProcessId) {
//FIXME/bug 703317 allocation of nsIntRegion uses a global //FIXME/bug 703317 allocation of nsIntRegion uses a global
//region pool which breaks threads //region pool which breaks threads
Test18(); Test18();

View File

@ -110,7 +110,7 @@ TestFailedCtorChild::DeallocPTestFailedCtorSubChild(PTestFailedCtorSubChild* act
void void
TestFailedCtorChild::ProcessingError(Result aCode, const char* aReason) TestFailedCtorChild::ProcessingError(Result aCode, const char* aReason)
{ {
if (OtherProcess() != 0) // thread-mode if (OtherPid() != ipc::kCurrentProcessId) // thread-mode
_exit(0); _exit(0);
} }

View File

@ -111,8 +111,14 @@ TestHangsParent::AnswerStackFrame()
void void
TestHangsParent::CleanUp() TestHangsParent::CleanUp()
{ {
if (!KillProcess(OtherProcess(), 0, false)) ipc::ScopedProcessHandle otherProcessHandle;
fail("terminating child process"); if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle.rwget())) {
fail("couldn't open child process");
} else {
if (!KillProcess(otherProcessHandle, 0, false)) {
fail("terminating child process");
}
}
Close(); Close();
} }

View File

@ -54,29 +54,24 @@ TestOpensParent::Main()
static void static void
OpenParent(TestOpensOpenedParent* aParent, OpenParent(TestOpensOpenedParent* aParent,
Transport* aTransport, ProcessHandle aOtherProcess) Transport* aTransport, base::ProcessId aOtherPid)
{ {
AssertNotMainThread(); AssertNotMainThread();
// Open the actor on the off-main thread to park it there. // Open the actor on the off-main thread to park it there.
// Messages will be delivered to this thread's message loop // Messages will be delivered to this thread's message loop
// instead of the main thread's. // instead of the main thread's.
if (!aParent->Open(aTransport, aOtherProcess, if (!aParent->Open(aTransport, aOtherPid,
XRE_GetIOMessageLoop(), ipc::ParentSide)) XRE_GetIOMessageLoop(), ipc::ParentSide))
fail("opening Parent"); fail("opening Parent");
} }
PTestOpensOpenedParent* PTestOpensOpenedParent*
TestOpensParent::AllocPTestOpensOpenedParent(Transport* transport, TestOpensParent::AllocPTestOpensOpenedParent(Transport* transport,
ProcessId otherProcess) ProcessId otherPid)
{ {
gMainThread = MessageLoop::current(); gMainThread = MessageLoop::current();
ProcessHandle h;
if (!base::OpenProcessHandle(otherProcess, &h)) {
return nullptr;
}
gParentThread = new Thread("ParentThread"); gParentThread = new Thread("ParentThread");
if (!gParentThread->Start()) if (!gParentThread->Start())
fail("starting parent thread"); fail("starting parent thread");
@ -84,7 +79,7 @@ TestOpensParent::AllocPTestOpensOpenedParent(Transport* transport,
TestOpensOpenedParent* a = new TestOpensOpenedParent(transport); TestOpensOpenedParent* a = new TestOpensOpenedParent(transport);
gParentThread->message_loop()->PostTask( gParentThread->message_loop()->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableFunction(OpenParent, a, transport, h)); NewRunnableFunction(OpenParent, a, transport, otherPid));
return a; return a;
} }
@ -174,14 +169,14 @@ TestOpensChild::RecvStart()
static void static void
OpenChild(TestOpensOpenedChild* aChild, OpenChild(TestOpensOpenedChild* aChild,
Transport* aTransport, ProcessHandle aOtherProcess) Transport* aTransport, base::ProcessId aOtherPid)
{ {
AssertNotMainThread(); AssertNotMainThread();
// Open the actor on the off-main thread to park it there. // Open the actor on the off-main thread to park it there.
// Messages will be delivered to this thread's message loop // Messages will be delivered to this thread's message loop
// instead of the main thread's. // instead of the main thread's.
if (!aChild->Open(aTransport, aOtherProcess, if (!aChild->Open(aTransport, aOtherPid,
XRE_GetIOMessageLoop(), ipc::ChildSide)) XRE_GetIOMessageLoop(), ipc::ChildSide))
fail("opening Child"); fail("opening Child");
@ -192,15 +187,10 @@ OpenChild(TestOpensOpenedChild* aChild,
PTestOpensOpenedChild* PTestOpensOpenedChild*
TestOpensChild::AllocPTestOpensOpenedChild(Transport* transport, TestOpensChild::AllocPTestOpensOpenedChild(Transport* transport,
ProcessId otherProcess) ProcessId otherPid)
{ {
gMainThread = MessageLoop::current(); gMainThread = MessageLoop::current();
ProcessHandle h;
if (!base::OpenProcessHandle(otherProcess, &h)) {
return nullptr;
}
gChildThread = new Thread("ChildThread"); gChildThread = new Thread("ChildThread");
if (!gChildThread->Start()) if (!gChildThread->Start())
fail("starting child thread"); fail("starting child thread");
@ -208,7 +198,7 @@ TestOpensChild::AllocPTestOpensOpenedChild(Transport* transport,
TestOpensOpenedChild* a = new TestOpensOpenedChild(transport); TestOpensOpenedChild* a = new TestOpensOpenedChild(transport);
gChildThread->message_loop()->PostTask( gChildThread->message_loop()->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableFunction(OpenChild, a, transport, h)); NewRunnableFunction(OpenChild, a, transport, otherPid));
return a; return a;
} }

View File

@ -116,7 +116,7 @@ def main(argv):
%sChild** child = %sChild** child =
reinterpret_cast<%sChild**>(&gChildActor); reinterpret_cast<%sChild**>(&gChildActor);
*child = new %sChild(); *child = new %sChild();
(*child)->Open(transport, parent, worker); (*child)->Open(transport, parentPid, worker);
return; return;
} }
'''% (t, t, t, t) for t in unittests+extras ]) '''% (t, t, t, t) for t in unittests+extras ])