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

Method run_

test/Queue/FifoQueuePriorityTestCase.cpp:216–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214+---------------------------------------------------------------------------------------------------------------------*/
215
216bool FifoQueuePriorityTestCase::run_() const
217{
218 const auto allocatedMemory = mallinfo().uordblks;
219 const auto contextSwitchCount = statistics::getContextSwitchCount();
220 std::remove_const<decltype(contextSwitchCount)>::type expectedContextSwitchCount {};
221 constexpr size_t fifoQueueTypes {4};
222
223 for (const auto& stage : stages)
224 for (const auto& phase : priorityTestPhases)
225 for (const auto dynamic : falseTrue)
226 for (const auto raw : falseTrue)
227 {
228 {
229 const auto queueWrapper = makeQueueWrapper<totalThreads>(dynamic, raw, true);
230 SequenceAsserter sequenceAsserter;
231
232 const auto& threadFunction = std::get<0>(stage);
233 std::array<DynamicThread, totalThreads> threads
234 {{
235 makeTestThread(threadFunction, 0, phase.first[phase.second[0]], sequenceAsserter,
236 *queueWrapper),
237 makeTestThread(threadFunction, 1, phase.first[phase.second[1]], sequenceAsserter,
238 *queueWrapper),
239 makeTestThread(threadFunction, 2, phase.first[phase.second[2]], sequenceAsserter,
240 *queueWrapper),
241 makeTestThread(threadFunction, 3, phase.first[phase.second[3]], sequenceAsserter,
242 *queueWrapper),
243 makeTestThread(threadFunction, 4, phase.first[phase.second[4]], sequenceAsserter,
244 *queueWrapper),
245 makeTestThread(threadFunction, 5, phase.first[phase.second[5]], sequenceAsserter,
246 *queueWrapper),
247 makeTestThread(threadFunction, 6, phase.first[phase.second[6]], sequenceAsserter,
248 *queueWrapper),
249 makeTestThread(threadFunction, 7, phase.first[phase.second[7]], sequenceAsserter,
250 *queueWrapper),
251 }};
252
253 // execute Prepare
254 if (std::get<1>(stage) != nullptr)
255 std::get<1>(stage)(*queueWrapper);
256
257 bool result {true};
258
259 for (auto& thread : threads)
260 {
261 thread.start();
262 // 2 context switches: "into" the thread and "back" to main thread when test thread blocks
263 // on FIFO queue
264 expectedContextSwitchCount += 2;
265 if (statistics::getContextSwitchCount() - contextSwitchCount != expectedContextSwitchCount)
266 result = false;
267 }
268
269 if (sequenceAsserter.assertSequence(totalThreads) == false)
270 result = false;
271
272 for (size_t i = 0; i < threads.size(); ++i)
273 {

Callers

nothing calls this directly

Calls 6

getContextSwitchCountFunction · 0.85
assertSequenceMethod · 0.80
makeTestThreadFunction · 0.70
startMethod · 0.45
sizeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected