diff --git a/lib/resolve.h b/lib/resolve.h index 4720eb21241c49fd7bd2eae9958847fecec8cf7c..f62c54c5470c6265a0ef127e924d65d24195f332 100644 --- a/lib/resolve.h +++ b/lib/resolve.h @@ -37,15 +37,10 @@ * @code{.c} * * struct kr_context ctx = { - * .pool = NULL, // for persistent data * .cache = ..., // open cache instance (or NULL) - * .layers = {} // loaded layers + * .layers = &modules, * }; * - * // Push basic layers - * array_push(ctx.layers, iterate_layer); - * array_push(ctx.layers, rrcache_layer); - * * // Resolve "IN A cz." * knot_pkt_t *answer = knot_pkt_new(NULL, 65535, ctx.pool); * int ret = kr_resolve(&ctx, answer, (uint8_t*)"\x02cz", 1, 1); diff --git a/tests/test_resolve.c b/tests/test_resolve.c index 878ce54b5a94d36071c9856ecc1b075055dfa2da..eafff00d8090ecb754c8bae0f3116835035f9d89 100644 --- a/tests/test_resolve.c +++ b/tests/test_resolve.c @@ -14,9 +14,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <libknot/descriptor.h> #include "tests/test.h" #include <cmocka.h> - #include "lib/resolve.h" static void test_resolve_nullparams(void **state) @@ -33,11 +33,29 @@ static void test_resolve_nullparams(void **state) assert_int_equal(ret, KNOT_EINVAL); } +static void test_resolve_dummy(void **state) +{ + /* Create resolution context */ + module_array_t module_arr = { NULL, 0, 0 }; + struct kr_context ctx = { + .pool = NULL, + .modules = &module_arr + }; + /* Resolve a query (no iterator) */ + knot_pkt_t *answer = knot_pkt_new(NULL, 4096, NULL); + int ret = kr_resolve(&ctx, answer, (const uint8_t *)"", KNOT_CLASS_IN, KNOT_RRTYPE_NS); + assert_int_not_equal(ret, kr_ok()); + assert_int_equal(knot_wire_get_rcode(answer->wire), KNOT_RCODE_SERVFAIL); + knot_pkt_free(&answer); +} + int main(void) { const UnitTest tests[] = { /* Parameter sanity checks */ - unit_test(test_resolve_nullparams) + unit_test(test_resolve_nullparams), + /* Simple resolution test cases */ + unit_test(test_resolve_dummy) }; return run_tests(tests);