示例#1
0
bool
TestRPCRacesChild::AnswerStackFrame()
{
    // reset for the second test
    mHasReply = false;

    if (!CallStackFrame())
        fail("can't set up stack frame");

    if (!mHasReply)
        fail("should have had reply by now");

    return true;
}
示例#2
0
void
TestStackHooksChild::RunTests()
{
    // 1 because of RecvStart()
    if (1 != mEntered)
        fail("missed stack notification");
    if (mOnStack)
        fail("spurious stack notification");
    if (0 != mIncallDepth)
        fail("EnteredCall/ExitedCall malfunction");

    if (!SendAsync())
        fail("sending Async()");
    if (mOnStack)
        fail("spurious stack notification");
    if (0 != mIncallDepth)
        fail("EnteredCall/ExitedCall malfunction");
    if (2 != mEntered)
        fail("missed stack notification");

    if (!SendSync())
        fail("sending Sync()");
    if (mOnStack)
        fail("spurious stack notification");
    if (0 != mIncallDepth)
        fail("EnteredCall/ExitedCall malfunction");
    if (3 != mEntered)
        fail("missed stack notification");

    if (!CallRpc())
        fail("calling RPC()");
    if (mOnStack)
        fail("spurious stack notification");
    if (0 != mIncallDepth)
        fail("EnteredCall/ExitedCall malfunction");
    if (4 != mEntered)
        fail("missed stack notification");

    if (!CallStackFrame())
        fail("calling StackFrame()");
    if (mOnStack)
        fail("spurious stack notification");
    if (0 != mIncallDepth)
        fail("EnteredCall/ExitedCall malfunction");
    if (5 != mEntered)
        fail("missed stack notification");

    Close();
}
示例#3
0
bool
TestStackHooksParent::AnswerStackFrame()
{
    if (!mOnStack)
        fail("not on C++ stack?!");

    if (!CallStackFrame())
        fail("calling StackFrame()");

    if (!mOnStack)
        fail("not on C++ stack?!");

    if (1 != mIncallDepth)
        fail("missed EnteredCall or ExitedCall hook");

    return true;
}
示例#4
0
bool
TestHangsParent::AnswerStackFrame()
{
    if (PTestHangs::HANG != state()) {
        if (CallStackFrame())
            fail("should have timed out!");
    }
    else {
        // minimum possible, 2 ms.  We want to detecting a hang to race
        // with the reply coming in, as reliably as possible
        SetReplyTimeoutMs(2);

        if (CallHang())
            fail("should have timed out!");
    }

    return true;
}
示例#5
0
void
TestRPCRacesParent::Test2()
{
    puts("  passed");
    puts("Test 2");

    mHasReply = false;
    mChildHasReply = false;

    if (!CallStackFrame())
        fail("can't set up a stack frame");

    puts("  passed");

    MessageLoop::current()->PostTask(
        FROM_HERE,
        NewRunnableMethod(this, &TestRPCRacesParent::Test3));
}
示例#6
0
void
TestHangsParent::Main()
{
    // Here we try to set things up to test the following sequence of events:
    //
    // - subprocess causes an OnMaybeDequeueOne() task to be posted to
    //   this thread
    //
    // - subprocess hangs just long enough for the hang timer to expire
    //
    // - hang-kill code in the parent starts running
    //
    // - subprocess replies to message while hang code runs
    //
    // - reply is processed in OnMaybeDequeueOne() before Close() has
    //   been called or the channel error notification has been posted

    // this tells the subprocess to send us Nonce()
    if (!SendStart())
        fail("sending Start");

    // now we sleep here for a while awaiting the Nonce() message from
    // the child.  since we're not blocked on anything, the IO thread
    // will enqueue an OnMaybeDequeueOne() task to process that
    // message
    // 
    // NB: PR_Sleep is exactly what we want, only the current thread
    // sleeping
    PR_Sleep(5000);

    // when we call into this, we'll pull the Nonce() message out of
    // the mPending queue, but that doesn't matter ... the
    // OnMaybeDequeueOne() event will remain
    if (CallStackFrame() && mDetectedHang)
        fail("should have timed out!");

    // the Close() task in the queue will shut us down
}
示例#7
0
mozilla::ipc::IPCResult
TestHangsParent::AnswerStackFrame()
{
    ++mNumAnswerStackFrame;

    // MOZ_ASSERT((PTestHangs::HANG != state()) == (mNumAnswerStackFrame == 1));

    if (mNumAnswerStackFrame == 1) {
        if (CallStackFrame()) {
          fail("should have timed out!");
        }
    } else if (mNumAnswerStackFrame == 2) {
        // minimum possible, 2 ms.  We want to detecting a hang to race
        // with the reply coming in, as reliably as possible
        SetReplyTimeoutMs(2);

        if (CallHang())
            fail("should have timed out!");
    } else {
        fail("unexpected state");
    }

    return IPC_OK();
}