michael@0: To add a new IPDL C++ unit test, you need to create (at least) the michael@0: following files (for a test "TestFoo"): michael@0: michael@0: - PTestFoo.ipdl, specifying the top-level protocol used for the test michael@0: michael@0: - TestFoo.h, declaring the top-level parent/child actors used for michael@0: the test michael@0: michael@0: - TestFoo.cpp, defining the top-level actors michael@0: michael@0: - (make sure all are in the namespace mozilla::_ipdltest) michael@0: michael@0: Next michael@0: michael@0: - add PTestFoo.ipdl to ipdl.mk michael@0: michael@0: - append TestFoo to the variable IPDLTESTS in Makefile.in michael@0: michael@0: You must define three methods in your |TestFooParent| class: michael@0: michael@0: - static methods |bool RunTestInProcesses()| and michael@0: |bool RunTestInThreads()|. These methods control whether michael@0: to execute the test using actors in separate processes and michael@0: threads respectively. Generally, both should return true. michael@0: michael@0: - an instance method |void Main()|. The test harness wil first michael@0: initialize the processes or threads, create and open both actors, michael@0: and then kick off the test using |Main()|. Make sure you define michael@0: it. michael@0: michael@0: If your test passes its criteria, please call michael@0: |MOZ_IPDL_TESTPASS("msg")| and "exit gracefully". michael@0: michael@0: If your tests fails, please call |MOZ_IPDL_TESTFAIL("msg")| and "exit michael@0: ungracefully", preferably by abort()ing. michael@0: michael@0: michael@0: If all goes well, running michael@0: michael@0: make -C $OBJDIR/ipc/ipdl/test/cxx michael@0: michael@0: will update the file IPDLUnitTests.cpp (the test launcher), and your michael@0: new code will be built automatically. michael@0: michael@0: michael@0: You can launch your new test by invoking one of michael@0: michael@0: make -C $OBJDIR/ipc/ipdl/test/cxx check-proc (test process-based tests) michael@0: make -C $OBJDIR/ipc/ipdl/test/cxx check-threads (test thread-based tests) michael@0: make -C $OBJDIR/ipc/ipdl/test/cxx check (tests both) michael@0: michael@0: If you want to launch only your test, run michael@0: michael@0: cd $OBJDIR/dist/bin michael@0: ./run-mozilla.sh ./ipdlunittest TestFoo (test in two processes, if appl.) michael@0: ./run-mozilla.sh ./ipdlunittest thread:TestFoo (test in two threads, if appl.) michael@0: michael@0: michael@0: For a bare-bones example of adding a test, take a look at michael@0: PTestSanity.ipdl, TestSanity.h, TestSanity.cpp, and how "TestSanity" michael@0: is included in ipdl.mk and Makefile.in.