ipc/ipdl/test/cxx/TestHangs.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/ipdl/test/cxx/TestHangs.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,87 @@
     1.4 +#ifndef mozilla__ipdltest_TestHangs_h
     1.5 +#define mozilla__ipdltest_TestHangs_h 1
     1.6 +
     1.7 +#include "mozilla/_ipdltest/IPDLUnitTests.h"
     1.8 +
     1.9 +#include "mozilla/_ipdltest/PTestHangsParent.h"
    1.10 +#include "mozilla/_ipdltest/PTestHangsChild.h"
    1.11 +
    1.12 +namespace mozilla {
    1.13 +namespace _ipdltest {
    1.14 +
    1.15 +
    1.16 +class TestHangsParent :
    1.17 +    public PTestHangsParent
    1.18 +{
    1.19 +public:
    1.20 +    TestHangsParent();
    1.21 +    virtual ~TestHangsParent();
    1.22 +
    1.23 +    static bool RunTestInProcesses() { return true; }
    1.24 +
    1.25 +    // FIXME/bug 703320 Disabled because parent kills child proc, not
    1.26 +    //                  clear how that should work in threads.
    1.27 +    static bool RunTestInThreads() { return false; }
    1.28 +
    1.29 +    void Main();
    1.30 +
    1.31 +protected:
    1.32 +    virtual bool ShouldContinueFromReplyTimeout() MOZ_OVERRIDE;
    1.33 +
    1.34 +    virtual bool RecvNonce() {
    1.35 +        return true;
    1.36 +    }
    1.37 +
    1.38 +    virtual bool AnswerStackFrame() MOZ_OVERRIDE;
    1.39 +
    1.40 +    virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    1.41 +    {
    1.42 +        if (AbnormalShutdown != why)
    1.43 +            fail("unexpected destruction!");  
    1.44 +        passed("ok");
    1.45 +        QuitParent();
    1.46 +    }
    1.47 +
    1.48 +    void CleanUp();
    1.49 +
    1.50 +    bool mDetectedHang;
    1.51 +};
    1.52 +
    1.53 +
    1.54 +class TestHangsChild :
    1.55 +    public PTestHangsChild
    1.56 +{
    1.57 +public:
    1.58 +    TestHangsChild();
    1.59 +    virtual ~TestHangsChild();
    1.60 +
    1.61 +protected:
    1.62 +    virtual bool RecvStart() MOZ_OVERRIDE {
    1.63 +        if (!SendNonce())
    1.64 +            fail("sending Nonce");
    1.65 +        return true;
    1.66 +    }
    1.67 +
    1.68 +    virtual bool AnswerStackFrame() MOZ_OVERRIDE
    1.69 +    {
    1.70 +        if (CallStackFrame())
    1.71 +            fail("should have failed");
    1.72 +        return true;
    1.73 +    }
    1.74 +
    1.75 +    virtual bool AnswerHang() MOZ_OVERRIDE;
    1.76 +
    1.77 +    virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    1.78 +    {
    1.79 +        if (AbnormalShutdown != why)
    1.80 +            fail("unexpected destruction!");
    1.81 +        QuitChild();
    1.82 +    }
    1.83 +};
    1.84 +
    1.85 +
    1.86 +} // namespace _ipdltest
    1.87 +} // namespace mozilla
    1.88 +
    1.89 +
    1.90 +#endif // ifndef mozilla__ipdltest_TestHangs_h

mercurial