Bug 1493649: Fix IPDL test compilation (r=jld)
authorDavid Parks <dparks@mozilla.com>
Tue, 02 Oct 2018 22:32:17 +0000
changeset 495198 d7057bcc6e824a5cbdc5053c419874a9700af8ef
parent 495197 20c446dff6ab8389bea9e474644951910fcc9909
child 495199 275985ae0d13f0e9f7062e58b74a2953ff4738bd
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1493649
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1493649: Fix IPDL test compilation (r=jld) This patch allows IPDL tests to compile -- in other words, it fixes the build when the --enable-ipdl-tests flag is present. Most of the fixes are simple API updates but we also needed to fix an issue with the constness of nsTArray<Shmem> parameters that are defined in IPDL structs. This patch does not fix the tests themselves -- some IPDL tests will still fail when run. Differential Revision: https://phabricator.services.mozilla.com/D6705
ipc/ipdl/ipdl/lower.py
ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp
ipc/ipdl/test/cxx/TestCrashCleanup.cpp
ipc/ipdl/test/cxx/TestEndpointOpens.cpp
ipc/ipdl/test/cxx/TestInterruptErrorCleanup.cpp
ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp
ipc/ipdl/test/cxx/TestStackHooks.cpp
ipc/ipdl/test/cxx/TestSyncHang.cpp
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -589,17 +589,18 @@ def _cxxConstRefType(ipdltype, side):
     if ipdltype.isIPDL() and ipdltype.isShmem():
         t.ref = 1
         return t
     if ipdltype.isIPDL() and ipdltype.isByteBuf():
         t.ref = 1
         return t
     if ipdltype.isIPDL() and ipdltype.isArray():
         # Keep same constness as inner type.
-        t.const = _cxxConstRefType(ipdltype.basetype, side).const
+        inner = _cxxConstRefType(ipdltype.basetype, side)
+        t.const = inner.const or not inner.ref
         t.ref = 1
         return t
     if ipdltype.isCxx() and ipdltype.isRefcounted():
         # Use T* instead of const RefPtr<T>&
         t = t.T
         t.ptr = 1
         return t
     t.const = 1
--- a/ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp
+++ b/ipc/ipdl/test/cxx/IPDLUnitTests.template.cpp
@@ -254,25 +254,26 @@ QuitXPCOM()
   appShell->Exit();
 }
 
 void
 DeleteSubprocess(MessageLoop* uiLoop)
 {
   // pong to QuitXPCOM
   delete gSubprocess;
-  uiLoop->PostTask(NewRunnableFunction(QuitXPCOM));
+  uiLoop->PostTask(NewRunnableFunction("QuitXPCOM", QuitXPCOM));
 }
 
 void
 DeferredParentShutdown()
 {
     // ping to DeleteSubprocess
     XRE_GetIOMessageLoop()->PostTask(
-        NewRunnableFunction(DeleteSubprocess, MessageLoop::current()));
+        NewRunnableFunction("DeleteSubprocess", DeleteSubprocess,
+                            MessageLoop::current()));
 }
 
 void
 TryThreadedShutdown()
 {
     // Stop if either:
     // - the child has not finished,
     // - the parent has not finished,
@@ -296,41 +297,41 @@ ChildCompleted()
 }
 
 void
 QuitParent()
 {
     if (gChildThread) {
         gParentDone = true;
         MessageLoop::current()->PostTask(
-            NewRunnableFunction(TryThreadedShutdown));
+            NewRunnableFunction("TryThreadedShutdown", TryThreadedShutdown));
     } else {
         // defer "real" shutdown to avoid *Channel::Close() racing with the
         // deletion of the subprocess
         MessageLoop::current()->PostTask(
-            NewRunnableFunction(DeferredParentShutdown));
+            NewRunnableFunction("DeferredParentShutdown", DeferredParentShutdown));
     }
 }
 
 static void
 ChildDie()
 {
     DeleteChildActor();
     XRE_ShutdownChildProcess();
 }
 
 void
 QuitChild()
 {
     if (gChildThread) { // Threaded-mode test
         gParentMessageLoop->PostTask(
-            NewRunnableFunction(ChildCompleted));
+            NewRunnableFunction("ChildCompleted", ChildCompleted));
     } else { // Process-mode test
         MessageLoop::current()->PostTask(
-            NewRunnableFunction(ChildDie));
+            NewRunnableFunction("ChildDie", ChildDie));
     }
 }
 
 } // namespace _ipdltest
 } // namespace mozilla
 
 
 //-----------------------------------------------------------------------------
