Commit 59d0264e authored by Daniel Salzman's avatar Daniel Salzman

tests: add common configuration helper

parent ec2e072f
......@@ -8,11 +8,20 @@ doc/configuration.rst
doc/index.rst
doc/installation.rst
doc/introduction.rst
doc/man_kdig.rst
doc/man_keymgr.rst
doc/man_khost.rst
doc/man_knot1to2.rst
doc/man_knotc.rst
doc/man_knotd.rst
doc/man_knsec3hash.rst
doc/man_knsupdate.rst
doc/migration.rst
doc/reference.rst
doc/requirements.rst
doc/running.rst
doc/troubleshooting.rst
doc/utilities.rst
libtap/Makefile.am
libtap/runtests.c
libtap/tap/basic.c
......@@ -20,8 +29,6 @@ libtap/tap/basic.h
libtap/tap/float.c
libtap/tap/float.h
libtap/tap/macros.h
man/Makefile.am
patches/Makefile.am
samples/Makefile.am
src/Makefile.am
src/dnssec/Makefile.am
......@@ -96,9 +103,10 @@ src/dnssec/lib/sign/der.c
src/dnssec/lib/sign/der.h
src/dnssec/lib/sign/sign.c
src/dnssec/lib/tsig.c
src/dnssec/man/Makefile.am
src/dnssec/shared/base32hex.c
src/dnssec/shared/base32hex.h
src/dnssec/shared/bignum.c
src/dnssec/shared/bignum.h
src/dnssec/shared/dname.c
src/dnssec/shared/dname.h
src/dnssec/shared/fs.c
......@@ -117,6 +125,7 @@ src/dnssec/shared/wire.h
src/dnssec/tests/Makefile.am
src/dnssec/tests/binary.c
src/dnssec/tests/crypto.c
src/dnssec/tests/event_keystate.c
src/dnssec/tests/kasp_dir_escape.c
src/dnssec/tests/kasp_dir_file.c
src/dnssec/tests/kasp_store.c
......@@ -132,7 +141,9 @@ src/dnssec/tests/nsec_hash.c
src/dnssec/tests/random.c
src/dnssec/tests/sample_keys.h
src/dnssec/tests/shared_base32hex.c
src/dnssec/tests/shared_bignum.c
src/dnssec/tests/shared_dname.c
src/dnssec/tests/shared_strtonum.c
src/dnssec/tests/shared_wire.c
src/dnssec/tests/sign.c
src/dnssec/tests/sign_der.c
......@@ -468,6 +479,7 @@ src/zscanner/tests/processing.h
src/zscanner/tests/tests.c
src/zscanner/tests/tests.h
src/zscanner/tests/zscanner-tool.c
tests-fuzz/Makefile.am
tests/Makefile.am
tests/acl.c
tests/base32hex.c
......@@ -484,6 +496,7 @@ tests/hattrie.c
tests/hhash.c
tests/journal.c
tests/namedb.c
tests/net_shortwrite.c
tests/node.c
tests/overlay.c
tests/pkt.c
......@@ -497,6 +510,7 @@ tests/rrl.c
tests/rrset.c
tests/rrset_wire.c
tests/server.c
tests/test_conf.h
tests/utils.c
tests/wire.c
tests/worker_pool.c
......
......@@ -5,3 +5,5 @@ src/dnssec/lib/dnssec
src/dnssec/shared
src/dnssec/utils
src/zscanner
tests
tests-fuzz
\ No newline at end of file
......@@ -64,6 +64,6 @@ check-local: $(check_PROGRAMS)
-L $(top_builddir)/tests/runtests.log \
$(check_PROGRAMS)
process_query_SOURCES = process_query.c fake_server.h
process_answer_SOURCES = process_answer.c fake_server.h
process_query_SOURCES = process_query.c fake_server.h test_conf.h
process_answer_SOURCES = process_answer.c fake_server.h test_conf.h
CLEANFILES = runtests.log
#pragma once
#include "test_conf.h"
#include "knot/server/server.h"
#include "libknot/internal/mempattern.h"
......@@ -52,24 +53,12 @@ static inline int create_fake_server(server_t *server, mm_ctx_t *mm)
return ret;
}
/* Create configuration. */
/* Load test configuration. */
const char *conf_str = "server:\n identity: bogus.ns\n version: 0.11\n";
conf_t *conf;
ret = conf_new(&conf, conf_scheme, NULL);
ret = test_conf(conf_str, NULL);
if (ret != KNOT_EOK) {
return ret;
}
ret = conf_import(conf, conf_str, false);
if (ret != KNOT_EOK) {
conf_free(conf, false);
return ret;
}
ret = conf_post_open(conf);
if (ret != KNOT_EOK) {
conf_free(conf, false);
return ret;
}
conf_update(conf);
/* Insert root zone. */
create_root_zone(server, mm);
......
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "knot/conf/conf.h"
#include "libknot/errcode.h"
/* Prepare server configuration. */
static inline int test_conf(const char *conf_str, const yp_item_t *scheme)
{
// Use default scheme if not specified.
if (scheme == NULL) {
scheme = conf_scheme;
}
conf_t *conf;
int ret = conf_new(&conf, scheme, NULL);
if (ret != KNOT_EOK) {
return ret;
}
ret = conf_import(conf, conf_str, false);
if (ret != KNOT_EOK) {
conf_free(conf, false);
return ret;
}
ret = conf_post_open(conf);
if (ret != KNOT_EOK) {
conf_free(conf, false);
return ret;
}
conf_update(conf);
return KNOT_EOK;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment