ipc/ipdl/test/cxx/TestHangs.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #ifndef mozilla__ipdltest_TestHangs_h
     2 #define mozilla__ipdltest_TestHangs_h 1
     4 #include "mozilla/_ipdltest/IPDLUnitTests.h"
     6 #include "mozilla/_ipdltest/PTestHangsParent.h"
     7 #include "mozilla/_ipdltest/PTestHangsChild.h"
     9 namespace mozilla {
    10 namespace _ipdltest {
    13 class TestHangsParent :
    14     public PTestHangsParent
    15 {
    16 public:
    17     TestHangsParent();
    18     virtual ~TestHangsParent();
    20     static bool RunTestInProcesses() { return true; }
    22     // FIXME/bug 703320 Disabled because parent kills child proc, not
    23     //                  clear how that should work in threads.
    24     static bool RunTestInThreads() { return false; }
    26     void Main();
    28 protected:
    29     virtual bool ShouldContinueFromReplyTimeout() MOZ_OVERRIDE;
    31     virtual bool RecvNonce() {
    32         return true;
    33     }
    35     virtual bool AnswerStackFrame() MOZ_OVERRIDE;
    37     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    38     {
    39         if (AbnormalShutdown != why)
    40             fail("unexpected destruction!");  
    41         passed("ok");
    42         QuitParent();
    43     }
    45     void CleanUp();
    47     bool mDetectedHang;
    48 };
    51 class TestHangsChild :
    52     public PTestHangsChild
    53 {
    54 public:
    55     TestHangsChild();
    56     virtual ~TestHangsChild();
    58 protected:
    59     virtual bool RecvStart() MOZ_OVERRIDE {
    60         if (!SendNonce())
    61             fail("sending Nonce");
    62         return true;
    63     }
    65     virtual bool AnswerStackFrame() MOZ_OVERRIDE
    66     {
    67         if (CallStackFrame())
    68             fail("should have failed");
    69         return true;
    70     }
    72     virtual bool AnswerHang() MOZ_OVERRIDE;
    74     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    75     {
    76         if (AbnormalShutdown != why)
    77             fail("unexpected destruction!");
    78         QuitChild();
    79     }
    80 };
    83 } // namespace _ipdltest
    84 } // namespace mozilla
    87 #endif // ifndef mozilla__ipdltest_TestHangs_h

mercurial