mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Test for bug 572134. a=b
This commit is contained in:
parent
a7c8bdb47f
commit
402b448575
@ -71,6 +71,7 @@ IPDLTESTS = \
|
||||
TestRPCErrorCleanup \
|
||||
TestRPCRaces \
|
||||
TestRPCShutdownRace \
|
||||
TestRaceDeferral \
|
||||
TestRacyReentry \
|
||||
TestRacyRPCReplies \
|
||||
TestSanity \
|
||||
|
45
ipc/ipdl/test/cxx/PTestRaceDeferral.ipdl
Normal file
45
ipc/ipdl/test/cxx/PTestRaceDeferral.ipdl
Normal file
@ -0,0 +1,45 @@
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
rpc protocol PTestRaceDeferral {
|
||||
parent:
|
||||
rpc Lose();
|
||||
|
||||
child:
|
||||
async StartRace();
|
||||
rpc Win();
|
||||
rpc Rpc();
|
||||
async __delete__();
|
||||
|
||||
// Test that messages deferred due to race resolution are
|
||||
// re-considered when the winner makes later RPCs
|
||||
|
||||
// IPDL's type system can't express this protocol because the race
|
||||
// resolution causes state to diverge for multiple steps, so we'll
|
||||
// leave it "stateless"
|
||||
/*
|
||||
state START:
|
||||
send StartRace goto DEFER;
|
||||
state DEFER:
|
||||
call Win goto PARENT;
|
||||
answer Lose goto CHILD;
|
||||
|
||||
state PARENT:
|
||||
// 'Lose' is received here but deferred
|
||||
call Rpc goto PARENT_LOSE;
|
||||
state PARENT_LOSE:
|
||||
// Calling 'Rpc' undefers 'Lose', and it wins the "race" with 'Rpc'
|
||||
answer Lose goto DONE;
|
||||
|
||||
state CHILD:
|
||||
call Win goto CHILD_RPC;
|
||||
state CHILD_RPC:
|
||||
call Rpc goto DONE;
|
||||
|
||||
state DONE:
|
||||
send __delete__;
|
||||
*/
|
||||
};
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
118
ipc/ipdl/test/cxx/TestRaceDeferral.cpp
Normal file
118
ipc/ipdl/test/cxx/TestRaceDeferral.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
#include "TestRaceDeferral.h"
|
||||
|
||||
#include "IPDLUnitTests.h" // fail etc.
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
typedef mozilla::ipc::RPCChannel::Message Message;
|
||||
typedef mozilla::ipc::RPCChannel::RacyRPCPolicy RacyRPCPolicy;
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
static RacyRPCPolicy
|
||||
MediateRace(const Message& parent, const Message& child)
|
||||
{
|
||||
return (PTestRaceDeferral::Msg_Win__ID == parent.type()) ?
|
||||
RPCChannel::RRPParentWins : RPCChannel::RRPChildWins;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// parent
|
||||
|
||||
TestRaceDeferralParent::TestRaceDeferralParent()
|
||||
: mProcessedLose(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TestRaceDeferralParent);
|
||||
}
|
||||
|
||||
TestRaceDeferralParent::~TestRaceDeferralParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TestRaceDeferralParent);
|
||||
|
||||
if (!mProcessedLose)
|
||||
fail("never processed Lose");
|
||||
}
|
||||
|
||||
void
|
||||
TestRaceDeferralParent::Main()
|
||||
{
|
||||
Test1();
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
void
|
||||
TestRaceDeferralParent::Test1()
|
||||
{
|
||||
if (!SendStartRace())
|
||||
fail("sending StartRace");
|
||||
|
||||
if (!CallWin())
|
||||
fail("calling Win");
|
||||
if (mProcessedLose)
|
||||
fail("Lose didn't lose");
|
||||
|
||||
if (!CallRpc())
|
||||
fail("calling Rpc");
|
||||
if (!mProcessedLose)
|
||||
fail("didn't resolve Rpc vs. Lose 'race' correctly");
|
||||
}
|
||||
|
||||
bool
|
||||
TestRaceDeferralParent::AnswerLose()
|
||||
{
|
||||
if (mProcessedLose)
|
||||
fail("processed Lose twice");
|
||||
mProcessedLose = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
RacyRPCPolicy
|
||||
TestRaceDeferralParent::MediateRPCRace(const Message& parent,
|
||||
const Message& child)
|
||||
{
|
||||
return MediateRace(parent, child);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// child
|
||||
|
||||
TestRaceDeferralChild::TestRaceDeferralChild()
|
||||
{
|
||||
MOZ_COUNT_CTOR(TestRaceDeferralChild);
|
||||
}
|
||||
|
||||
TestRaceDeferralChild::~TestRaceDeferralChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TestRaceDeferralChild);
|
||||
}
|
||||
|
||||
bool
|
||||
TestRaceDeferralChild::RecvStartRace()
|
||||
{
|
||||
if (!CallLose())
|
||||
fail("calling Lose");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestRaceDeferralChild::AnswerWin()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestRaceDeferralChild::AnswerRpc()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RacyRPCPolicy
|
||||
TestRaceDeferralChild::MediateRPCRace(const Message& parent,
|
||||
const Message& child)
|
||||
{
|
||||
return MediateRace(parent, child);
|
||||
}
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
79
ipc/ipdl/test/cxx/TestRaceDeferral.h
Normal file
79
ipc/ipdl/test/cxx/TestRaceDeferral.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef mozilla__ipdltest_TestRaceDeferral_h
|
||||
#define mozilla__ipdltest_TestRaceDeferral_h 1
|
||||
|
||||
#include "mozilla/_ipdltest/IPDLUnitTests.h"
|
||||
|
||||
#include "mozilla/_ipdltest/PTestRaceDeferralParent.h"
|
||||
#include "mozilla/_ipdltest/PTestRaceDeferralChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
class TestRaceDeferralParent :
|
||||
public PTestRaceDeferralParent
|
||||
{
|
||||
public:
|
||||
TestRaceDeferralParent();
|
||||
virtual ~TestRaceDeferralParent();
|
||||
|
||||
void Main();
|
||||
|
||||
protected:
|
||||
void Test1();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool AnswerLose();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||
MediateRPCRace(const Message& parent, const Message& child);
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual void ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (NormalShutdown != why)
|
||||
fail("unexpected destruction!");
|
||||
passed("ok");
|
||||
QuitParent();
|
||||
}
|
||||
|
||||
bool mProcessedLose;
|
||||
};
|
||||
|
||||
|
||||
class TestRaceDeferralChild :
|
||||
public PTestRaceDeferralChild
|
||||
{
|
||||
public:
|
||||
TestRaceDeferralChild();
|
||||
virtual ~TestRaceDeferralChild();
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvStartRace();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool AnswerWin();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool AnswerRpc();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||
MediateRPCRace(const Message& parent, const Message& child);
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual void ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (NormalShutdown != why)
|
||||
fail("unexpected destruction!");
|
||||
QuitChild();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
#endif // ifndef mozilla__ipdltest_TestRaceDeferral_h
|
@ -17,6 +17,7 @@ IPDLSRCS = \
|
||||
PTestMultiMgrsRight.ipdl \
|
||||
PTestMultiMgrsBottom.ipdl \
|
||||
PTestNestedLoops.ipdl \
|
||||
PTestRaceDeferral.ipdl \
|
||||
PTestRacyReentry.ipdl \
|
||||
PTestRacyRPCReplies.ipdl \
|
||||
PTestRPCErrorCleanup.ipdl \
|
||||
|
Loading…
Reference in New Issue
Block a user