gecko-dev/ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp
David Anderson 437f6053a9 Rename IPDL's RPC to Interrupt (bug 910020, r=bent).
--HG--
rename : ipc/ipdl/test/cxx/PTestRPCErrorCleanup.ipdl => ipc/ipdl/test/cxx/PTestInterruptErrorCleanup.ipdl
rename : ipc/ipdl/test/cxx/PTestRPCRaces.ipdl => ipc/ipdl/test/cxx/PTestInterruptRaces.ipdl
rename : ipc/ipdl/test/cxx/PTestRPCShutdownRace.ipdl => ipc/ipdl/test/cxx/PTestInterruptShutdownRace.ipdl
rename : ipc/ipdl/test/cxx/PTestRacyRPCReplies.ipdl => ipc/ipdl/test/cxx/PTestRacyInterruptReplies.ipdl
rename : ipc/ipdl/test/cxx/TestRPCErrorCleanup.cpp => ipc/ipdl/test/cxx/TestInterruptErrorCleanup.cpp
rename : ipc/ipdl/test/cxx/TestRPCErrorCleanup.h => ipc/ipdl/test/cxx/TestInterruptErrorCleanup.h
rename : ipc/ipdl/test/cxx/TestRPCRaces.cpp => ipc/ipdl/test/cxx/TestInterruptRaces.cpp
rename : ipc/ipdl/test/cxx/TestRPCRaces.h => ipc/ipdl/test/cxx/TestInterruptRaces.h
rename : ipc/ipdl/test/cxx/TestRPCShutdownRace.cpp => ipc/ipdl/test/cxx/TestInterruptShutdownRace.cpp
rename : ipc/ipdl/test/cxx/TestRPCShutdownRace.h => ipc/ipdl/test/cxx/TestInterruptShutdownRace.h
rename : ipc/ipdl/test/cxx/TestRacyRPCReplies.cpp => ipc/ipdl/test/cxx/TestRacyInterruptReplies.cpp
rename : ipc/ipdl/test/cxx/TestRacyRPCReplies.h => ipc/ipdl/test/cxx/TestRacyInterruptReplies.h
rename : ipc/ipdl/test/ipdl/error/rpcMessageCompress.ipdl => ipc/ipdl/test/ipdl/error/intrMessageCompress.ipdl
rename : ipc/ipdl/test/ipdl/error/tooWeakRPCAsync.ipdl => ipc/ipdl/test/ipdl/error/tooWeakInterruptAsync.ipdl
rename : ipc/ipdl/test/ipdl/ok/rpcProtocol.ipdl => ipc/ipdl/test/ipdl/ok/intrProtocol.ipdl
2013-09-30 17:27:45 -07:00

120 lines
2.5 KiB
C++

#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