--- a/ipc/ipdl/test/cxx/TestCrashCleanup.cpp
+++ b/ipc/ipdl/test/cxx/TestCrashCleanup.cpp
@@ -40,17 +40,17 @@ void DeleteTheWorld()
     // needs to be synchronous to avoid affecting event ordering on
     // the main thread
     Mutex mutex("TestCrashCleanup.DeleteTheWorld.mutex");
     CondVar cvar(mutex, "TestCrashCleanup.DeleteTheWorld.cvar");
 
     MutexAutoLock lock(mutex);
 
     XRE_GetIOMessageLoop()->PostTask(
-      NewRunnableFunction(DeleteSubprocess, &mutex, &cvar));
+      NewRunnableFunction("DeleteSubprocess", DeleteSubprocess, &mutex, &cvar));
 
     cvar.Wait();
 }
 
 void Done()
 {
   static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
   nsCOMPtr<nsIAppShell> appShell (do_GetService(kAppShellCID));
@@ -74,24 +74,24 @@ TestCrashCleanupParent::~TestCrashCleanu
         fail("should have been ActorDestroy()d!");
 }
 
 void
 TestCrashCleanupParent::Main()
 {
     // NB: has to be enqueued before IO thread's error notification
     MessageLoop::current()->PostTask(
-        NewRunnableFunction(DeleteTheWorld));
+        NewRunnableFunction("DeleteTheWorld", DeleteTheWorld));
 
     if (CallDIEDIEDIE())
         fail("expected an error!");
 
     Close();
 
-    MessageLoop::current()->PostTask(NewRunnableFunction(Done));
+    MessageLoop::current()->PostTask(NewRunnableFunction("Done", Done));
 }
 
 
 //-----------------------------------------------------------------------------
 // child
 
 TestCrashCleanupChild::TestCrashCleanupChild()
 {
--- a/ipc/ipdl/test/cxx/TestEndpointOpens.cpp
+++ b/ipc/ipdl/test/cxx/TestEndpointOpens.cpp
@@ -67,17 +67,17 @@ TestEndpointOpensParent::RecvStartSubpro
 
   gParentThread = new Thread("ParentThread");
   if (!gParentThread->Start()) {
     fail("starting parent thread");
   }
 
   TestEndpointOpensOpenedParent* a = new TestEndpointOpensOpenedParent();
   gParentThread->message_loop()->PostTask(
-    NewRunnableFunction(OpenParent, a, std::move(endpoint)));
+    NewRunnableFunction("OpenParent", OpenParent, a, std::move(endpoint)));
 
   return IPC_OK();
 }
 
 void
 TestEndpointOpensParent::ActorDestroy(ActorDestroyReason why)
 {
   // Stops the thread and joins it
@@ -132,17 +132,18 @@ TestEndpointOpensOpenedParent::ActorDest
   if (NormalShutdown != why) {
     fail("unexpected destruction B!");
   }
 
   // ActorDestroy() is just a callback from IPDL-generated code,
   // which needs the top-level actor (this) to stay alive a little
   // longer so other things can be cleaned up.
   gParentThread->message_loop()->PostTask(
-    NewRunnableFunction(ShutdownTestEndpointOpensOpenedParent,
+    NewRunnableFunction("ShutdownTestEndpointOpensOpenedParent",
+                        ShutdownTestEndpointOpensOpenedParent,
                         this, GetTransport()));
 }
 
 //-----------------------------------------------------------------------------
 // child
 
 static TestEndpointOpensChild* gOpensChild;
 // Thread on which TestEndpointOpensOpenedChild runs
@@ -188,17 +189,17 @@ TestEndpointOpensChild::RecvStart()
 
   gChildThread = new Thread("ChildThread");
   if (!gChildThread->Start()) {
     fail("starting child thread");
   }
 
   TestEndpointOpensOpenedChild* a = new TestEndpointOpensOpenedChild();
   gChildThread->message_loop()->PostTask(
-    NewRunnableFunction(OpenChild, a, std::move(child)));
+    NewRunnableFunction("OpenChild", OpenChild, a, std::move(child)));
 
   if (!SendStartSubprotocol(parent)) {
     fail("send StartSubprotocol");
   }
 
   return IPC_OK();
 }
 
@@ -269,13 +270,14 @@ TestEndpointOpensOpenedChild::ActorDestr
     fail("unexpected destruction D!");
   }
 
   // ActorDestroy() is just a callback from IPDL-generated code,
   // which needs the top-level actor (this) to stay alive a little
   // longer so other things can be cleaned up.  Defer shutdown to
   // let cleanup finish.
   gChildThread->message_loop()->PostTask(
-    NewRunnableFunction(ShutdownTestEndpointOpensOpenedChild,
+    NewRunnableFunction("ShutdownTestEndpointOpensOpenedChild",
+                        ShutdownTestEndpointOpensOpenedChild,
                         this, GetTransport()));
 }
 
 } // namespace mozilla
