Confirmed users
699
edits
Line 146: | Line 146: | ||
If you put your code in the <code>ipc/test-harness</code>, you can run it by invoking the test-harness binary. Navigate to your dist/bin directory and run | If you put your code in the <code>ipc/test-harness</code>, you can run it by invoking the test-harness binary. Navigate to your dist/bin directory and run | ||
$ ipctestharness | $ ./ipctestharness | ||
If all goes well, you should see the output | If all goes well, you should see the output | ||
[TestParent] in DoStuff() | [TestParent] in DoStuff() | ||
Line 152: | Line 152: | ||
[TestParent] world! | [TestParent] world! | ||
fly by eventually. Remember, the first and third messages are printed by the parent process, and the second is printed by the child process. | fly by eventually. Remember, the first and third messages are printed by the parent process, and the second is printed by the child process. | ||
You can enable more detailed logging by setting the <code>MOZ_IPC_MESSAGE_LOG</code> environment variable in DEBUG builds. For this small example, you will only see something like the following | |||
$ MOZ_IPC_MESSAGE_LOG=1 ./ipctestharness | |||
// [...SNIP...] | |||
[TestParent] in DoStuff() | |||
[time:1248148008902152][TestProtocolParent] SendHello() | |||
[time:1248148008902898][TestProtocolChild] RecvHello() | |||
[TestChild] Hello, | |||
[time:1248148008902939][TestProtocolChild] SendWorld() | |||
[time:1248148008903080][TestProtocolParent] RecvWorld() | |||
[TestParent] world! | |||
Note, however, this code also logs the parameters and returned values of messages that have them (neither message in this little example do), so it can be a valuable debugging asset. | |||
== Exercise: write a slightly less trivial protocol == | == Exercise: write a slightly less trivial protocol == |