blob: 513b84f73ed80c4a08532e567043c79147a96fdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
|