2009-12-03 00:16:28 -08:00
|
|
|
#include "TestShutdown.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace _ipdltest {
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Parent side
|
|
|
|
void
|
|
|
|
TestShutdownParent::Main()
|
|
|
|
{
|
2010-04-26 22:43:01 -07:00
|
|
|
if (!SendStart())
|
|
|
|
fail("sending Start()");
|
2009-12-03 00:16:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestShutdownParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
if (AbnormalShutdown != why)
|
|
|
|
fail("should have ended test with crash!");
|
|
|
|
|
|
|
|
passed("ok");
|
|
|
|
|
|
|
|
QuitParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestShutdownSubParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
nsTArray<PTestShutdownSubParent*> broArr; // grumble grumble
|
|
|
|
Manager()->ManagedPTestShutdownSubParent(broArr);
|
|
|
|
if (broArr.Length() == 0)
|
|
|
|
fail("manager should still have managees!");
|
|
|
|
|
|
|
|
if (mExpectCrash && AbnormalShutdown != why)
|
|
|
|
fail("expected crash!");
|
|
|
|
else if (!mExpectCrash && AbnormalShutdown == why)
|
|
|
|
fail("wasn't expecting crash!");
|
|
|
|
|
2010-04-26 18:11:47 -07:00
|
|
|
if (mExpectCrash && 0 == ManagedPTestShutdownSubsubParent().Length())
|
2009-12-03 00:16:28 -08:00
|
|
|
fail("expected to *still* have kids");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestShutdownSubsubParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2010-04-26 18:11:47 -07:00
|
|
|
if (Manager()->ManagedPTestShutdownSubsubParent().Length() == 0)
|
2009-12-03 00:16:28 -08:00
|
|
|
fail("manager should still have managees!");
|
|
|
|
|
|
|
|
if (mExpectParentDeleted && AncestorDeletion != why)
|
|
|
|
fail("expected ParentDeleted == why");
|
|
|
|
else if (!mExpectParentDeleted && AncestorDeletion == why)
|
|
|
|
fail("wasn't expecting parent delete");
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Child side
|
|
|
|
|
|
|
|
bool
|
|
|
|
TestShutdownChild::RecvStart()
|
|
|
|
{
|
|
|
|
// test 1: alloc some actors and subactors, delete in
|
|
|
|
// managee-before-manager order
|
|
|
|
{
|
|
|
|
bool expectCrash = false, expectParentDeleted = false;
|
|
|
|
|
|
|
|
PTestShutdownSubChild* c1 =
|
|
|
|
SendPTestShutdownSubConstructor(expectCrash);
|
|
|
|
if (!c1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubChild* c2 =
|
|
|
|
SendPTestShutdownSubConstructor(expectCrash);
|
|
|
|
if (!c2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubsubChild* c1s1 =
|
|
|
|
c1->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c1s1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
PTestShutdownSubsubChild* c1s2 =
|
|
|
|
c1->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c1s2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubsubChild* c2s1 =
|
|
|
|
c2->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c2s1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
PTestShutdownSubsubChild* c2s2 =
|
|
|
|
c2->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c2s2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
2010-01-14 21:25:56 -08:00
|
|
|
if (!PTestShutdownSubsubChild::Send__delete__(c1s1))
|
|
|
|
fail("problem sending dtor");
|
|
|
|
if (!PTestShutdownSubsubChild::Send__delete__(c1s2))
|
|
|
|
fail("problem sending dtor");
|
|
|
|
if (!PTestShutdownSubsubChild::Send__delete__(c2s1))
|
|
|
|
fail("problem sending dtor");
|
|
|
|
if (!PTestShutdownSubsubChild::Send__delete__(c2s2))
|
|
|
|
fail("problem sending dtor");
|
|
|
|
|
2010-01-15 13:15:51 -08:00
|
|
|
if (!c1->CallStackFrame())
|
|
|
|
fail("problem creating dummy stack frame");
|
|
|
|
if (!c2->CallStackFrame())
|
|
|
|
fail("problem creating dummy stack frame");
|
2009-12-03 00:16:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// test 2: alloc some actors and subactors, delete managers first
|
|
|
|
{
|
|
|
|
bool expectCrash = false, expectParentDeleted = true;
|
|
|
|
|
|
|
|
PTestShutdownSubChild* c1 =
|
|
|
|
SendPTestShutdownSubConstructor(expectCrash);
|
|
|
|
if (!c1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubChild* c2 =
|
|
|
|
SendPTestShutdownSubConstructor(expectCrash);
|
|
|
|
if (!c2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubsubChild* c1s1 =
|
|
|
|
c1->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c1s1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
PTestShutdownSubsubChild* c1s2 =
|
|
|
|
c1->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c1s2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubsubChild* c2s1 =
|
|
|
|
c2->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c2s1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
PTestShutdownSubsubChild* c2s2 =
|
|
|
|
c2->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c2s2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
// delete parents without deleting kids
|
2010-01-15 13:15:51 -08:00
|
|
|
if (!c1->CallStackFrame())
|
|
|
|
fail("problem creating dummy stack frame");
|
|
|
|
if (!c2->CallStackFrame())
|
|
|
|
fail("problem creating dummy stack frame");
|
2009-12-03 00:16:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// test 3: alloc some actors and subactors, then crash
|
|
|
|
{
|
|
|
|
bool expectCrash = true, expectParentDeleted = false;
|
|
|
|
|
|
|
|
PTestShutdownSubChild* c1 =
|
|
|
|
SendPTestShutdownSubConstructor(expectCrash);
|
|
|
|
if (!c1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubChild* c2 =
|
|
|
|
SendPTestShutdownSubConstructor(expectCrash);
|
|
|
|
if (!c2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubsubChild* c1s1 =
|
|
|
|
c1->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c1s1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
PTestShutdownSubsubChild* c1s2 =
|
|
|
|
c1->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c1s2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
PTestShutdownSubsubChild* c2s1 =
|
|
|
|
c2->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c2s1)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
PTestShutdownSubsubChild* c2s2 =
|
|
|
|
c2->SendPTestShutdownSubsubConstructor(expectParentDeleted);
|
|
|
|
if (!c2s2)
|
|
|
|
fail("problem sending ctor");
|
|
|
|
|
|
|
|
// make sure the ctors have been processed by the other side;
|
|
|
|
// the write end of the socket may temporarily be unwriteable
|
|
|
|
if (!SendSync())
|
|
|
|
fail("can't synchronize with parent");
|
|
|
|
|
|
|
|
// "crash", but without tripping tinderbox assert/abort
|
|
|
|
// detectors
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestShutdownChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
fail("hey wait ... we should have crashed!");
|
|
|
|
}
|
|
|
|
|
2010-01-15 13:15:51 -08:00
|
|
|
bool
|
|
|
|
TestShutdownSubChild::AnswerStackFrame()
|
|
|
|
{
|
|
|
|
if (!PTestShutdownSubChild::Send__delete__(this))
|
|
|
|
fail("problem sending dtor");
|
|
|
|
|
|
|
|
// WATCH OUT! |this| has just deleted
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-12-03 00:16:28 -08:00
|
|
|
void
|
|
|
|
TestShutdownSubChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2010-04-26 18:11:47 -07:00
|
|
|
if (Manager()->ManagedPTestShutdownSubChild().Length() == 0)
|
2009-12-03 00:16:28 -08:00
|
|
|
fail("manager should still have managees!");
|
|
|
|
|
|
|
|
if (mExpectCrash && AbnormalShutdown != why)
|
|
|
|
fail("expected crash!");
|
|
|
|
else if (!mExpectCrash && AbnormalShutdown == why)
|
|
|
|
fail("wasn't expecting crash!");
|
|
|
|
|
2010-04-26 18:11:47 -07:00
|
|
|
if (mExpectCrash && 0 == ManagedPTestShutdownSubsubChild().Length())
|
2009-12-03 00:16:28 -08:00
|
|
|
fail("expected to *still* have kids");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TestShutdownSubsubChild::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
2010-04-26 18:11:47 -07:00
|
|
|
if (Manager()->ManagedPTestShutdownSubsubChild().Length() == 0)
|
2009-12-03 00:16:28 -08:00
|
|
|
fail("manager should still have managees!");
|
|
|
|
|
|
|
|
if (mExpectParentDeleted && AncestorDeletion != why)
|
|
|
|
fail("expected ParentDeleted == why");
|
|
|
|
else if (!mExpectParentDeleted && AncestorDeletion == why)
|
|
|
|
fail("wasn't expecting parent delete");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace _ipdltest
|
|
|
|
} // namespace mozilla
|