This test case checks that the CCheckQueue works properly * with each specified size_t Checks pushed. */
| 147 | * with each specified size_t Checks pushed. |
| 148 | */ |
| 149 | static void Correct_Queue_range(std::vector<size_t> range) |
| 150 | { |
| 151 | auto small_queue = std::unique_ptr<Correct_Queue>(new Correct_Queue {QUEUE_BATCH_SIZE}); |
| 152 | boost::thread_group tg; |
| 153 | for (auto x = 0; x < nScriptCheckThreads; ++x) { |
| 154 | tg.create_thread([&]{small_queue->Thread();}); |
| 155 | } |
| 156 | // Make vChecks here to save on malloc (this test can be slow...) |
| 157 | std::vector<FakeCheckCheckCompletion> vChecks; |
| 158 | for (auto i : range) { |
| 159 | size_t total = i; |
| 160 | FakeCheckCheckCompletion::n_calls = 0; |
| 161 | CCheckQueueControl<FakeCheckCheckCompletion> control(small_queue.get()); |
| 162 | while (total) { |
| 163 | vChecks.resize(std::min(total, (size_t) InsecureRandRange(10))); |
| 164 | total -= vChecks.size(); |
| 165 | control.Add(vChecks); |
| 166 | } |
| 167 | BOOST_REQUIRE(control.Wait()); |
| 168 | if (FakeCheckCheckCompletion::n_calls != i) { |
| 169 | BOOST_REQUIRE_EQUAL(FakeCheckCheckCompletion::n_calls, i); |
| 170 | BOOST_TEST_MESSAGE("Failure on trial " << i << " expected, got " << FakeCheckCheckCompletion::n_calls); |
| 171 | } |
| 172 | } |
| 173 | tg.interrupt_all(); |
| 174 | tg.join_all(); |
| 175 | } |
| 176 | |
| 177 | /** Test that 0 checks is correct |
| 178 | */ |
no test coverage detected