Home | History | Annotate | Download | only in unit

Lines Matching defs:bin

4 do_fill_test(cache_bin_t *bin, cache_bin_info_t *info, void **ptrs,
9 assert_true(cache_bin_ncached_get_local(bin, info) == 0, "");
11 cache_bin_init_ptr_array_for_fill(bin, info, &arr, nfill_attempt);
15 cache_bin_finish_fill(bin, info, &arr, nfill_succeed);
16 expect_true(cache_bin_ncached_get_local(bin, info) == nfill_succeed,
18 cache_bin_low_water_set(bin);
21 ptr = cache_bin_alloc(bin, &success);
25 expect_true(cache_bin_low_water_get(bin, info)
28 expect_true(cache_bin_ncached_get_local(bin, info) == 0, "");
29 expect_true(cache_bin_low_water_get(bin, info) == 0, "");
33 do_flush_test(cache_bin_t *bin, cache_bin_info_t *info, void **ptrs,
36 assert_true(cache_bin_ncached_get_local(bin, info) == 0, "");
39 success = cache_bin_dalloc_easy(bin, &ptrs[i]);
44 cache_bin_init_ptr_array_for_flush(bin, info, &arr, nflush);
48 cache_bin_finish_flush(bin, info, &arr, nflush);
50 expect_true(cache_bin_ncached_get_local(bin, info) == nfill - nflush,
52 while (cache_bin_ncached_get_local(bin, info) > 0) {
53 cache_bin_alloc(bin, &success);
58 do_batch_alloc_test(cache_bin_t *bin, cache_bin_info_t *info, void **ptrs,
60 assert_true(cache_bin_ncached_get_local(bin, info) == 0, "");
62 cache_bin_init_ptr_array_for_fill(bin, info, &arr, nfill);
66 cache_bin_finish_fill(bin, info, &arr, nfill);
67 assert_true(cache_bin_ncached_get_local(bin, info) == nfill, "");
68 cache_bin_low_water_set(bin);
71 size_t n = cache_bin_alloc_batch(bin, batch, out);
76 expect_true(cache_bin_low_water_get(bin, info) == nfill -
78 while (cache_bin_ncached_get_local(bin, info) > 0) {
80 cache_bin_alloc(bin, &success);
86 test_bin_init(cache_bin_t *bin, cache_bin_info_t *info) {
95 cache_bin_init(bin, info, mem, &cur_offset);
107 cache_bin_t bin;
108 test_bin_init(&bin, &info);
112 expect_true(cache_bin_ncached_get_local(&bin, &info) == 0, "");
113 expect_true(cache_bin_low_water_get(&bin, &info) == 0, "");
115 ptr = cache_bin_alloc_easy(&bin, &success);
119 ptr = cache_bin_alloc(&bin, &success);
124 * We allocate one more item than ncached_max, so we can test cache bin
130 expect_true(cache_bin_ncached_get_local(&bin, &info) == i, "");
131 success = cache_bin_dalloc_easy(&bin, &ptrs[i]);
133 "Should be able to dalloc into a non-full cache bin.");
134 expect_true(cache_bin_low_water_get(&bin, &info) == 0,
137 expect_true(cache_bin_ncached_get_local(&bin, &info) == ncached_max,
139 success = cache_bin_dalloc_easy(&bin, &ptrs[ncached_max]);
140 expect_false(success, "Shouldn't be able to dalloc into a full bin.");
142 cache_bin_low_water_set(&bin);
145 expect_true(cache_bin_low_water_get(&bin, &info)
147 expect_true(cache_bin_ncached_get_local(&bin, &info)
153 ptr = cache_bin_alloc_easy(&bin, &success);
156 expect_true(cache_bin_low_water_get(&bin, &info)
158 expect_true(cache_bin_ncached_get_local(&bin, &info)
162 ptr = cache_bin_alloc(&bin, &success);
166 expect_true(cache_bin_low_water_get(&bin, &info)
168 expect_true(cache_bin_ncached_get_local(&bin, &info)
172 expect_true(cache_bin_ncached_get_local(&bin, &info) == 0, "");
173 ptr = cache_bin_alloc_easy(&bin, &success);
176 ptr = cache_bin_alloc(&bin, &success);
181 cache_bin_dalloc_easy(&bin, &ptrs[i]);
183 cache_bin_low_water_set(&bin);
186 cache_bin_dalloc_easy(&bin, &ptrs[i]);
188 expect_true(cache_bin_ncached_get_local(&bin, &info) == ncached_max,
195 ptr = cache_bin_alloc_easy(&bin, &success);
200 ptr = cache_bin_alloc_easy(&bin, &success);
205 while (cache_bin_ncached_get_local(&bin, &info)) {
206 cache_bin_alloc(&bin, &success);
212 do_fill_test(&bin, &info, ptrs, ncached_max, ncached_max, ncached_max);
214 do_fill_test(&bin, &info, ptrs, ncached_max, ncached_max,
217 do_fill_test(&bin, &info, ptrs, ncached_max, ncached_max, 0);
220 do_fill_test(&bin, &info, ptrs, ncached_max, ncached_max / 2,
223 do_fill_test(&bin, &info, ptrs, ncached_max, ncached_max / 2,
226 do_fill_test(&bin, &info, ptrs, ncached_max, ncached_max / 2, 0);
228 do_flush_test(&bin, &info, ptrs, ncached_max, ncached_max);
229 do_flush_test(&bin, &info, ptrs, ncached_max, ncached_max / 2);
230 do_flush_test(&bin, &info, ptrs, ncached_max, 0);
231 do_flush_test(&bin, &info, ptrs, ncached_max / 2, ncached_max / 2);
232 do_flush_test(&bin, &info, ptrs, ncached_max / 2, ncached_max / 4);
233 do_flush_test(&bin, &info, ptrs, ncached_max / 2, 0);
235 do_batch_alloc_test(&bin, &info, ptrs, ncached_max, ncached_max);
236 do_batch_alloc_test(&bin, &info, ptrs, ncached_max, ncached_max * 2);
237 do_batch_alloc_test(&bin, &info, ptrs, ncached_max, ncached_max / 2);
238 do_batch_alloc_test(&bin, &info, ptrs, ncached_max, 2);
239 do_batch_alloc_test(&bin, &info, ptrs, ncached_max, 1);
240 do_batch_alloc_test(&bin, &info, ptrs, ncached_max, 0);
241 do_batch_alloc_test(&bin, &info, ptrs, ncached_max / 2,
243 do_batch_alloc_test(&bin, &info, ptrs, ncached_max / 2, ncached_max);
244 do_batch_alloc_test(&bin, &info, ptrs, ncached_max / 2,
246 do_batch_alloc_test(&bin, &info, ptrs, ncached_max / 2, 2);
247 do_batch_alloc_test(&bin, &info, ptrs, ncached_max / 2, 1);
248 do_batch_alloc_test(&bin, &info, ptrs, ncached_max / 2, 0);
249 do_batch_alloc_test(&bin, &info, ptrs, 2, ncached_max);
250 do_batch_alloc_test(&bin, &info, ptrs, 2, 2);
251 do_batch_alloc_test(&bin, &info, ptrs, 2, 1);
252 do_batch_alloc_test(&bin, &info, ptrs, 2, 0);
253 do_batch_alloc_test(&bin, &info, ptrs, 1, 2);
254 do_batch_alloc_test(&bin, &info, ptrs, 1, 1);
255 do_batch_alloc_test(&bin, &info, ptrs, 1, 0);
256 do_batch_alloc_test(&bin, &info, ptrs, 0, 2);
257 do_batch_alloc_test(&bin, &info, ptrs, 0, 1);
258 do_batch_alloc_test(&bin, &info, ptrs, 0, 0);
265 do_flush_stashed_test(cache_bin_t *bin, cache_bin_info_t *info, void **ptrs,
267 expect_true(cache_bin_ncached_get_local(bin, info) == 0,
268 "Bin not empty");
269 expect_true(cache_bin_nstashed_get_local(bin, info) == 0,
270 "Bin not empty");
276 ret = cache_bin_dalloc_easy(bin, &ptrs[i]);
279 expect_true(cache_bin_ncached_get_local(bin, info) == nfill,
284 ret = cache_bin_stash(bin, &ptrs[i + nfill]);
287 expect_true(cache_bin_nstashed_get_local(bin, info) == nstash,
291 ret = cache_bin_dalloc_easy(bin, &ptrs[0]);
292 expect_false(ret, "Should not dalloc into a full bin");
293 ret = cache_bin_stash(bin, &ptrs[0]);
294 expect_false(ret, "Should not stash into a full bin");
299 void *ptr = cache_bin_alloc(bin, &ret);
305 expect_true(cache_bin_ncached_get_local(bin, info) == 0,
307 expect_true(cache_bin_nstashed_get_local(bin, info) == nstash,
310 cache_bin_alloc(bin, &ret);
314 cache_bin_finish_flush_stashed(bin, info);
315 expect_true(cache_bin_ncached_get_local(bin, info) == 0,
317 expect_true(cache_bin_nstashed_get_local(bin, info) == 0,
320 cache_bin_alloc(bin, &ret);
321 expect_false(ret, "Should not alloc from empty bin");
327 cache_bin_t bin;
330 test_bin_init(&bin, &info);
340 expect_true(cache_bin_ncached_get_local(&bin, &info) ==
342 expect_true(cache_bin_nstashed_get_local(&bin, &info) == i / 2,
345 cache_bin_dalloc_easy(&bin, &ptrs[i]);
347 ret = cache_bin_stash(&bin, &ptrs[i]);
349 "non-full cache bin");
352 ret = cache_bin_dalloc_easy(&bin, &ptrs[0]);
353 expect_false(ret, "Should not dalloc into a full cache bin");
354 ret = cache_bin_stash(&bin, &ptrs[0]);
355 expect_false(ret, "Should not stash into a full cache bin");
357 void *ptr = cache_bin_alloc(&bin, &ret);
365 expect_true(cache_bin_nstashed_get_local(&bin, &info) ==
370 test_bin_init(&bin, &info);
371 do_flush_stashed_test(&bin, &info, ptrs, ncached_max, 0);
372 do_flush_stashed_test(&bin, &info, ptrs, 0, ncached_max);
373 do_flush_stashed_test(&bin, &info, ptrs, ncached_max / 2, ncached_max / 2);
374 do_flush_stashed_test(&bin, &info, ptrs, ncached_max / 4, ncached_max / 2);
375 do_flush_stashed_test(&bin, &info, ptrs, ncached_max / 2, ncached_max / 4);
376 do_flush_stashed_test(&bin, &info, ptrs, ncached_max / 4, ncached_max / 4);