diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:26:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:26:00 +0000 |
commit | 830407e88f9d40d954356c3754f2647f91d5c06a (patch) | |
tree | d6a0ece6feea91f3c656166dbaa884ef8a29740e /lib/test_module.c | |
parent | Initial commit. (diff) | |
download | knot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.tar.xz knot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.zip |
Adding upstream version 5.6.0.upstream/5.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/test_module.c')
-rw-r--r-- | lib/test_module.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/test_module.c b/lib/test_module.c new file mode 100644 index 0000000..d7124c1 --- /dev/null +++ b/lib/test_module.c @@ -0,0 +1,39 @@ +/* Copyright (C) CZ.NIC, z.s.p.o. <knot-resolver@labs.nic.cz> + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "tests/unit/test.h" +#include "lib/module.h" + +static void test_module_params(void **state) +{ + struct kr_module module = { 0 }; + assert_int_equal(kr_module_load(NULL, NULL, NULL), kr_error(EINVAL)); + assert_int_equal(kr_module_load(&module, NULL, NULL), kr_error(EINVAL)); + kr_module_unload(NULL); +} + +static void test_module_builtin(void **state) +{ + struct kr_module module = { 0 }; + assert_int_equal(kr_module_load(&module, "iterate", NULL), 0); + kr_module_unload(&module); +} + +static void test_module_c(void **state) +{ + struct kr_module module = { 0 }; + assert_int_equal(kr_module_load(&module, "mock_cmodule", "tests/unit"), 0); + kr_module_unload(&module); +} + +int main(void) +{ + const UnitTest tests[] = { + unit_test(test_module_params), + unit_test(test_module_builtin), + unit_test(test_module_c), + }; + + return run_tests(tests); +} |