Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | To add a new IPDL C++ unit test, you need to create (at least) the |
michael@0 | 2 | following files (for a test "TestFoo"): |
michael@0 | 3 | |
michael@0 | 4 | - PTestFoo.ipdl, specifying the top-level protocol used for the test |
michael@0 | 5 | |
michael@0 | 6 | - TestFoo.h, declaring the top-level parent/child actors used for |
michael@0 | 7 | the test |
michael@0 | 8 | |
michael@0 | 9 | - TestFoo.cpp, defining the top-level actors |
michael@0 | 10 | |
michael@0 | 11 | - (make sure all are in the namespace mozilla::_ipdltest) |
michael@0 | 12 | |
michael@0 | 13 | Next |
michael@0 | 14 | |
michael@0 | 15 | - add PTestFoo.ipdl to ipdl.mk |
michael@0 | 16 | |
michael@0 | 17 | - append TestFoo to the variable IPDLTESTS in Makefile.in |
michael@0 | 18 | |
michael@0 | 19 | You must define three methods in your |TestFooParent| class: |
michael@0 | 20 | |
michael@0 | 21 | - static methods |bool RunTestInProcesses()| and |
michael@0 | 22 | |bool RunTestInThreads()|. These methods control whether |
michael@0 | 23 | to execute the test using actors in separate processes and |
michael@0 | 24 | threads respectively. Generally, both should return true. |
michael@0 | 25 | |
michael@0 | 26 | - an instance method |void Main()|. The test harness wil first |
michael@0 | 27 | initialize the processes or threads, create and open both actors, |
michael@0 | 28 | and then kick off the test using |Main()|. Make sure you define |
michael@0 | 29 | it. |
michael@0 | 30 | |
michael@0 | 31 | If your test passes its criteria, please call |
michael@0 | 32 | |MOZ_IPDL_TESTPASS("msg")| and "exit gracefully". |
michael@0 | 33 | |
michael@0 | 34 | If your tests fails, please call |MOZ_IPDL_TESTFAIL("msg")| and "exit |
michael@0 | 35 | ungracefully", preferably by abort()ing. |
michael@0 | 36 | |
michael@0 | 37 | |
michael@0 | 38 | If all goes well, running |
michael@0 | 39 | |
michael@0 | 40 | make -C $OBJDIR/ipc/ipdl/test/cxx |
michael@0 | 41 | |
michael@0 | 42 | will update the file IPDLUnitTests.cpp (the test launcher), and your |
michael@0 | 43 | new code will be built automatically. |
michael@0 | 44 | |
michael@0 | 45 | |
michael@0 | 46 | You can launch your new test by invoking one of |
michael@0 | 47 | |
michael@0 | 48 | make -C $OBJDIR/ipc/ipdl/test/cxx check-proc (test process-based tests) |
michael@0 | 49 | make -C $OBJDIR/ipc/ipdl/test/cxx check-threads (test thread-based tests) |
michael@0 | 50 | make -C $OBJDIR/ipc/ipdl/test/cxx check (tests both) |
michael@0 | 51 | |
michael@0 | 52 | If you want to launch only your test, run |
michael@0 | 53 | |
michael@0 | 54 | cd $OBJDIR/dist/bin |
michael@0 | 55 | ./run-mozilla.sh ./ipdlunittest TestFoo (test in two processes, if appl.) |
michael@0 | 56 | ./run-mozilla.sh ./ipdlunittest thread:TestFoo (test in two threads, if appl.) |
michael@0 | 57 | |
michael@0 | 58 | |
michael@0 | 59 | For a bare-bones example of adding a test, take a look at |
michael@0 | 60 | PTestSanity.ipdl, TestSanity.h, TestSanity.cpp, and how "TestSanity" |
michael@0 | 61 | is included in ipdl.mk and Makefile.in. |