unbound 0.1
unitslabhash.c File Reference

Tests the locking LRU keeping hash table implementation. More...

#include "config.h"
#include "testcode/unitmain.h"
#include "util/log.h"
#include "util/storage/slabhash.h"

Data Structures

struct  slab_test_thr
 structure to threaded test the lru hash table More...

Macros

#define HASHTESTMAX   32
 number of hash test max

Functions

static void delkey (struct slabhash_testkey *k)
 delete key
static hashvalue_type myhash (int id)
 hash func, very bad to improve collisions, both high and low bits
static testkey_type * newkey (int id)
 allocate new key, fill in hash
static testdata_type * newdata (int val)
 new data el
static void test_short_table (struct slabhash *table)
 test hashtable using short sequence
static void testadd (struct slabhash *table, testdata_type *ref[])
 test adding a random element
static void testremove (struct slabhash *table, testdata_type *ref[])
 test adding a random element
static void testlookup (struct slabhash *table, testdata_type *ref[])
 test adding a random element
static void check_lru_table (struct lruhash *table)
 check integrity of hash table
static void check_table (struct slabhash *table)
 check integrity of hash table
static void testadd_unlim (struct slabhash *table, testdata_type **ref)
 test adding a random element (unlimited range)
static void testremove_unlim (struct slabhash *table, testdata_type **ref)
 test adding a random element (unlimited range)
static void testlookup_unlim (struct slabhash *table, testdata_type **ref)
 test adding a random element (unlimited range)
static void test_long_table (struct slabhash *table)
 test with long sequence of adds, removes and updates, and lookups
static void * test_thr_main (void *arg)
 main routine for threaded hash table test
static void test_threaded_table (struct slabhash *table)
 test hash table access by multiple threads
void slabhash_test (void)
 unit test slabhashtable implementation

Detailed Description

Tests the locking LRU keeping hash table implementation.

Function Documentation

◆ delkey()

void delkey ( struct slabhash_testkey * k)
static

◆ myhash()

hashvalue_type myhash ( int id)
static

hash func, very bad to improve collisions, both high and low bits

References myhash().

◆ newkey()

◆ newdata()

testdata_type * newdata ( int val)
static

new data el

References slabhash_testdata::data, fatal_exit(), and newdata().

◆ test_short_table()

void test_short_table ( struct slabhash * table)
static

◆ testadd()

void testadd ( struct slabhash * table,
testdata_type * ref[] )
static

◆ testremove()

void testremove ( struct slabhash * table,
testdata_type * ref[] )
static

test adding a random element

References delkey(), HASHTESTMAX, myhash(), newkey(), slabhash_remove(), and testremove().

◆ testlookup()

◆ check_lru_table()

◆ check_table()

void check_table ( struct slabhash * table)
static

check integrity of hash table

References slabhash::array, check_lru_table(), check_table(), and slabhash::size.

◆ testadd_unlim()

void testadd_unlim ( struct slabhash * table,
testdata_type ** ref )
static

test adding a random element (unlimited range)

References lruhash_entry::data, HASHTESTMAX, lruhash_entry::key, myhash(), newdata(), newkey(), slabhash_insert(), and testadd_unlim().

◆ testremove_unlim()

void testremove_unlim ( struct slabhash * table,
testdata_type ** ref )
static

test adding a random element (unlimited range)

References delkey(), HASHTESTMAX, lruhash_entry::key, myhash(), newkey(), slabhash_remove(), and testremove_unlim().

◆ testlookup_unlim()

void testlookup_unlim ( struct slabhash * table,
testdata_type ** ref )
static

◆ test_long_table()

void test_long_table ( struct slabhash * table)
static

◆ test_thr_main()

void * test_thr_main ( void * arg)
static

◆ test_threaded_table()

void test_threaded_table ( struct slabhash * table)
static

test hash table access by multiple threads

References slab_test_thr::num, slabhash_status(), slab_test_thr::table, test_thr_main(), and test_threaded_table().

◆ slabhash_test()

void slabhash_test ( void )