unbound 0.1
unitlruhash.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/lruhash.h"
#include "util/storage/slabhash.h"

Data Structures

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

Macros

#define HASHTESTMAX   25
 number of hash test max

Typedefs

typedef struct slabhash_testkey testkey_type
 use this type for the lruhash test key
typedef struct slabhash_testdata testdata_type
 use this type for the lruhash test data

Functions

static void delkey (struct slabhash_testkey *k)
 delete key
static void deldata (struct slabhash_testdata *d)
 delete data
static hashvalue_type myhash (int id)
 hash func, very bad to improve collisions
static testkey_type * newkey (int id)
 allocate new key, fill in hash
static testdata_type * newdata (int val)
 new data el
static void test_bin_find_entry (struct lruhash *table)
 test bin_find_entry function and bin_overflow_remove
static void test_lru (struct lruhash *table)
 test lru_front lru_remove
static void test_short_table (struct lruhash *table)
 test hashtable using short sequence
static void testadd (struct lruhash *table, testdata_type *ref[])
 test adding a random element
static void testremove (struct lruhash *table, testdata_type *ref[])
 test adding a random element
static void testlookup (struct lruhash *table, testdata_type *ref[])
 test adding a random element
static void check_table (struct lruhash *table)
 check integrity of hash table
static void testadd_unlim (struct lruhash *table, testdata_type **ref)
 test adding a random element (unlimited range)
static void testremove_unlim (struct lruhash *table, testdata_type **ref)
 test adding a random element (unlimited range)
static void testlookup_unlim (struct lruhash *table, testdata_type **ref)
 test adding a random element (unlimited range)
static void test_long_table (struct lruhash *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 lruhash *table)
 test hash table access by multiple threads
void lruhash_test (void)
 unit test lruhashtable implementation

Detailed Description

Tests the locking LRU keeping hash table implementation.

Macro Definition Documentation

◆ HASHTESTMAX

Typedef Documentation

◆ testkey_type

use this type for the lruhash test key

use this type for the slabhash test key

◆ testdata_type

use this type for the lruhash test data

use this type for the slabhash test data

Function Documentation

◆ delkey()

◆ deldata()

void deldata ( struct slabhash_testdata * d)
static

delete data

References deldata().

Referenced by deldata(), deldata(), and test_bin_find_entry().

◆ myhash()

◆ newkey()

◆ newdata()

◆ test_bin_find_entry()

◆ test_lru()

void test_lru ( struct lruhash * table)
static

◆ test_short_table()

◆ testadd()

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

◆ testremove()

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

test adding a random element

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

Referenced by test_long_table(), test_long_table(), testremove(), and testremove().

◆ testlookup()

◆ check_table()

◆ testadd_unlim()

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

◆ testremove_unlim()

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

◆ testlookup_unlim()

◆ test_long_table()

void test_long_table ( struct lruhash * table)
static

◆ test_thr_main()

◆ test_threaded_table()

void test_threaded_table ( struct lruhash * table)
static

◆ lruhash_test()