gecko-dev/ipc/ipdl/test/cxx
Gabriele Svelto 69790bc62e Bug 1600545 - Remove useless inclusions of header files generated from IDL files in accessible/, browser/, caps/, chrome/, devtools/, docshell/, editor/, extensions/, gfx/, hal/, image/, intl/, ipc/, js/, layout/, and media/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.

find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
    interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
    if [ -n "$interfaces" ]; then
        if [[ "$interfaces" == *$'\n'* ]]; then
          regexp="\("
          for i in $interfaces; do regexp="$regexp$i\|"; done
          regexp="${regexp%%\\\|}\)"
        else
          regexp="$interfaces"
        fi
        interface=$(basename "$path")
        rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
            hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
            if [ $hits -eq 0 ]; then
                echo "Removing ${interface} from ${path2}"
                grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
                mv -f "$path2".tmp "$path2"
            fi
        done
    fi
done

Differential Revision: https://phabricator.services.mozilla.com/D55443

--HG--
extra : moz-landing-system : lando
2019-12-06 09:16:44 +00:00
..
app
genIPDLUnitTests.py
IPDLUnitTestProcessChild.cpp
IPDLUnitTestProcessChild.h
IPDLUnitTests.h Bug 1600545 - Remove useless inclusions of header files generated from IDL files in accessible/, browser/, caps/, chrome/, devtools/, docshell/, editor/, extensions/, gfx/, hal/, image/, intl/, ipc/, js/, layout/, and media/ r=Ehsan 2019-12-06 09:16:44 +00:00
IPDLUnitTests.template.cpp
IPDLUnitTestSubprocess.cpp
IPDLUnitTestSubprocess.h
IPDLUnitTestTypes.h
IPDLUnitTestUtils.h Bug 1513911 - Part 2 - fixed a missing include; r=mccr8 2019-02-27 20:00:58 +00:00
Makefile.in
moz.build
PTestActorPunning.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestActorPunningPunned.ipdl
PTestActorPunningSub.ipdl
PTestAsyncReturns.ipdl
PTestBadActor.ipdl
PTestBadActorSub.ipdl
PTestCancel.ipdl
PTestCrashCleanup.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestDataStructures.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestDataStructuresCommon.ipdlh
PTestDataStructuresSub.ipdl
PTestDemon.ipdl
PTestDesc.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestDescSub.ipdl
PTestDescSubsub.ipdl
PTestEndpointBridgeMain.ipdl
PTestEndpointBridgeMainSub.ipdl
PTestEndpointBridgeSub.ipdl
PTestEndpointOpens.ipdl
PTestEndpointOpensOpened.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestFailedCtor.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestFailedCtorSub.ipdl
PTestFailedCtorSubsub.ipdl
PTestHandle.ipdl
PTestHangs.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestHighestPrio.ipdl
PTestIndirectProtocolParam.ipdlh
PTestIndirectProtocolParamFirst.ipdl
PTestIndirectProtocolParamManage.ipdl
PTestIndirectProtocolParamSecond.ipdl
PTestInterruptErrorCleanup.ipdl
PTestInterruptRaces.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestInterruptShutdownRace.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestJSON.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestLatency.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestLayoutThread.ipdl
PTestManyChildAllocs.ipdl
PTestManyChildAllocsSub.ipdl
PTestMultiMgrs.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestMultiMgrsBottom.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestMultiMgrsLeft.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestMultiMgrsRight.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestNestedLoops.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestPaintThread.ipdl
PTestPriority.ipdl
PTestRaceDeadlock.ipdl
PTestRaceDeferral.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestRacyInterruptReplies.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestRacyReentry.ipdl
PTestRacyUndefer.ipdl
PTestRPC.ipdl
PTestSanity.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestSelfManage.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestSelfManageRoot.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestShmem.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestShutdown.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestShutdownSub.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestShutdownSubsub.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestStackHooks.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestSyncError.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestSyncHang.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestSyncWakeup.ipdl Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
PTestUniquePtrIPC.ipdl
PTestUrgency.ipdl
PTestUrgentHangs.ipdl
README.txt
TestActorPunning.cpp
TestActorPunning.h
TestAsyncReturns.cpp
TestAsyncReturns.h
TestBadActor.cpp
TestBadActor.h
TestCancel.cpp Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan 2019-05-01 08:47:10 +00:00
TestCancel.h Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan 2019-05-01 08:47:10 +00:00
TestCrashCleanup.cpp
TestCrashCleanup.h
TestDataStructures.cpp Bug 1289211 - Rename InfallibleTArray to nsTArray in ipc/ r=nika 2019-07-10 03:31:24 +00:00
TestDataStructures.h Bug 1289211 - Rename InfallibleTArray to nsTArray in ipc/ r=nika 2019-07-10 03:31:24 +00:00
TestDemon.cpp
TestDemon.h
TestDesc.cpp
TestDesc.h
TestEndpointBridgeMain.cpp
TestEndpointBridgeMain.h
TestEndpointOpens.cpp Bug 1441651 - Part 2 - pass Shmem and ByteBuf by rvalref to Send* IPC methods; r=nika,jrmuizel 2019-03-04 16:35:30 +00:00
TestEndpointOpens.h
TestFailedCtor.cpp
TestFailedCtor.h
TestHangs.cpp Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
TestHangs.h
TestHighestPrio.cpp
TestHighestPrio.h
TestInterruptErrorCleanup.cpp
TestInterruptErrorCleanup.h
TestInterruptRaces.cpp
TestInterruptRaces.h
TestInterruptShutdownRace.cpp
TestInterruptShutdownRace.h
TestJSON.cpp Bug 1289211 - Rename InfallibleTArray to nsTArray in ipc/ r=nika 2019-07-10 03:31:24 +00:00
TestJSON.h
TestLatency.cpp Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
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 Bug 1441651 - Part 2 - pass Shmem and ByteBuf by rvalref to Send* IPC methods; r=nika,jrmuizel 2019-03-04 16:35:30 +00:00
TestShmem.h
TestShutdown.cpp
TestShutdown.h
TestStackHooks.cpp Bug 1548717 - Part 1: Remove the unnecessary internal liveness state value, r=froydnj 2019-05-21 17:04:27 +00:00
TestStackHooks.h
TestSyncError.cpp
TestSyncError.h
TestSyncHang.cpp
TestSyncHang.h
TestSyncWakeup.cpp
TestSyncWakeup.h
TestUniquePtrIPC.cpp Bug 1441651 - Part 2 - pass Shmem and ByteBuf by rvalref to Send* IPC methods; r=nika,jrmuizel 2019-03-04 16:35:30 +00:00
TestUniquePtrIPC.h
TestUrgency.cpp Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan 2019-05-01 08:47:10 +00:00
TestUrgency.h Bug 1547143 - Format the tree: Be prescriptive with the pointer style (left) r=Ehsan 2019-05-01 08:47:10 +00:00
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.