From 79f9940b8352ac8d322b52ba318c631e0d45d06d Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Thu, 8 Feb 2007 20:53:37 +0000 Subject: [PATCH] #3 fixed decode query test --- tests/dns.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/dns.c b/tests/dns.c index 0755be6..374c7bf 100644 --- a/tests/dns.c +++ b/tests/dns.c @@ -49,6 +49,7 @@ static char answerPacket[] = "\x20\x62\x65\x20\x64\x65\x6C\x69\x76\x65\x72\x65\x64"; static char *msgData = "this is the message to be delivered"; +static char *topdomain = "kryo.se"; static char *queryData = "HELLO this is the test data"; static char *recData = "AHELLO this is the test data"; // The A flag is added @@ -150,6 +151,7 @@ END_TEST START_TEST(test_decode_query) { char buf[512]; + char *domain; struct query q; int len; int ret; @@ -159,7 +161,9 @@ START_TEST(test_decode_query) q.id = 0; len = sizeof(queryPacket) - 1; - ret = dns_decode(buf, sizeof(buf), &q, QR_QUERY, queryPacket, len); + dns_decode(buf, sizeof(buf), &q, QR_QUERY, queryPacket, len); + domain = strstr(q.name, topdomain); + ret = decode_data(buf, sizeof(buf), q.name, domain); fail_unless(strncmp(buf, recData, ret) == 0, "Did not extract expected host: '%s'", buf); fail_unless(strlen(buf) == strlen(recData), va_str("Bad host length: %d, expected %d", strlen(q.name), strlen(recData)));