From 1f505bf1b7d6e52d6ed74b609dd50ab4d002eb0a Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Mon, 13 Sep 2021 17:24:25 -0500 Subject: [PATCH] vere: make hashtable_tests complain about leak --- pkg/urbit/noun/hashtable.c | 2 +- pkg/urbit/tests/hashtable_tests.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/noun/hashtable.c b/pkg/urbit/noun/hashtable.c index 8ae60209e..40e36ef9e 100644 --- a/pkg/urbit/noun/hashtable.c +++ b/pkg/urbit/noun/hashtable.c @@ -400,7 +400,7 @@ _ch_trim_slot(u3h_root* har_u, u3h_slot *sot_w, c3_w lef_w, c3_w rem_w) } } -/* _ch_trim_slot(): trim one entry from a hashtable +/* _ch_trim_root(): trim one entry from a hashtable */ static c3_o _ch_trim_root(u3h_root* har_u) diff --git a/pkg/urbit/tests/hashtable_tests.c b/pkg/urbit/tests/hashtable_tests.c index c9c1bb822..7bd3e9538 100644 --- a/pkg/urbit/tests/hashtable_tests.c +++ b/pkg/urbit/tests/hashtable_tests.c @@ -1,4 +1,5 @@ #include "all.h" +#include "vere/vere.h" // defined in noun/hashtable.c c3_w _ch_skip_slot(c3_w mug_w, c3_w lef_w); @@ -8,6 +9,8 @@ c3_w _ch_skip_slot(c3_w mug_w, c3_w lef_w); static void _setup(void) { + u3C.wag_w = u3C.wag_w | u3o_debug_ram; + u3m_init(); u3m_pave(c3y); } @@ -136,26 +139,33 @@ static c3_i _test_cache_trimming(void) { c3_i ret_i = 1; - c3_w max_w = 620; + c3_w max_w = 620000; c3_w i_w; //u3p(u3h_root) har_p = u3h_new_cache(max_w / 2); - u3p(u3h_root) har_p = u3h_new_cache(max_w / 10 ); + u3p(u3h_root) har_p = u3h_new_cache(max_w / 10); u3h_root* har_u = u3to(u3h_root, har_p); for ( i_w = 0; i_w < max_w; i_w++ ) { - u3h_put(har_p, i_w, i_w + max_w); + u3_noun key = u3nc(i_w,i_w); + u3h_put(har_p, key, u3nc(i_w,i_w + max_w)); + u3z(key); } - if ( ( max_w + max_w - 1) != u3h_get(har_p, max_w - 1) ) { + u3_noun key = u3nc(max_w-1,max_w-1); + u3_noun val = u3h_get(har_p, key); + if ( ( max_w + max_w - 1) != u3t(val) ) { fprintf(stderr, "cache_trimming (a): fail\r\n"); ret_i = 0; } if ( ( max_w / 10 ) != har_u->use_w ) { - fprintf(stderr, "cache_trimming (b): fail\r\n"); + fprintf(stderr, "cache_trimming (b): fail %d %d\r\n", + max_w / 10, har_u->use_w ); ret_i = 0; } + u3z(key); + u3z(val); u3h_free(har_p); return ret_i; } @@ -186,6 +196,8 @@ _test_cache_replace_value(void) } if ( max_w != har_u->use_w ) { fprintf(stderr, "cache_replace (b): fail\r\n"); + fprintf(stderr, "cache_replace (b): fail %d %d\r\n", + max_w, har_u->use_w ); ret_i = 0; }