From: Mathieu Desnoyers Date: Wed, 14 Sep 2011 17:17:16 +0000 (-0400) Subject: rculfhash: validate lookups X-Git-Tag: v0.7.0~43^2~148^2~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=59b10634e3ec5ca35111f24d8b880935193e6266;p=userspace-rcu.git rculfhash: validate lookups Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c index 4a5ca55..2bdaa38 100644 --- a/tests/test_urcu_hash.c +++ b/tests/test_urcu_hash.c @@ -120,6 +120,7 @@ static int opt_auto_resize; static int add_only, add_unique; static unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset; +static int validate_lookup; static inline void loop_sleep(unsigned long l) { @@ -399,10 +400,14 @@ void *thr_reader(void *_count) node = cds_lfht_lookup(test_ht, (void *)(unsigned long)((rand_r(&rand_lookup) % rand_pool) + lookup_pool_offset), sizeof(void *)); - if (node == NULL) + if (node == NULL) { + if (validate_lookup) { + printf("[ERROR] Lookup cannot find initial node.\n"); + } lookup_fail++; - else + } else { lookup_ok++; + } debug_yield_read(); if (unlikely(rduration)) loop_sleep(rduration); @@ -531,8 +536,7 @@ static int populate_hash(void) if (add_unique && init_populate * 10 > rand_pool) { printf("WARNING: required to populate %lu nodes (-k), but random " "pool is quite small (%lu values) and we are in add_unique (-u) mode. Try with a " -"larger random pool (-p option).\n", init_populate, rand_pool); - return -1; +"larger random pool (-p option). This may take a while...\n", init_populate, rand_pool); } while (nr_add < init_populate) { @@ -570,9 +574,10 @@ void show_usage(int argc, char **argv) printf(" [-i] Add only (no removal)."); printf(" [-k nr_nodes] Number of nodes to insert initially."); printf(" [-A] Automatically resize hash table."); - printf(" [-R offset] Lookup pool offset\n"); - printf(" [-S offset] Write pool offset\n"); - printf(" [-T offset] Init pool offset\n"); + printf(" [-R offset] Lookup pool offset."); + printf(" [-S offset] Write pool offset."); + printf(" [-T offset] Init pool offset."); + printf(" [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range)."); printf("\n"); } @@ -687,6 +692,9 @@ int main(int argc, char **argv) case 'T': init_pool_offset = atol(argv[++i]); break; + case 'V': + validate_lookup = 1; + break; } }