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

Function phase1

test/Queue/QueueOperationsTestCase.cpp:132–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130 */
131
132bool phase1()
133{
134 for (const auto dynamic : falseTrue)
135 for (const auto raw : falseTrue)
136 for (const auto fifo : falseTrue)
137 {
138 // size 0, so queue is both full and empty at the same time
139 const auto queueWrapper = makeQueueWrapper<0>(dynamic, raw, fifo);
140 const uint8_t constPriority {};
141 const OperationCountingType constTestValue {};
142 uint8_t nonConstPriority {};
143 OperationCountingType nonConstTestValue {};
144
145 {
146 const auto ret = testTryPushWhenFull(*queueWrapper);
147 if (ret != true)
148 return ret;
149 }
150
151 {
152 // queue is both full and empty, so tryPush(..., T&&) should fail immediately
153 OperationCountingType::resetCounters();
154 waitForNextTick();
155 const auto start = TickClock::now();
156 // 1 construction, 1 destruction
157 const auto ret = queueWrapper->tryPush(constPriority, OperationCountingType{});
158 if (ret != EAGAIN || start != TickClock::now() ||
159 queueWrapper->checkCounters(1, 0, 0, 1, 0, 0, 0) != true)
160 return false;
161 }
162
163 {
164 OperationCountingType::resetCounters();
165 waitForNextTick();
166
167 const auto contextSwitchCount = statistics::getContextSwitchCount();
168
169 // queue is both full and empty, so tryPushFor(..., const T&) should time-out at expected time
170 const auto start = TickClock::now();
171 const auto ret = queueWrapper->tryPushFor(singleDuration, constPriority, constTestValue);
172 const auto realDuration = TickClock::now() - start;
173 if (ret != ETIMEDOUT || realDuration != singleDuration + decltype(singleDuration){1} ||
174 queueWrapper->checkCounters(0, 0, 0, 0, 0, 0, 0) != true ||
175 statistics::getContextSwitchCount() - contextSwitchCount !=
176 phase1TryForUntilContextSwitchCount)
177 return false;
178 }
179
180 {
181 OperationCountingType::resetCounters();
182 waitForNextTick();
183
184 const auto contextSwitchCount = statistics::getContextSwitchCount();
185
186 // queue is both full and empty, so tryPushFor(..., T&&) should time-out at expected time
187 const auto start = TickClock::now();
188 // 1 construction, 1 destruction
189 const auto ret = queueWrapper->tryPushFor(singleDuration, constPriority, OperationCountingType{});

Callers

nothing calls this directly

Calls 13

testTryPushWhenFullFunction · 0.85
waitForNextTickFunction · 0.85
getContextSwitchCountFunction · 0.85
testTryPopWhenEmptyFunction · 0.85
tryPushMethod · 0.45
checkCountersMethod · 0.45
tryPushForMethod · 0.45
tryPushUntilMethod · 0.45
tryPopForMethod · 0.45
tryPopUntilMethod · 0.45
tryEmplaceMethod · 0.45
tryEmplaceForMethod · 0.45

Tested by

no test coverage detected