]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup unit test for BSD changes to infra storage.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 18 Dec 2008 14:44:15 +0000 (14:44 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 18 Dec 2008 14:44:15 +0000 (14:44 +0000)
git-svn-id: file:///svn/unbound/trunk@1404 be551aaa-1e26-0410-a405-d3ace91eadb9

testcode/unitmain.c

index 0f007068d47086f15b75bd04abf02eaad673d5e4..fb0d88f299beb94a137e471e1566ba0bb3e09ce0 100644 (file)
@@ -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);