vere: make hashtable_tests complain about leak

This commit is contained in:
Philip Monk 2021-09-13 17:24:25 -05:00
parent 12b0506853
commit 1f505bf1b7
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
2 changed files with 18 additions and 6 deletions

View File

@ -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)

View File

@ -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;
}