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

Method run_

test/Thread/ThreadOperationsTestCase.cpp:429–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427+---------------------------------------------------------------------------------------------------------------------*/
428
429bool ThreadOperationsTestCase::run_() const
430{
431 constexpr auto phase1ExpectedContextSwitchCount = 2;
432 constexpr auto phase2ExpectedContextSwitchCount = 0;
433#ifdef DISTORTOS_THREAD_DETACH_ENABLE
434 constexpr auto phase3ExpectedContextSwitchCount = 11;
435 constexpr auto phase4ExpectedContextSwitchCount = 6;
436#else // !def DISTORTOS_THREAD_DETACH_ENABLE
437 constexpr auto phase3ExpectedContextSwitchCount = 0;
438 constexpr auto phase4ExpectedContextSwitchCount = 2;
439#endif // !def DISTORTOS_THREAD_DETACH_ENABLE
440 constexpr auto phase5ExpectedContextSwitchCount = 8;
441 constexpr auto expectedContextSwitchCount = phase1ExpectedContextSwitchCount + phase2ExpectedContextSwitchCount +
442 phase3ExpectedContextSwitchCount + phase4ExpectedContextSwitchCount + phase5ExpectedContextSwitchCount;
443
444 const auto allocatedMemory = mallinfo().uordblks;
445 const auto contextSwitchCount = statistics::getContextSwitchCount();
446
447 for (const auto& function : {phase1, phase2, phase3, phase4, phase5})
448 {
449 const auto ret = function();
450 if (ret != true)
451 return ret;
452
453 if (mallinfo().uordblks != allocatedMemory) // dynamic memory must be deallocated after each test phase
454 return false;
455 }
456
457 if (statistics::getContextSwitchCount() - contextSwitchCount != expectedContextSwitchCount)
458 return false;
459
460 return true;
461}
462
463} // namespace test
464

Callers

nothing calls this directly

Calls 2

getContextSwitchCountFunction · 0.85
functionFunction · 0.85

Tested by

no test coverage detected