X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=tests%2Ftest_urcu_ja.c;h=7b64575d7bb1c0d0c2394dd921aa535e94844ae0;hb=3d8fe30760fd4fb67ce24b5aa011ab75f680a904;hp=d933bae5c2c890f1a0965e22240af2e971df4299;hpb=df65c98a4b6a3c3ba5e55c448521605fe14b6ec3;p=userspace-rcu.git diff --git a/tests/test_urcu_ja.c b/tests/test_urcu_ja.c index d933bae..7b64575 100644 --- a/tests/test_urcu_ja.c +++ b/tests/test_urcu_ja.c @@ -123,14 +123,14 @@ void rcu_copy_mutex_unlock(void) } } -#if 0 void free_node_cb(struct rcu_head *head) { struct ja_test_node *node = - caa_container_of(head, struct ja_test_node, head); + caa_container_of(head, struct ja_test_node, node.head); free(node); } +#if 0 static void test_delete_all_nodes(struct cds_lfht *ht) { @@ -233,8 +233,29 @@ int test_8bit_key(void) rcu_read_unlock(); } printf("OK\n"); + printf("Test #4: remove keys (8-bit).\n"); + for (key = 0; key < 200; key++) { + struct cds_hlist_head head; + struct ja_test_node *node; + + rcu_read_lock(); + head = cds_ja_lookup(test_ja, key); + node = cds_hlist_first_entry_rcu(&head, struct ja_test_node, node.list); + if (!node) { + fprintf(stderr, "Error lookup node %" PRIu64 "\n", key); + assert(0); + } + ret = cds_ja_del(test_ja, key, &node->node); + if (ret) { + fprintf(stderr, "Error (%d) removing node %" PRIu64 "\n", ret, key); + assert(0); + } + call_rcu(&node->node.head, free_node_cb); + rcu_read_unlock(); + } + printf("OK\n"); - ret = cds_ja_destroy(test_ja); + ret = cds_ja_destroy(test_ja, free_node_cb); if (ret) { fprintf(stderr, "Error destroying judy array\n"); return -1; @@ -304,7 +325,7 @@ int test_16bit_key(void) } printf("OK\n"); - ret = cds_ja_destroy(test_ja); + ret = cds_ja_destroy(test_ja, free_node_cb); if (ret) { fprintf(stderr, "Error destroying judy array\n"); return -1; @@ -390,7 +411,7 @@ int test_sparse_key(unsigned int bits) printf("OK\n"); } - ret = cds_ja_destroy(test_ja); + ret = cds_ja_destroy(test_ja, free_node_cb); if (ret) { fprintf(stderr, "Error destroying judy array\n"); return -1;