diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp')
-rw-r--r-- | ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp b/ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp new file mode 100644 index 000000000..513b84f73 --- /dev/null +++ b/ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp @@ -0,0 +1,119 @@ +#include "TestRacyInterruptReplies.h" + +#include "IPDLUnitTests.h" // fail etc. + +namespace mozilla { +namespace _ipdltest { + +//----------------------------------------------------------------------------- +// parent + +TestRacyInterruptRepliesParent::TestRacyInterruptRepliesParent() : mReplyNum(0) +{ + MOZ_COUNT_CTOR(TestRacyInterruptRepliesParent); +} + +TestRacyInterruptRepliesParent::~TestRacyInterruptRepliesParent() +{ + MOZ_COUNT_DTOR(TestRacyInterruptRepliesParent); +} + +void +TestRacyInterruptRepliesParent::Main() +{ + int replyNum = -1; + if (!CallR_(&replyNum)) + fail("calling R()"); + + if (1 != replyNum) + fail("this should have been the first reply to R()"); + + if (!SendChildTest()) + fail("sending ChildStart"); +} + +bool +TestRacyInterruptRepliesParent::RecvA_() +{ + int replyNum = -1; + // this R() call races with the reply being generated by the other + // side to the R() call from Main(). This is a pretty nasty edge + // case for which one could argue we're breaking in-order message + // delivery, since this side will process the second reply to R() + // before the first. + if (!CallR_(&replyNum)) + fail("calling R()"); + + if (2 != replyNum) + fail("this should have been the second reply to R()"); + + return true; +} + +bool +TestRacyInterruptRepliesParent::Answer_R(int* replyNum) +{ + *replyNum = ++mReplyNum; + + if (1 == *replyNum) + if (!Send_A()) + fail("sending _A()"); + + return true; +} + +//----------------------------------------------------------------------------- +// child + +TestRacyInterruptRepliesChild::TestRacyInterruptRepliesChild() : mReplyNum(0) +{ + MOZ_COUNT_CTOR(TestRacyInterruptRepliesChild); +} + +TestRacyInterruptRepliesChild::~TestRacyInterruptRepliesChild() +{ + MOZ_COUNT_DTOR(TestRacyInterruptRepliesChild); +} + +bool +TestRacyInterruptRepliesChild::AnswerR_(int* replyNum) +{ + *replyNum = ++mReplyNum; + + if (1 == *replyNum) + SendA_(); + + return true; +} + +bool +TestRacyInterruptRepliesChild::RecvChildTest() +{ + int replyNum = -1; + if (!Call_R(&replyNum)) + fail("calling R()"); + + if (1 != replyNum) + fail("this should have been the first reply to R()"); + + Close(); + + return true; +} + +bool +TestRacyInterruptRepliesChild::Recv_A() +{ + int replyNum = -1; + + if (!Call_R(&replyNum)) + fail("calling _R()"); + + if (2 != replyNum) + fail("this should have been the second reply to R()"); + + return true; +} + +} // namespace _ipdltest +} // namespace mozilla |