dnstap_test.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#include <config.h>
#include <atf-c.h>
#include <unistd.h>
#include <stdlib.h>
#include "dnstest.h"
#ifdef HAVE_DNSTAP
#include <dns/dnstap.pb-c.h>
#include <protobuf-c/protobuf-c.h>
#define TAPFILE "testdata/dnstap/dnstap.file"
#define TAPSOCK "testdata/dnstap/dnstap.sock"
#define TAPSAVED "testdata/dnstap/dnstap.saved"
#define TAPTEXT "testdata/dnstap/dnstap.text"
/*
* Helper functions
*/
static void
cleanup() {
(void) isc_file_remove(TAPFILE);
(void) isc_file_remove(TAPSOCK);
}
/*
* Individual unit tests
*/
}
cleanup();
/* 'create' should succeed, but the file shouldn't exist yet */
cleanup();
dns_test_end();
}
}
unsigned char zone[DNS_NAME_MAXWIRE];
isc_time_t p, f;
cleanup();
/*
* Set up some test data
*/
isc_buffer_t *m;
switch (dt) {
case DNS_DTTYPE_AQ:
m = &qamsg;
break;
case DNS_DTTYPE_AR:
m = &ramsg;
break;
default:
m = &qrmsg;
if ((dt & DNS_DTTYPE_RESPONSE) != 0)
m = &ramsg;
break;
}
}
/*
* XXX now read back and check content.
*/
isc_region_t r;
static int n = 0;
if (result != ISC_R_SUCCESS) {
n++;
continue;
}
if (++n % 8 == 0)
expected <<= 1;
}
cleanup();
dns_test_end();
}
}
/* make sure text conversion gets the right local time */
isc_buffer_t *b = NULL;
isc_region_t r;
char s[BUFSIZ], *p;
/* read the corresponding line of text */
ATF_CHECK_EQ(p, s);
if (p == NULL)
break;
p = strchr(p, '\n');
if (p != NULL)
*p = '\0';
/* parse dnstap frame */
if (result != ISC_R_SUCCESS)
continue;
if (b == NULL)
break;
/* convert to text and compare */
ATF_CHECK_STREQ((char *) isc_buffer_base(b), s);
isc_buffer_free(&b);
}
cleanup();
dns_test_end();
}
#else
}
atf_tc_skip("dnstap not available");
}
#endif
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
#ifdef HAVE_DNSTAP
#else
#endif
return (atf_no_error());
}