ipc/ipdl/test/cxx/TestInterruptRaces.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 #ifndef mozilla__ipdltest_TestInterruptRaces_h
     2 #define mozilla__ipdltest_TestInterruptRaces_h
     4 #include "mozilla/_ipdltest/IPDLUnitTests.h"
     6 #include "mozilla/_ipdltest/PTestInterruptRacesParent.h"
     7 #include "mozilla/_ipdltest/PTestInterruptRacesChild.h"
     9 namespace mozilla {
    10 namespace _ipdltest {
    12 mozilla::ipc::RacyInterruptPolicy
    13 MediateRace(const mozilla::ipc::MessageChannel::Message& parent,
    14             const mozilla::ipc::MessageChannel::Message& child);
    16 class TestInterruptRacesParent :
    17     public PTestInterruptRacesParent
    18 {
    19 public:
    20     TestInterruptRacesParent() : mHasReply(false),
    21                            mChildHasReply(false),
    22                            mAnsweredParent(false)
    23     { }
    24     virtual ~TestInterruptRacesParent() { }
    26     static bool RunTestInProcesses() { return true; }
    27     static bool RunTestInThreads() { return true; }
    29     void Main();
    31 protected:
    32     virtual bool
    33     RecvStartRace() MOZ_OVERRIDE;
    35     virtual bool
    36     AnswerRace(bool* hasRace) MOZ_OVERRIDE;
    38     virtual bool
    39     AnswerStackFrame() MOZ_OVERRIDE;
    41     virtual bool
    42     AnswerStackFrame3() MOZ_OVERRIDE;
    44     virtual bool
    45     AnswerParent() MOZ_OVERRIDE;
    47     virtual bool
    48     RecvGetAnsweredParent(bool* answeredParent) MOZ_OVERRIDE;
    50     virtual mozilla::ipc::RacyInterruptPolicy
    51     MediateInterruptRace(const Message& parent, const Message& child) MOZ_OVERRIDE
    52     {
    53         return MediateRace(parent, child);
    54     }
    56     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
    57     {
    58         if (NormalShutdown != why)
    59             fail("unexpected destruction!");
    60         if (!(mHasReply && mChildHasReply))
    61             fail("both sides should have replies!");
    62         passed("ok");
    63         QuitParent();
    64     }
    66 private:
    67     void OnRaceTime();
    69     void Test2();
    70     void Test3();
    72     bool mHasReply;
    73     bool mChildHasReply;
    74     bool mAnsweredParent;
    75 };
    78 class TestInterruptRacesChild :
    79     public PTestInterruptRacesChild
    80 {
    81 public:
    82     TestInterruptRacesChild() : mHasReply(false) { }
    83     virtual ~TestInterruptRacesChild() { }
    85 protected:
    86     virtual bool
    87     RecvStart() MOZ_OVERRIDE;
    89     virtual bool
    90     AnswerRace(bool* hasRace) MOZ_OVERRIDE;
    92     virtual bool
    93     AnswerStackFrame() MOZ_OVERRIDE;
    95     virtual bool
    96     AnswerStackFrame3() MOZ_OVERRIDE;
    98     virtual bool
    99     RecvWakeup() MOZ_OVERRIDE;
   101     virtual bool
   102     RecvWakeup3() MOZ_OVERRIDE;
   104     virtual bool
   105     AnswerChild() MOZ_OVERRIDE;
   107     virtual mozilla::ipc::RacyInterruptPolicy
   108     MediateInterruptRace(const Message& parent, const Message& child) MOZ_OVERRIDE
   109     {
   110         return MediateRace(parent, child);
   111     }
   113     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE
   114     {
   115         if (NormalShutdown != why)
   116             fail("unexpected destruction!");
   117         QuitChild();
   118     }
   120 private:
   121     bool mHasReply;
   122 };
   125 } // namespace _ipdltest
   126 } // namespace mozilla
   129 #endif // ifndef mozilla__ipdltest_TestInterruptRaces_h

mercurial