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

Function phase3

test/Queue/QueueOperationsTestCase.cpp:637–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635 */
636
637bool phase3()
638{
639 for (const auto dynamic : falseTrue)
640 for (const auto raw : falseTrue)
641 for (const auto fifo : falseTrue)
642 {
643 const auto queueWrapper = makeQueueWrapper<1>(dynamic, raw, fifo);
644 uint8_t sharedMagicPriority {};
645 OperationCountingType sharedMagicValue {};
646 auto softwareTimer = makeStaticSoftwareTimer(
647 [&queueWrapper, &sharedMagicPriority, &sharedMagicValue]()
648 {
649 queueWrapper->tryPush(sharedMagicPriority, sharedMagicValue);
650 });
651
652 {
653 OperationCountingType::resetCounters();
654 waitForNextTick();
655
656 const auto contextSwitchCount = statistics::getContextSwitchCount();
657 const auto wakeUpTimePoint = TickClock::now() + longDuration;
658 sharedMagicPriority = 0x93;
659 // 1 construction, 1 move assignment, 1 destruction
660 sharedMagicValue = OperationCountingType{0x2f5be1a4};
661 softwareTimer.start(wakeUpTimePoint); // in timer: 1 copy construction
662
663 // queue is currently empty, but pop() should succeed at expected time
664 uint8_t priority {};
665 OperationCountingType testValue {}; // 1 construction
666 const auto ret = queueWrapper->pop(priority, testValue); // 1 swap, 1 destruction
667 const auto wokenUpTimePoint = TickClock::now();
668 if (ret != 0 || wakeUpTimePoint != wokenUpTimePoint ||
669 queueWrapper->check(sharedMagicPriority, sharedMagicValue, priority, testValue) == false ||
670 queueWrapper->checkCounters(2, 1, 0, 2, 0, 1, 1) != true ||
671 statistics::getContextSwitchCount() - contextSwitchCount !=
672 phase34SoftwareTimerContextSwitchCount)
673 return false;
674 }
675
676 {
677 const auto ret = testTryPopWhenEmpty(*queueWrapper);
678 if (ret != true)
679 return ret;
680 }
681
682 {
683 OperationCountingType::resetCounters();
684 waitForNextTick();
685
686 const auto contextSwitchCount = statistics::getContextSwitchCount();
687 const auto wakeUpTimePoint = TickClock::now() + longDuration;
688 sharedMagicPriority = 0x01;
689 // 1 construction, 1 move assignment, 1 destruction
690 sharedMagicValue = OperationCountingType{0xc1fe105a};
691 softwareTimer.start(wakeUpTimePoint); // in timer: 1 copy construction
692
693 // queue is currently empty, but tryPopFor() should succeed at expected time
694 uint8_t priority {};

Callers

nothing calls this directly

Calls 11

makeStaticSoftwareTimerFunction · 0.85
waitForNextTickFunction · 0.85
getContextSwitchCountFunction · 0.85
testTryPopWhenEmptyFunction · 0.85
tryPushMethod · 0.45
startMethod · 0.45
popMethod · 0.45
checkMethod · 0.45
checkCountersMethod · 0.45
tryPopForMethod · 0.45
tryPopUntilMethod · 0.45

Tested by

no test coverage detected