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