Lines Matching +full:one +full:- +full:to +full:- +full:one

2  * testcode/unitinfra.c - unit test for infra cache.
20 * be used to endorse or promote products derived from this software without
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
57 d = (struct infra_data*)e->data; in infra_lookup_host()
58 if(d->ttl < now) { in infra_lookup_host()
59 lock_rw_unlock(&e->lock); in infra_lookup_host()
62 *k = (struct infra_key*)e->key; in infra_lookup_host()
67 struct config_file* cfg, struct sockaddr_storage one, socklen_t onelen, in test_keep_probing() argument
72 int vs, to, lame, dnsseclame, reclame, probedelay; in test_keep_probing() local
77 cfg->infra_cache_max_rtt = rtt_max_timeout; in test_keep_probing()
79 slab->infra_keep_probing = keep_probing; in test_keep_probing()
82 *now += cfg->host_ttl + 10; in test_keep_probing()
83 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in test_keep_probing()
84 *now, &vs, &edns_lame, &to) ); in test_keep_probing()
87 while(to < USEFUL_SERVER_TOP_TIMEOUT) { in test_keep_probing()
88 unit_assert( infra_rtt_update(slab, &one, onelen, zone, zonelen, in test_keep_probing()
89 LDNS_RR_TYPE_A, -1, to, *now) ); in test_keep_probing()
90 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in test_keep_probing()
91 *now, &vs, &edns_lame, &to) ); in test_keep_probing()
92 unit_assert( vs == 0 && to <= USEFUL_SERVER_TOP_TIMEOUT && edns_lame == 0 ); in test_keep_probing()
94 unit_assert( vs == 0 && to == USEFUL_SERVER_TOP_TIMEOUT && edns_lame == 0 ); in test_keep_probing()
97 unit_assert( (d=infra_lookup_host(slab, &one, onelen, zone, zonelen, 0, *now, &k)) ); in test_keep_probing()
98 unit_assert( d->timeout_A >= TIMEOUT_COUNT_MAX ); in test_keep_probing()
99 unit_assert( d->probedelay > 0 ); in test_keep_probing()
100 probedelay = d->probedelay; in test_keep_probing()
101 lock_rw_unlock(&k->entry.lock); in test_keep_probing()
102 cfg->host_ttl = cfg->host_ttl + *now < probedelay in test_keep_probing()
103 ?cfg->host_ttl :probedelay + 10; in test_keep_probing()
108 unit_assert( infra_get_lame_rtt(slab, &one, onelen, zone, zonelen, in test_keep_probing()
109 LDNS_RR_TYPE_A, &lame, &dnsseclame, &reclame, &to, *now) ); in test_keep_probing()
111 && to == keep_probing ?still_useful_timeout() :USEFUL_SERVER_TOP_TIMEOUT); in test_keep_probing()
117 struct sockaddr_storage one; in infra_test() local
125 int vs, to; in infra_test() local
132 unit_assert(ipstrtoaddr("127.0.0.1", 53, &one, &onelen)); in infra_test()
137 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, now, in infra_test()
138 &vs, &edns_lame, &to) ); in infra_test()
139 unit_assert( vs == 0 && to == init && edns_lame == 0 ); in infra_test()
142 unit_assert( infra_rtt_update(slab, &one, onelen, zone, zonelen, LDNS_RR_TYPE_A, -1, init, now) ); in infra_test()
143 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in infra_test()
144 now, &vs, &edns_lame, &to) ); in infra_test()
145 unit_assert( vs == 0 && to == init*2 && edns_lame == 0 ); in infra_test()
148 unit_assert( infra_edns_update(slab, &one, onelen, zone, zonelen, -1, now) ); in infra_test()
149 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in infra_test()
150 now, &vs, &edns_lame, &to) ); in infra_test()
151 unit_assert( vs == -1 && to == init*2 && edns_lame == 1); in infra_test()
154 now += cfg->host_ttl + 10; in infra_test()
155 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in infra_test()
156 now, &vs, &edns_lame, &to) ); in infra_test()
157 unit_assert( vs == 0 && to == init && edns_lame == 0 ); in infra_test()
160 unit_assert( infra_set_lame(slab, &one, onelen, in infra_test()
162 unit_assert( (d=infra_lookup_host(slab, &one, onelen, zone, zonelen, 0, now, &k)) ); in infra_test()
163 unit_assert( d->ttl == now+cfg->host_ttl ); in infra_test()
164 unit_assert( d->edns_version == 0 ); in infra_test()
165 unit_assert(!d->isdnsseclame && !d->rec_lame && d->lame_type_A && in infra_test()
166 !d->lame_other); in infra_test()
167 lock_rw_unlock(&k->entry.lock); in infra_test()
170 unit_assert( infra_set_lame(slab, &one, onelen, in infra_test()
172 unit_assert( (d=infra_lookup_host(slab, &one, onelen, zone, zonelen, 0, now, &k)) ); in infra_test()
173 unit_assert(!d->isdnsseclame && !d->rec_lame && d->lame_type_A && in infra_test()
174 d->lame_other); in infra_test()
175 lock_rw_unlock(&k->entry.lock); in infra_test()
177 /* test that noEDNS cannot overwrite known-yesEDNS */ in infra_test()
178 now += cfg->host_ttl + 10; in infra_test()
179 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in infra_test()
180 now, &vs, &edns_lame, &to) ); in infra_test()
181 unit_assert( vs == 0 && to == init && edns_lame == 0 ); in infra_test()
183 unit_assert( infra_edns_update(slab, &one, onelen, zone, zonelen, 0, now) ); in infra_test()
184 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in infra_test()
185 now, &vs, &edns_lame, &to) ); in infra_test()
186 unit_assert( vs == 0 && to == init && edns_lame == 1 ); in infra_test()
188 unit_assert( infra_edns_update(slab, &one, onelen, zone, zonelen, -1, now) ); in infra_test()
189 unit_assert( infra_host(slab, &one, onelen, zone, zonelen, in infra_test()
190 now, &vs, &edns_lame, &to) ); in infra_test()
191 unit_assert( vs == 0 && to == init && edns_lame == 1 ); in infra_test()
193 unit_show_feature("infra cache probing (keep-probing off, default infra-cache-max-rtt)"); in infra_test()
194 test_keep_probing(slab, cfg, one, onelen, zone, zonelen, &now, 0, default_max_rtt); in infra_test()
196 unit_show_feature("infra cache probing (keep-probing on, default infra-cache-max-rtt)"); in infra_test()
197 test_keep_probing(slab, cfg, one, onelen, zone, zonelen, &now, 1, default_max_rtt); in infra_test()
199 unit_show_feature("infra cache probing (keep-probing off, low infra-cache-max-rtt)"); in infra_test()
200 test_keep_probing(slab, cfg, one, onelen, zone, zonelen, &now, 0, 3000); in infra_test()
202 unit_show_feature("infra cache probing (keep-probing on, low infra-cache-max-rtt)"); in infra_test()
203 test_keep_probing(slab, cfg, one, onelen, zone, zonelen, &now, 1, 3000); in infra_test()
205 /* Re-apply defaults for other unit tests that follow */ in infra_test()