Running unit and integration tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The unit tests require cmocka_ and are executed with ``make check``.
+The unit tests require cmocka_ and are executed by ``make check``.
+Tests for the dnstap module need go and are executed by ``make ckeck-dnstap``.
The integration tests use Deckard, the `DNS test harness <deckard>`_.
/* dnstap_log prepares dnstap message and sent it to fstrm */
static int dnstap_log(kr_layer_t *ctx) {
- struct kr_request *req = ctx->req;
- struct kr_module *module = ctx->api->data;
- struct kr_rplan *rplan = &req->rplan;
- struct dnstap_data *dnstap_dt = module->data;
+ const struct kr_request *req = ctx->req;
+ const struct kr_module *module = ctx->api->data;
+ const struct kr_rplan *rplan = &req->rplan;
+ const struct dnstap_data *dnstap_dt = module->data;
/* check if we have a valid iothread */
if (!dnstap_dt->iothread || !dnstap_dt->ioq) {
/* Only handling response */
m.type = DNSTAP__MESSAGE__TYPE__RESOLVER_RESPONSE;
- if (req->qsource.tcp) {
- m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__TCP;
- } else {
- m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__UDP;
- }
- m.has_socket_protocol = true;
-
if (req->qsource.addr) {
set_address(req->qsource.addr,
&m.query_address,
}
if (req->qsource.dst_addr) {
+ if (req->qsource.tcp) {
+ m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__TCP;
+ } else {
+ m.socket_protocol = DNSTAP__SOCKET_PROTOCOL__UDP;
+ }
+ m.has_socket_protocol = true;
+
set_address(req->qsource.dst_addr,
&m.response_address,
&m.has_response_address,
return kr_ok();
}
-/* find_int copies json int into val
- * node must be of type JSON_NUMBER */
-static int find_int(const JsonNode *node, int *val) {
- if (!node || !node->key || !val) {
- return kr_error(EINVAL);
- }
- assert(node->tag == JSON_NUMBER);
- *val = node->number_;
- return kr_ok();
-}
-
/* find_bool returns bool from json */
static bool find_bool(const JsonNode *node) {
if (!node || !node->key) {
CMD := daemon/kresd
ZONES := "fake1.localdomain,fake2.localdomain,fake3.localdomain"
TIMEOUT := 60s
-check-dnstap:
+check-dnstap: daemon
@echo "Checking dnstap functionality"
GOPATH=$(GOPATH) go get -u github.com/FiloSottile/gvt
cd $(DNSTAP_PATH) && $(GOPATH)/bin/gvt restore
GOPATH=$(GOPATH) go install $(DNSTAP_TEST)
- $(GOPATH)/bin/$(DNSTAP_TEST) -c $(CONFIG) -cmd $(CMD) -q $(ZONES) -t $(TIMEOUT)
+ $(GOPATH)/bin/$(DNSTAP_TEST) -c $(CONFIG) -cmd $(CMD) -q $(ZONES) -t $(TIMEOUT)
clean-dnstap:
rm -rf $(GOPATH)/bin $(GOPATH)/pkg