Lines Matching refs:table

81 test_bin_find_entry(struct lruhash* table)  in test_bin_find_entry()  argument
97 unit_assert( bin_find_entry(table, &bin, h, k, NULL) == NULL ); in test_bin_find_entry()
105 unit_assert( bin_find_entry(table, &bin, myhash(13), k, NULL) == NULL ); in test_bin_find_entry()
109 unit_assert( bin_find_entry(table, &bin, h, k2, NULL) == NULL ); in test_bin_find_entry()
112 unit_assert( bin_find_entry(table, &bin, h, k, NULL) == &k->entry ); in test_bin_find_entry()
118 unit_assert( bin_find_entry(table, &bin, h, k, NULL) == NULL ); in test_bin_find_entry()
130 unit_assert( bin_find_entry(table, &bin, myhash(13), k, NULL) == NULL ); in test_bin_find_entry()
134 unit_assert( bin_find_entry(table, &bin, h, k2, NULL) == NULL ); in test_bin_find_entry()
137 unit_assert( bin_find_entry(table, &bin, h, k, NULL) == &k->entry ); in test_bin_find_entry()
140 unit_assert( bin_find_entry(table, &bin, k4->entry.hash, k4, NULL) in test_bin_find_entry()
145 unit_assert( bin_find_entry(table, &bin, k4->entry.hash, k4, NULL) == NULL); in test_bin_find_entry()
151 unit_assert( bin_find_entry(table, &bin, h, k, NULL) == NULL ); in test_bin_find_entry()
162 static void test_lru(struct lruhash* table) in test_lru() argument
166 lock_quick_lock(&table->lock); in test_lru()
168 unit_assert( table->lru_start == NULL && table->lru_end == NULL); in test_lru()
169 lru_remove(table, &k->entry); in test_lru()
170 unit_assert( table->lru_start == NULL && table->lru_end == NULL); in test_lru()
173 lru_front(table, &k->entry); in test_lru()
174 unit_assert( table->lru_start == &k->entry && in test_lru()
175 table->lru_end == &k->entry); in test_lru()
177 lru_remove(table, &k->entry); in test_lru()
178 unit_assert( table->lru_start == NULL && table->lru_end == NULL); in test_lru()
181 lru_front(table, &k->entry); in test_lru()
182 unit_assert( table->lru_start == &k->entry && in test_lru()
183 table->lru_end == &k->entry); in test_lru()
184 lru_front(table, &k2->entry); in test_lru()
185 unit_assert( table->lru_start == &k2->entry && in test_lru()
186 table->lru_end == &k->entry); in test_lru()
188 lru_remove(table, &k2->entry); in test_lru()
189 unit_assert( table->lru_start == &k->entry && in test_lru()
190 table->lru_end == &k->entry); in test_lru()
191 lru_front(table, &k2->entry); in test_lru()
192 unit_assert( table->lru_start == &k2->entry && in test_lru()
193 table->lru_end == &k->entry); in test_lru()
195 lru_remove(table, &k->entry); in test_lru()
196 unit_assert( table->lru_start == &k2->entry && in test_lru()
197 table->lru_end == &k2->entry); in test_lru()
200 lru_remove(table, &k2->entry); in test_lru()
201 unit_assert( table->lru_start == NULL && table->lru_end == NULL); in test_lru()
202 lock_quick_unlock(&table->lock); in test_lru()
209 test_short_table(struct lruhash* table) in test_short_table() argument
219 lruhash_insert(table, myhash(12), &k->entry, d, NULL); in test_short_table()
220 lruhash_insert(table, myhash(14), &k2->entry, d2, NULL); in test_short_table()
222 unit_assert( lruhash_lookup(table, myhash(12), k, 0) == &k->entry); in test_short_table()
224 unit_assert( lruhash_lookup(table, myhash(14), k2, 0) == &k2->entry); in test_short_table()
226 lruhash_remove(table, myhash(12), k); in test_short_table()
227 lruhash_remove(table, myhash(14), k2); in test_short_table()
235 testadd(struct lruhash* table, testdata_type* ref[]) in testadd() argument
241 lruhash_insert(table, myhash(numtoadd), &key->entry, data, NULL); in testadd()
247 testremove(struct lruhash* table, testdata_type* ref[]) in testremove() argument
251 lruhash_remove(table, myhash(num), key); in testremove()
258 testlookup(struct lruhash* table, testdata_type* ref[]) in testlookup() argument
262 struct lruhash_entry* en = lruhash_lookup(table, myhash(num), key, 0); in testlookup()
277 check_table(struct lruhash* table) in check_table() argument
281 lock_quick_lock(&table->lock); in check_table()
282 unit_assert( table->num <= table->size); in check_table()
283 unit_assert( table->size_mask == (int)table->size-1 ); in check_table()
284 unit_assert( (table->lru_start && table->lru_end) || in check_table()
285 (!table->lru_start && !table->lru_end) ); in check_table()
286 unit_assert( table->space_used <= table->space_max ); in check_table()
288 if(table->lru_start) in check_table()
289 unit_assert(table->lru_start->lru_prev == NULL); in check_table()
290 if(table->lru_end) in check_table()
291 unit_assert(table->lru_end->lru_next == NULL); in check_table()
292 p = table->lru_start; in check_table()
303 unit_assert(c == table->num); in check_table()
306 unit_assert( table->space_used == in check_table()
307 table->num * test_slabhash_sizefunc(NULL, NULL) ); in check_table()
308 lock_quick_unlock(&table->lock); in check_table()
313 testadd_unlim(struct lruhash* table, testdata_type** ref) in testadd_unlim() argument
319 lruhash_insert(table, myhash(numtoadd), &key->entry, data, NULL); in testadd_unlim()
326 testremove_unlim(struct lruhash* table, testdata_type** ref) in testremove_unlim() argument
330 lruhash_remove(table, myhash(num), key); in testremove_unlim()
338 testlookup_unlim(struct lruhash* table, testdata_type** ref) in testlookup_unlim() argument
342 struct lruhash_entry* en = lruhash_lookup(table, myhash(num), key, 0); in testlookup_unlim()
360 test_long_table(struct lruhash* table) in test_long_table() argument
368 (int)HASHTESTMAX, (int)table->space_max); in test_long_table()
369 unit_assert( test_slabhash_sizefunc(NULL, NULL)*HASHTESTMAX < table->space_max); in test_long_table()
370 if(0) lruhash_status(table, "unit test", 1); in test_long_table()
375 lruhash_clear(table); in test_long_table()
382 testadd(table, ref); in test_long_table()
385 testremove(table, ref); in test_long_table()
388 testlookup(table, ref); in test_long_table()
393 if(0) lruhash_status(table, "unit test", 1); in test_long_table()
394 check_table(table); in test_long_table()
395 unit_assert( table->num <= HASHTESTMAX ); in test_long_table()
404 testadd_unlim(table, ref); in test_long_table()
407 testremove_unlim(table, ref); in test_long_table()
410 testlookup_unlim(table, ref); in test_long_table()
415 if(0) lruhash_status(table, "unlim", 1); in test_long_table()
416 check_table(table); in test_long_table()
427 struct lruhash* table; member
441 testadd_unlim(t->table, NULL); in test_thr_main()
444 testremove_unlim(t->table, NULL); in test_thr_main()
447 testlookup_unlim(t->table, NULL); in test_thr_main()
452 if(0) lruhash_status(t->table, "hashtest", 1); in test_thr_main()
454 check_table(t->table); in test_thr_main()
456 check_table(t->table); in test_thr_main()
462 test_threaded_table(struct lruhash* table) in test_threaded_table() argument
470 t[i].table = table; in test_threaded_table()
477 if(0) lruhash_status(table, "hashtest", 1); in test_threaded_table()
484 struct lruhash* table ; in lruhash_test() local
486 table = lruhash_create(2, 8192, in lruhash_test()
489 test_bin_find_entry(table); in lruhash_test()
490 test_lru(table); in lruhash_test()
491 test_short_table(table); in lruhash_test()
492 test_long_table(table); in lruhash_test()
493 lruhash_delete(table); in lruhash_test()
494 table = lruhash_create(2, 8192, in lruhash_test()
497 test_threaded_table(table); in lruhash_test()
498 lruhash_delete(table); in lruhash_test()