ipc/ipdl/test/cxx/README.txt

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/ipdl/test/cxx/README.txt	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +To add a new IPDL C++ unit test, you need to create (at least) the
     1.5 +following files (for a test "TestFoo"):
     1.6 +
     1.7 +  - PTestFoo.ipdl, specifying the top-level protocol used for the test
     1.8 +
     1.9 +  - TestFoo.h, declaring the top-level parent/child actors used for
    1.10 +    the test
    1.11 +
    1.12 +  - TestFoo.cpp, defining the top-level actors
    1.13 +
    1.14 +  - (make sure all are in the namespace mozilla::_ipdltest)
    1.15 +
    1.16 +Next
    1.17 +
    1.18 +  - add PTestFoo.ipdl to ipdl.mk
    1.19 +
    1.20 +  - append TestFoo to the variable IPDLTESTS in Makefile.in
    1.21 +
    1.22 +You must define three methods in your |TestFooParent| class:
    1.23 +
    1.24 +  - static methods |bool RunTestInProcesses()| and
    1.25 +    |bool RunTestInThreads()|.  These methods control whether
    1.26 +    to execute the test using actors in separate processes and
    1.27 +    threads respectively.  Generally, both should return true.
    1.28 +
    1.29 +  - an instance method |void Main()|.  The test harness wil first
    1.30 +    initialize the processes or threads, create and open both actors,
    1.31 +    and then kick off the test using |Main()|.  Make sure you define
    1.32 +    it.
    1.33 +
    1.34 +If your test passes its criteria, please call
    1.35 +|MOZ_IPDL_TESTPASS("msg")| and "exit gracefully".
    1.36 +
    1.37 +If your tests fails, please call |MOZ_IPDL_TESTFAIL("msg")| and "exit
    1.38 +ungracefully", preferably by abort()ing.
    1.39 +
    1.40 +
    1.41 +If all goes well, running
    1.42 +
    1.43 +  make -C $OBJDIR/ipc/ipdl/test/cxx
    1.44 +
    1.45 +will update the file IPDLUnitTests.cpp (the test launcher), and your
    1.46 +new code will be built automatically.
    1.47 +
    1.48 +
    1.49 +You can launch your new test by invoking one of
    1.50 +
    1.51 +  make -C $OBJDIR/ipc/ipdl/test/cxx check-proc     (test process-based tests)
    1.52 +  make -C $OBJDIR/ipc/ipdl/test/cxx check-threads  (test thread-based tests)
    1.53 +  make -C $OBJDIR/ipc/ipdl/test/cxx check          (tests both)
    1.54 +
    1.55 +If you want to launch only your test, run
    1.56 +
    1.57 +  cd $OBJDIR/dist/bin
    1.58 +  ./run-mozilla.sh ./ipdlunittest TestFoo          (test in two processes, if appl.)
    1.59 +  ./run-mozilla.sh ./ipdlunittest thread:TestFoo   (test in two threads, if appl.)
    1.60 +
    1.61 +
    1.62 +For a bare-bones example of adding a test, take a look at
    1.63 +PTestSanity.ipdl, TestSanity.h, TestSanity.cpp, and how "TestSanity"
    1.64 +is included in ipdl.mk and Makefile.in.

mercurial