[ltt-dev] [PATCH 7/9] add identical-hash-value-chain test
Lai Jiangshan
laijs at cn.fujitsu.com
Sun Nov 13 23:50:57 EST 2011
Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
tests/test_urcu_hash.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c
index eb42522..3730c2b 100644
--- a/tests/test_urcu_hash.c
+++ b/tests/test_urcu_hash.c
@@ -111,6 +111,7 @@ struct test_data {
struct lfht_test_node {
struct cds_lfht_node node;
unsigned long hash;
+ unsigned long orig_hash;
/* cache-cold for iteration */
struct rcu_head head;
};
@@ -142,6 +143,7 @@ static unsigned long init_populate;
static int opt_auto_resize;
static int add_only, add_unique, add_replace;
static int opt_test_bucket_conflict;
+static int opt_duplicated;
static int count_pipe[2];
@@ -395,6 +397,19 @@ void lfht_test_node_init(struct lfht_test_node *node)
cds_lfht_node_init(&node->node);
+ /* 25% duplicated hash value */
+ if (opt_duplicated && test_rand_get_bits(2) == 0) {
+ struct cds_lfht_iter iter;
+
+ if (!cds_lfht_lookup(test_ht, test_rand_get(),
+ lookup_first, NULL, &iter))
+ cds_lfht_next(test_ht, &iter);
+ if (iter.node)
+ hash = to_test_node(iter.node)->orig_hash;
+ }
+
+ node->orig_hash = hash;
+
if (opt_test_bucket_conflict) {
#if (CAA_BITS_PER_LONG == 32)
int hash_bits= test_rand_get_bits(5);
@@ -690,6 +705,7 @@ void show_usage(int argc, char **argv)
printf(" [-k nr_nodes] Number of nodes to insert initially.\n");
printf(" [-A] Automatically resize hash table.\n");
printf(" [-C] Use some hash value Confilict with buckets.\n");
+ printf(" [-D] Test Duplicated hash values and nodes.\n");
printf("\n\n");
}
@@ -810,6 +826,8 @@ int main(int argc, char **argv)
break;
case 'C':
opt_test_bucket_conflict = 1;
+ case 'D':
+ opt_duplicated = 1;
break;
}
--
1.7.4.4
More information about the lttng-dev
mailing list