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.

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

mercurial