--- a/ipc/ipdl/test/cxx/TestInterruptErrorCleanup.cpp
+++ b/ipc/ipdl/test/cxx/TestInterruptErrorCleanup.cpp
@@ -40,17 +40,17 @@ void DeleteTheWorld()
     // needs to be synchronous to avoid affecting event ordering on
     // the main thread
     Mutex mutex("TestInterruptErrorCleanup.DeleteTheWorld.mutex");
     CondVar cvar(mutex, "TestInterruptErrorCleanup.DeleteTheWorld.cvar");
 
     MutexAutoLock lock(mutex);
 
     XRE_GetIOMessageLoop()->PostTask(
-      NewRunnableFunction(DeleteSubprocess, &mutex, &cvar));
+      NewRunnableFunction("DeleteSubprocess", DeleteSubprocess, &mutex, &cvar));
 
     cvar.Wait();
 }
 
 void Done()
 {
   static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
   nsCOMPtr<nsIAppShell> appShell (do_GetService(kAppShellCID));
@@ -96,34 +96,34 @@ TestInterruptErrorCleanupParent::Main()
     //  - use-after-free of parentActor
     //  - use-after-free of channel
     //
     // Because of legacy constraints related to nsNPAPI* code, we need
     // to ensure that this sequence of events can occur without
     // errors/crashes.
 
     MessageLoop::current()->PostTask(
-        NewRunnableFunction(DeleteTheWorld));
+        NewRunnableFunction("DeleteTheWorld", DeleteTheWorld));
 
     // it's a failure if this *succeeds*
     if (CallError())
         fail("expected an error!");
 
     if (!mGotProcessingError)
         fail("expected a ProcessingError() notification");
 
     // it's OK to Close() a channel after an error, because nsNPAPI*
     // wants to do this
     Close();
 
     // we know that this event *must* be after the MaybeError
     // notification enqueued by AsyncChannel, because that event is
     // enqueued within the same mutex that ends up signaling the
     // wakeup-on-error of |CallError()| above
-    MessageLoop::current()->PostTask(NewRunnableFunction(Done));
+    MessageLoop::current()->PostTask(NewRunnableFunction("Done", Done));
 }
 
 void
 TestInterruptErrorCleanupParent::ProcessingError(Result aCode, const char* aReason)
 {
     if (aCode != MsgDropped)
         fail("unexpected processing error");
     mGotProcessingError = true;
--- a/ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp
+++ b/ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp
@@ -70,20 +70,21 @@ TestInterruptShutdownRaceParent::StartSh
     if (CallExit())
         fail("connection was supposed to be interrupted");
 
     Close();
 
     delete static_cast<TestInterruptShutdownRaceParent*>(gParentActor);
     gParentActor = nullptr;
 
-    XRE_GetIOMessageLoop()->PostTask(NewRunnableFunction(DeleteSubprocess));
+    XRE_GetIOMessageLoop()->PostTask(NewRunnableFunction("DeleteSubprocess",
+                                                         DeleteSubprocess));
 
     // this is ordered after the OnMaybeDequeueOne event in the queue
-    MessageLoop::current()->PostTask(NewRunnableFunction(Done));
+    MessageLoop::current()->PostTask(NewRunnableFunction("Done", Done));
 
     // |this| has been deleted, be mindful
 }
 
 mozilla::ipc::IPCResult
 TestInterruptShutdownRaceParent::RecvOrphan()
 {
     // it would be nice to fail() here, but we'll process this message
--- a/ipc/ipdl/test/cxx/TestStackHooks.cpp
+++ b/ipc/ipdl/test/cxx/TestStackHooks.cpp
@@ -78,17 +78,18 @@ TestStackHooksChild::RecvStart()
     if (!mOnStack)
         fail("missed stack notification");
 
     if (0 != mIncallDepth)
         fail("EnteredCall/ExitedCall malfunction");
 
     // kick off tests from a runnable so that we can start with
     // MessageChannel code on the C++ stack
-    MessageLoop::current()->PostTask(NewRunnableFunction(RunTestsFn));
+    MessageLoop::current()->PostTask(NewRunnableFunction("RunTestsFn",
+                                                         RunTestsFn));
 
     return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TestStackHooksChild::AnswerStackFrame()
 {
     ++mNumAnswerStackFrame;
--- a/ipc/ipdl/test/cxx/TestSyncHang.cpp
+++ b/ipc/ipdl/test/cxx/TestSyncHang.cpp
@@ -31,30 +31,32 @@ DeleteSyncHangSubprocess(MessageLoop* ui
   delete gSyncHangSubprocess;
 }
 
 void
 DeferredSyncHangParentShutdown()
 {
   // ping to DeleteSubprocess
   XRE_GetIOMessageLoop()->PostTask(
-      NewRunnableFunction(DeleteSyncHangSubprocess, MessageLoop::current()));
+      NewRunnableFunction("DeleteSyncHangSubprocess", DeleteSyncHangSubprocess,
+                          MessageLoop::current()));
 }
 
 void
 TestSyncHangParent::Main()
 {
   vector<string> args;
   args.push_back("fake/path");
   gSyncHangSubprocess = new mozilla::ipc::GeckoChildProcessHost(GeckoProcessType_Plugin);
   bool launched = gSyncHangSubprocess->SyncLaunch(args, 2);
   if (launched)
     fail("Calling SyncLaunch with an invalid path should return false");
 
-  MessageLoop::current()->PostTask(NewRunnableFunction(DeferredSyncHangParentShutdown));
+  MessageLoop::current()->PostTask(NewRunnableFunction("DeferredSyncHangParentShutdown",
+                                                       DeferredSyncHangParentShutdown));
   Close();
 }
 
 //-----------------------------------------------------------------------------
 // child
 
 TestSyncHangChild::TestSyncHangChild()
 {