| 150 | */ |
| 151 | |
| 152 | bool phase2() |
| 153 | { |
| 154 | Semaphore semaphore {1}; |
| 155 | |
| 156 | { |
| 157 | // semaphore is unlocked, so tryWait() must succeed immediately |
| 158 | waitForNextTick(); |
| 159 | const auto start = TickClock::now(); |
| 160 | const auto ret = semaphore.tryWait(); |
| 161 | if (ret != 0 || start != TickClock::now() || semaphore.getValue() != 0) |
| 162 | return false; |
| 163 | } |
| 164 | |
| 165 | { |
| 166 | const auto ret = testTryWaitWhenLocked(semaphore); |
| 167 | if (ret != true) |
| 168 | return ret; |
| 169 | } |
| 170 | |
| 171 | { |
| 172 | const auto ret = testPost(semaphore); |
| 173 | if (ret != true) |
| 174 | return ret; |
| 175 | } |
| 176 | |
| 177 | { |
| 178 | // semaphore is unlocked, so tryWaitFor() should succeed immediately |
| 179 | waitForNextTick(); |
| 180 | const auto start = TickClock::now(); |
| 181 | const auto ret = semaphore.tryWaitFor(singleDuration); |
| 182 | if (ret != 0 || start != TickClock::now() || semaphore.getValue() != 0) |
| 183 | return false; |
| 184 | } |
| 185 | |
| 186 | { |
| 187 | const auto ret = testTryWaitWhenLocked(semaphore); |
| 188 | if (ret != true) |
| 189 | return ret; |
| 190 | } |
| 191 | |
| 192 | { |
| 193 | const auto ret = testPost(semaphore); |
| 194 | if (ret != true) |
| 195 | return ret; |
| 196 | } |
| 197 | |
| 198 | { |
| 199 | // semaphore is unlocked, so tryWaitUntil() should succeed immediately |
| 200 | waitForNextTick(); |
| 201 | const auto start = TickClock::now(); |
| 202 | const auto ret = semaphore.tryWaitUntil(start + singleDuration); |
| 203 | if (ret != 0 || start != TickClock::now() || semaphore.getValue() != 0) |
| 204 | return false; |
| 205 | } |
| 206 | |
| 207 | { |
| 208 | const auto ret = testTryWaitWhenLocked(semaphore); |
| 209 | if (ret != true) |
nothing calls this directly
no test coverage detected