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

Function phase4

test/Queue/QueueOperationsTestCase.cpp:761–1032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759 */
760
761bool phase4()
762{
763 for (const auto dynamic : falseTrue)
764 for (const auto raw : falseTrue)
765 for (const auto fifo : falseTrue)
766 {
767 const auto queueWrapper = makeQueueWrapper<1>(dynamic, raw, fifo);
768 uint8_t receivedPriority {};
769 OperationCountingType receivedTestValue {};
770 auto softwareTimer = makeStaticSoftwareTimer(
771 [&queueWrapper, &receivedPriority, &receivedTestValue]()
772 {
773 queueWrapper->tryPop(receivedPriority, receivedTestValue);
774 });
775
776 uint8_t currentMagicPriority {0xc9};
777 OperationCountingType currentMagicValue {0xa810b166};
778
779 {
780 // queue is not full, so push(..., const T&) must succeed immediately
781 OperationCountingType::resetCounters();
782 waitForNextTick();
783 const auto start = TickClock::now();
784 // 1 copy construction
785 const auto ret = queueWrapper->tryPush(currentMagicPriority, currentMagicValue);
786 if (ret != 0 || start != TickClock::now() ||
787 queueWrapper->checkCounters(0, 1, 0, 0, 0, 0, 0) != true)
788 return false;
789 }
790
791 {
792 OperationCountingType::resetCounters();
793 waitForNextTick();
794
795 const auto contextSwitchCount = statistics::getContextSwitchCount();
796 const auto wakeUpTimePoint = TickClock::now() + longDuration;
797 softwareTimer.start(wakeUpTimePoint); // in timer: 1 swap, 1 destruction
798
799 // queue is currently full, but push(..., const T&) should succeed at expected time
800 const decltype(currentMagicPriority) expectedPriority {currentMagicPriority};
801 const decltype(currentMagicValue) expectedTestValue {currentMagicValue}; // 1 copy construction
802 currentMagicPriority = 0x96;
803 // 1 construction, 1 move assignment, 1 destruction
804 currentMagicValue = OperationCountingType{0xc9e7e479};
805 // 1 copy construction
806 const auto ret = queueWrapper->push(currentMagicPriority, currentMagicValue);
807 const auto wokenUpTimePoint = TickClock::now();
808 if (ret != 0 || wakeUpTimePoint != wokenUpTimePoint ||
809 queueWrapper->check(expectedPriority, expectedTestValue, receivedPriority,
810 receivedTestValue) == false ||
811 queueWrapper->checkCounters(1, 2, 0, 2, 0, 1, 1) != true ||
812 statistics::getContextSwitchCount() - contextSwitchCount !=
813 phase34SoftwareTimerContextSwitchCount)
814 return false;
815 }
816
817 {
818 OperationCountingType::resetCounters();

Callers

nothing calls this directly

Calls 14

makeStaticSoftwareTimerFunction · 0.85
waitForNextTickFunction · 0.85
getContextSwitchCountFunction · 0.85
tryPopMethod · 0.45
tryPushMethod · 0.45
checkCountersMethod · 0.45
startMethod · 0.45
pushMethod · 0.45
checkMethod · 0.45
tryPushForMethod · 0.45
tryPushUntilMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected