gecko-dev/ipc/ipdl/test/cxx
2020-05-05 20:32:12 +00:00
..
app
genIPDLUnitTests.py
IPDLUnitTestProcessChild.cpp
IPDLUnitTestProcessChild.h
IPDLUnitTests.h
IPDLUnitTests.template.cpp
IPDLUnitTestSubprocess.cpp
IPDLUnitTestSubprocess.h
IPDLUnitTestTypes.h
IPDLUnitTestUtils.h
Makefile.in
moz.build
PTestActorPunning.ipdl
PTestActorPunningPunned.ipdl
PTestActorPunningSub.ipdl
PTestAsyncReturns.ipdl
PTestBadActor.ipdl
PTestBadActorSub.ipdl
PTestCancel.ipdl
PTestCrashCleanup.ipdl
PTestDataStructures.ipdl
PTestDataStructuresCommon.ipdlh
PTestDataStructuresSub.ipdl
PTestDemon.ipdl
PTestDesc.ipdl
PTestDescSub.ipdl
PTestDescSubsub.ipdl
PTestEndpointBridgeMain.ipdl
PTestEndpointBridgeMainSub.ipdl
PTestEndpointBridgeSub.ipdl
PTestEndpointOpens.ipdl
PTestEndpointOpensOpened.ipdl
PTestFailedCtor.ipdl
PTestFailedCtorSub.ipdl
PTestFailedCtorSubsub.ipdl
PTestHandle.ipdl
PTestHangs.ipdl
PTestHighestPrio.ipdl
PTestIndirectProtocolParam.ipdlh
PTestIndirectProtocolParamFirst.ipdl
PTestIndirectProtocolParamManage.ipdl
PTestIndirectProtocolParamSecond.ipdl
PTestInterruptErrorCleanup.ipdl
PTestInterruptRaces.ipdl
PTestInterruptShutdownRace.ipdl
PTestJSON.ipdl
PTestLatency.ipdl
PTestLayoutThread.ipdl
PTestManyChildAllocs.ipdl
PTestManyChildAllocsSub.ipdl
PTestMultiMgrs.ipdl
PTestMultiMgrsBottom.ipdl
PTestMultiMgrsLeft.ipdl
PTestMultiMgrsRight.ipdl
PTestNestedLoops.ipdl
PTestPaintThread.ipdl
PTestPriority.ipdl
PTestRaceDeadlock.ipdl
PTestRaceDeferral.ipdl
PTestRacyInterruptReplies.ipdl
PTestRacyReentry.ipdl
PTestRacyUndefer.ipdl
PTestRPC.ipdl
PTestSanity.ipdl
PTestSelfManage.ipdl
PTestSelfManageRoot.ipdl
PTestShmem.ipdl
PTestShutdown.ipdl
PTestShutdownSub.ipdl
PTestShutdownSubsub.ipdl
PTestStackHooks.ipdl
PTestSyncError.ipdl
PTestSyncHang.ipdl
PTestSyncWakeup.ipdl
PTestUniquePtrIPC.ipdl
PTestUrgency.ipdl
PTestUrgentHangs.ipdl
README.txt
TestActorPunning.cpp
TestActorPunning.h
TestAsyncReturns.cpp
TestAsyncReturns.h
TestBadActor.cpp
TestBadActor.h
TestCancel.cpp
TestCancel.h
TestCrashCleanup.cpp
TestCrashCleanup.h
TestDataStructures.cpp
TestDataStructures.h
TestDemon.cpp
TestDemon.h
TestDesc.cpp
TestDesc.h
TestEndpointBridgeMain.cpp
TestEndpointBridgeMain.h
TestEndpointOpens.cpp
TestEndpointOpens.h
TestFailedCtor.cpp
TestFailedCtor.h
TestHangs.cpp
TestHangs.h
TestHighestPrio.cpp
TestHighestPrio.h
TestInterruptErrorCleanup.cpp
TestInterruptErrorCleanup.h
TestInterruptRaces.cpp
TestInterruptRaces.h
TestInterruptShutdownRace.cpp
TestInterruptShutdownRace.h
TestJSON.cpp
TestJSON.h
TestLatency.cpp
TestLatency.h
TestManyChildAllocs.cpp
TestManyChildAllocs.h
TestMultiMgrs.cpp
TestMultiMgrs.h
TestNestedLoops.cpp
TestNestedLoops.h
TestOffMainThreadPainting.cpp
TestOffMainThreadPainting.h
TestRaceDeadlock.cpp
TestRaceDeadlock.h
TestRaceDeferral.cpp
TestRaceDeferral.h
TestRacyInterruptReplies.cpp
TestRacyInterruptReplies.h
TestRacyReentry.cpp
TestRacyReentry.h
TestRacyUndefer.cpp
TestRacyUndefer.h
TestRPC.cpp
TestRPC.h
TestSanity.cpp
TestSanity.h
TestSelfManageRoot.cpp
TestSelfManageRoot.h
TestShmem.cpp
TestShmem.h
TestShutdown.cpp
TestShutdown.h
TestStackHooks.cpp
TestStackHooks.h
TestSyncError.cpp
TestSyncError.h
TestSyncHang.cpp
TestSyncHang.h
TestSyncWakeup.cpp
TestSyncWakeup.h
TestUniquePtrIPC.cpp
TestUniquePtrIPC.h
TestUrgency.cpp
TestUrgency.h
TestUrgentHangs.cpp
TestUrgentHangs.h

To add a new IPDL C++ unit test, you need to create (at least) the
following files (for a test "TestFoo"):

  - PTestFoo.ipdl, specifying the top-level protocol used for the test

  - TestFoo.h, declaring the top-level parent/child actors used for
    the test

  - TestFoo.cpp, defining the top-level actors

  - (make sure all are in the namespace mozilla::_ipdltest)

Next

  - add PTestFoo.ipdl to ipdl.mk

  - append TestFoo to the variable IPDLTESTS in Makefile.in

You must define three methods in your |TestFooParent| class:

  - static methods |bool RunTestInProcesses()| and
    |bool RunTestInThreads()|.  These methods control whether
    to execute the test using actors in separate processes and
    threads respectively.  Generally, both should return true.

  - an instance method |void Main()|.  The test harness wil first
    initialize the processes or threads, create and open both actors,
    and then kick off the test using |Main()|.  Make sure you define
    it.

If your test passes its criteria, please call
|MOZ_IPDL_TESTPASS("msg")| and "exit gracefully".

If your tests fails, please call |MOZ_IPDL_TESTFAIL("msg")| and "exit
ungracefully", preferably by abort()ing.


If all goes well, running

  make -C $OBJDIR/ipc/ipdl/test/cxx

will update the file IPDLUnitTests.cpp (the test launcher), and your
new code will be built automatically.


You can launch your new test by invoking one of

  make -C $OBJDIR/ipc/ipdl/test/cxx check-proc     (test process-based tests)
  make -C $OBJDIR/ipc/ipdl/test/cxx check-threads  (test thread-based tests)
  make -C $OBJDIR/ipc/ipdl/test/cxx check          (tests both)

If you want to launch only your test, run

  cd $OBJDIR/dist/bin
  ./run-mozilla.sh ./ipdlunittest TestFoo          (test in two processes, if appl.)
  ./run-mozilla.sh ./ipdlunittest thread:TestFoo   (test in two threads, if appl.)


For a bare-bones example of adding a test, take a look at
PTestSanity.ipdl, TestSanity.h, TestSanity.cpp, and how "TestSanity"
is included in ipdl.mk and Makefile.in.