]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests: updated resolve unit test
authorMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 12 Jan 2015 01:26:23 +0000 (02:26 +0100)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Mon, 12 Jan 2015 01:26:23 +0000 (02:26 +0100)
lib/resolve.c
tests/test_resolve.c

index b852b1dd4e0c20d8781b0fff1e58df8656117039..91e6c48bc18463a18f95ee69523f6a080ac87be5 100755 (executable)
@@ -92,7 +92,7 @@ int kr_resolve(struct kr_context* ctx, knot_pkt_t *answer,
                const knot_dname_t *qname, uint16_t qclass, uint16_t qtype)
 {
        if (ctx == NULL || answer == NULL || qname == NULL) {
-               return KNOT_ENOENT;
+               return KNOT_EINVAL;
        }
 
        /* Initialize context. */
index 775c736b45ae2949f6e58b075442153c20af3a9a..50b38f2d9c0ad8473c724c255e89a0f782c88890 100644 (file)
  */
 
 #include "tests/test.h"
-
-#include <libknot/descriptor.h>
 #include "lib/resolve.h"
 
-void test_resolve_sync(void **state)
+static void test_resolve_nullparams(void **state)
 {
-       /* \todo CMocka should provide responses here. */
+       int ret = KNOT_EOK;
+
+       /* NULL parameter check */
+       void *non_null = (void *)0xDEADBEEF;
+       ret = kr_resolve(NULL, non_null, non_null, KNOT_CLASS_NONE, KNOT_RRTYPE_ANY);
+       assert_int_equal(ret, KNOT_EINVAL);
+       ret = kr_resolve(non_null, NULL, non_null, KNOT_CLASS_NONE, KNOT_RRTYPE_ANY);
+       assert_int_equal(ret, KNOT_EINVAL);
+       ret = kr_resolve(non_null, non_null, NULL, KNOT_CLASS_NONE, KNOT_RRTYPE_ANY);
+       assert_int_equal(ret, KNOT_EINVAL);
 }
 
 int main(void)
 {
        const UnitTest tests[] = {
-               unit_test(test_resolve_sync),
+               /* Parameter sanity checks */
+               unit_test(test_resolve_nullparams)
        };
 
        return run_tests(tests);