test-resolved-packet: skip most of the loop

We want to test the edge cases, but testing all the values in between
is mostly pointless and slow on slow architectures (>1s on rpi).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-07-12 21:41:41 +00:00
parent da1e72f482
commit 86d0608929
3 changed files with 9 additions and 3 deletions

View file

@ -28,7 +28,6 @@
#define EDNS0_OPT_DO (1<<15)
#define DNS_PACKET_SIZE_START 512u
assert_cc(DNS_PACKET_SIZE_START > DNS_PACKET_HEADER_SIZE)
typedef struct DnsPacketRewinder {

View file

@ -56,10 +56,14 @@ struct DnsPacketHeader {
#define UDP_PACKET_HEADER_SIZE (sizeof(struct iphdr) + sizeof(struct udphdr))
/* The various DNS protocols deviate in how large a packet can grow,
but the TCP transport has a 16bit size field, hence that appears to
be the absolute maximum. */
* but the TCP transport has a 16bit size field, hence that appears to
* be the absolute maximum. */
#define DNS_PACKET_SIZE_MAX 0xFFFFu
/* The default size to use for allocation when we don't know how large
* the packet will turn out to be. */
#define DNS_PACKET_SIZE_START 512u
/* RFC 1035 say 512 is the maximum, for classic unicast DNS */
#define DNS_PACKET_UNICAST_SIZE_MAX 512u

View file

@ -31,6 +31,9 @@ static void test_dns_packet_new(void) {
log_debug("dns_packet_new: %zu → %zu", i, p->allocated);
assert_se(p->allocated >= MIN(DNS_PACKET_SIZE_MAX, i));
if (i > DNS_PACKET_SIZE_START + 10 && i < DNS_PACKET_SIZE_MAX - 10)
i = MIN(i * 2, DNS_PACKET_SIZE_MAX - 10);
}
assert_se(dns_packet_new(&p2, DNS_PROTOCOL_DNS, DNS_PACKET_SIZE_MAX + 1) == -EFBIG);