MCPcopy Create free account
hub / github.com/DISTORTEC/distortos / run_

Method run_

test/Thread/ThreadSleepUntilTestCase.cpp:96–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94+---------------------------------------------------------------------------------------------------------------------*/
95
96bool ThreadSleepUntilTestCase::run_() const
97{
98 const auto allocatedMemory = mallinfo().uordblks;
99
100 for (const auto& phase : priorityTestPhases)
101 {
102 {
103 SequenceAsserter sequenceAsserter;
104 std::array<TickClock::duration, totalThreads> timePointDeviations {{}};
105 std::array<int, totalThreads> sharedRets {{}};
106 const auto now = TickClock::now();
107
108 std::array<DynamicThread, totalThreads> threads
109 {{
110 makeTestThread(now, phase.first[phase.second[0]], sequenceAsserter, timePointDeviations[0],
111 sharedRets[0]),
112 makeTestThread(now, phase.first[phase.second[1]], sequenceAsserter, timePointDeviations[1],
113 sharedRets[1]),
114 makeTestThread(now, phase.first[phase.second[2]], sequenceAsserter, timePointDeviations[2],
115 sharedRets[2]),
116 makeTestThread(now, phase.first[phase.second[3]], sequenceAsserter, timePointDeviations[3],
117 sharedRets[3]),
118 makeTestThread(now, phase.first[phase.second[4]], sequenceAsserter, timePointDeviations[4],
119 sharedRets[4]),
120 makeTestThread(now, phase.first[phase.second[5]], sequenceAsserter, timePointDeviations[5],
121 sharedRets[5]),
122 makeTestThread(now, phase.first[phase.second[6]], sequenceAsserter, timePointDeviations[6],
123 sharedRets[6]),
124 makeTestThread(now, phase.first[phase.second[7]], sequenceAsserter, timePointDeviations[7],
125 sharedRets[7]),
126 }};
127
128 {
129 const InterruptMaskingLock interruptMaskingLock;
130
131 for (auto& thread : threads)
132 thread.start();
133 }
134
135 bool invalidState {};
136 for (const auto& thread : threads)
137 if (thread.getState() != ThreadState::sleeping)
138 invalidState = true;
139
140 for (auto& thread : threads)
141 thread.join();
142
143 if (invalidState != false)
144 return false;
145
146 if (sequenceAsserter.assertSequence(totalThreads) == false)
147 return false;
148
149 for (const auto& timePointDeviation : timePointDeviations)
150 if (timePointDeviation != TickClock::duration{})
151 return false;
152
153 for (const auto& sharedRet : sharedRets)

Callers

nothing calls this directly

Calls 5

assertSequenceMethod · 0.80
makeTestThreadFunction · 0.70
startMethod · 0.45
getStateMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected