From ccdc0e3c531206ab4efed51fb158f39312466e48 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 18 Dec 2008 14:44:15 +0000 Subject: [PATCH] fixup unit test for BSD changes to infra storage. git-svn-id: file:///svn/unbound/trunk@1404 be551aaa-1e26-0410-a405-d3ace91eadb9 --- testcode/unitmain.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/testcode/unitmain.c b/testcode/unitmain.c index 0f007068d..fb0d88f29 100644 --- a/testcode/unitmain.c +++ b/testcode/unitmain.c @@ -309,7 +309,8 @@ rtt_test() static void infra_test() { - int one = 1; + struct sockaddr_storage one; + socklen_t onelen; uint8_t* zone = (uint8_t*)"\007example\003com\000"; size_t zonelen = 13; struct infra_cache* slab; @@ -322,33 +323,31 @@ infra_test() int init = 376; int dlame, rlame, alame, olame; + unit_assert(ipstrtoaddr("127.0.0.1", 53, &one, &onelen)); + slab = infra_create(cfg); unit_assert( infra_host(slab, (struct sockaddr_storage*)&one, (socklen_t)sizeof(int), now, &vs, &edns_lame, &to) ); unit_assert( vs == 0 && to == init && edns_lame == 0 ); - unit_assert( infra_rtt_update(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), -1, init, now) ); - unit_assert( infra_host(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), now, &vs, &edns_lame, &to) ); + unit_assert( infra_rtt_update(slab, &one, onelen, -1, init, now) ); + unit_assert( infra_host(slab, &one, onelen, + now, &vs, &edns_lame, &to) ); unit_assert( vs == 0 && to == init*2 && edns_lame == 0 ); - unit_assert( infra_edns_update(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), -1, now) ); - unit_assert( infra_host(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), now, &vs, &edns_lame, &to) ); + unit_assert( infra_edns_update(slab, &one, onelen, -1, now) ); + unit_assert( infra_host(slab, &one, onelen, + now, &vs, &edns_lame, &to) ); unit_assert( vs == -1 && to == init*2 && edns_lame == 1); now += cfg->host_ttl + 10; - unit_assert( infra_host(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), now, &vs, &edns_lame, &to) ); + unit_assert( infra_host(slab, &one, onelen, + now, &vs, &edns_lame, &to) ); unit_assert( vs == 0 && to == init && edns_lame == 0 ); - unit_assert( infra_set_lame(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), zone, zonelen, now, 0, 0, - LDNS_RR_TYPE_A) ); - unit_assert( (d=infra_lookup_host(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), 0, now, &k)) ); + unit_assert( infra_set_lame(slab, &one, onelen, + zone, zonelen, now, 0, 0, LDNS_RR_TYPE_A) ); + unit_assert( (d=infra_lookup_host(slab, &one, onelen, 0, now, &k)) ); unit_assert( d->ttl == now+cfg->host_ttl ); unit_assert( d->edns_version == 0 ); unit_assert( infra_lookup_lame(d, zone, zonelen, now, @@ -361,11 +360,9 @@ infra_test() lock_rw_unlock(&k->entry.lock); /* test merge of data */ - unit_assert( infra_set_lame(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), zone, zonelen, now, 0, 0, - LDNS_RR_TYPE_AAAA) ); - unit_assert( (d=infra_lookup_host(slab, (struct sockaddr_storage*)&one, - (socklen_t)sizeof(int), 0, now, &k)) ); + unit_assert( infra_set_lame(slab, &one, onelen, + zone, zonelen, now, 0, 0, LDNS_RR_TYPE_AAAA) ); + unit_assert( (d=infra_lookup_host(slab, &one, onelen, 0, now, &k)) ); unit_assert( infra_lookup_lame(d, zone, zonelen, now, &dlame, &rlame, &alame, &olame) ); unit_assert(!dlame && !rlame && alame && olame); -- 2.47.3