mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 552014: Test
This commit is contained in:
parent
2ec17c6ad8
commit
eae7be085a
@ -58,23 +58,24 @@ FORCE_STATIC_LIB = 1
|
||||
EXPORT_LIBRARY = 1
|
||||
|
||||
IPDLTESTS = \
|
||||
TestSanity \
|
||||
TestRPCErrorCleanup \
|
||||
TestCrashCleanup \
|
||||
TestStackHooks \
|
||||
TestSyncWakeup \
|
||||
TestLatency \
|
||||
TestRPCRaces \
|
||||
TestRacyRPCReplies \
|
||||
TestRPCShutdownRace \
|
||||
TestHangs \
|
||||
TestArrays \
|
||||
TestBlockChild \
|
||||
TestManyChildAllocs \
|
||||
TestCrashCleanup \
|
||||
TestDesc \
|
||||
TestHangs \
|
||||
TestLatency \
|
||||
TestManyChildAllocs \
|
||||
TestMultiMgrs \
|
||||
TestNestedLoops \
|
||||
TestRPCErrorCleanup \
|
||||
TestRPCRaces \
|
||||
TestRPCShutdownRace \
|
||||
TestRacyRPCReplies \
|
||||
TestSanity \
|
||||
TestShmem \
|
||||
TestShutdown \
|
||||
TestArrays \
|
||||
TestStackHooks \
|
||||
TestSyncWakeup \
|
||||
$(NULL)
|
||||
|
||||
IPDLTESTSRCS = $(addsuffix .cpp,$(IPDLTESTS))
|
||||
|
34
ipc/ipdl/test/cxx/PTestNestedLoops.ipdl
Normal file
34
ipc/ipdl/test/cxx/PTestNestedLoops.ipdl
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
|
||||
rpc protocol PTestNestedLoops {
|
||||
|
||||
child:
|
||||
async Start();
|
||||
rpc R();
|
||||
__delete__();
|
||||
|
||||
parent:
|
||||
async Nonce();
|
||||
|
||||
|
||||
state START:
|
||||
send Start goto RACE;
|
||||
|
||||
state RACE:
|
||||
recv Nonce goto RACE1;
|
||||
call R goto RACE2;
|
||||
state RACE1:
|
||||
call R goto DEAD;
|
||||
state RACE2:
|
||||
recv Nonce goto DEAD;
|
||||
|
||||
state DEAD:
|
||||
send __delete__;
|
||||
};
|
||||
|
||||
|
||||
} // namespace mozilla
|
||||
} // namespace _ipdltest
|
106
ipc/ipdl/test/cxx/TestNestedLoops.cpp
Normal file
106
ipc/ipdl/test/cxx/TestNestedLoops.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include "base/basictypes.h"
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "TestNestedLoops.h"
|
||||
|
||||
#include "IPDLUnitTests.h" // fail etc.
|
||||
|
||||
template<>
|
||||
struct RunnableMethodTraits<mozilla::_ipdltest::TestNestedLoopsParent>
|
||||
{
|
||||
static void RetainCallee(mozilla::_ipdltest::TestNestedLoopsParent* obj) { }
|
||||
static void ReleaseCallee(mozilla::_ipdltest::TestNestedLoopsParent* obj) { }
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// parent
|
||||
|
||||
TestNestedLoopsParent::TestNestedLoopsParent() : mBreakNestedLoop(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TestNestedLoopsParent);
|
||||
}
|
||||
|
||||
TestNestedLoopsParent::~TestNestedLoopsParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TestNestedLoopsParent);
|
||||
}
|
||||
|
||||
void
|
||||
TestNestedLoopsParent::Main()
|
||||
{
|
||||
if (!SendStart())
|
||||
fail("sending Start");
|
||||
|
||||
// sigh ... spin for a while to let Nonce arrive
|
||||
puts(" (sleeping to wait for nonce ... sorry)");
|
||||
PR_Sleep(5000);
|
||||
|
||||
// while waiting for the reply to R, we'll receive Nonce
|
||||
if (!CallR())
|
||||
fail("calling R");
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
bool
|
||||
TestNestedLoopsParent::RecvNonce()
|
||||
{
|
||||
// if we have an OnMaybeDequeueOne waiting for us (we may not, due
|
||||
// to the inherent race condition in this test, then this event
|
||||
// must be ordered after it in the queue
|
||||
MessageLoop::current()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(this, &TestNestedLoopsParent::BreakNestedLoop));
|
||||
|
||||
// sigh ... spin for a while to let the reply to R arrive
|
||||
puts(" (sleeping to wait for reply to R ... sorry)");
|
||||
PR_Sleep(5000);
|
||||
|
||||
// sigh ... we have no idea when code might do this
|
||||
do {
|
||||
if (!NS_ProcessNextEvent(nsnull, PR_FALSE))
|
||||
fail("expected at least one pending event");
|
||||
} while (!mBreakNestedLoop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TestNestedLoopsParent::BreakNestedLoop()
|
||||
{
|
||||
mBreakNestedLoop = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// child
|
||||
|
||||
TestNestedLoopsChild::TestNestedLoopsChild()
|
||||
{
|
||||
MOZ_COUNT_CTOR(TestNestedLoopsChild);
|
||||
}
|
||||
|
||||
TestNestedLoopsChild::~TestNestedLoopsChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TestNestedLoopsChild);
|
||||
}
|
||||
|
||||
bool
|
||||
TestNestedLoopsChild::RecvStart()
|
||||
{
|
||||
if (!SendNonce())
|
||||
fail("sending Nonce");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TestNestedLoopsChild::AnswerR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
69
ipc/ipdl/test/cxx/TestNestedLoops.h
Normal file
69
ipc/ipdl/test/cxx/TestNestedLoops.h
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef mozilla__ipdltest_TestNestedLoops_h
|
||||
#define mozilla__ipdltest_TestNestedLoops_h 1
|
||||
|
||||
#include "mozilla/_ipdltest/IPDLUnitTests.h"
|
||||
|
||||
#include "mozilla/_ipdltest/PTestNestedLoopsParent.h"
|
||||
#include "mozilla/_ipdltest/PTestNestedLoopsChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
|
||||
class TestNestedLoopsParent :
|
||||
public PTestNestedLoopsParent
|
||||
{
|
||||
public:
|
||||
TestNestedLoopsParent();
|
||||
virtual ~TestNestedLoopsParent();
|
||||
|
||||
void Main();
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvNonce();
|
||||
|
||||
void BreakNestedLoop();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual void ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (NormalShutdown != why)
|
||||
fail("unexpected destruction!");
|
||||
passed("ok");
|
||||
QuitParent();
|
||||
}
|
||||
|
||||
bool mBreakNestedLoop;
|
||||
};
|
||||
|
||||
|
||||
class TestNestedLoopsChild :
|
||||
public PTestNestedLoopsChild
|
||||
{
|
||||
public:
|
||||
TestNestedLoopsChild();
|
||||
virtual ~TestNestedLoopsChild();
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual bool RecvStart();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool AnswerR();
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual void ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (NormalShutdown != why)
|
||||
fail("unexpected destruction!");
|
||||
QuitChild();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace _ipdltest
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
#endif // ifndef mozilla__ipdltest_TestNestedLoops_h
|
@ -14,6 +14,7 @@ IPDLSRCS = \
|
||||
PTestMultiMgrsLeft.ipdl \
|
||||
PTestMultiMgrsRight.ipdl \
|
||||
PTestMultiMgrsBottom.ipdl \
|
||||
PTestNestedLoops.ipdl \
|
||||
PTestRacyRPCReplies.ipdl \
|
||||
PTestRPCErrorCleanup.ipdl \
|
||||
PTestRPCRaces.ipdl \
|
||||
|
Loading…
Reference in New Issue
Block a user