tests UPDATE fuzz build and sources updated
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index 66c0353..98737c7 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -1,32 +1,28 @@
-cmake_minimum_required(VERSION 2.8.12)
+if(ENABLE_FUZZ_TARGETS)
+    set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json buf_add_char yang_parse_module)
 
-if (ENABLE_FUZZ_TARGETS)
-	set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json buf_add_char yang_parse_module)
-
-	if(FUZZER STREQUAL "AFL")
-		foreach(target_name IN LISTS fuzz_targets)
-		    add_executable(${target_name}_fuzz_harness ${target_name}.c main.c $<TARGET_OBJECTS:yangobj>)
-		    target_link_libraries(${target_name}_fuzz_harness yang)
-		    target_link_libraries(${target_name}_fuzz_harness ${CMAKE_THREADS_LIB_INIT})
-		endforeach(target_name)
-	elseif(FUZZER STREQUAL "LibFuzzer")
-		foreach(target_name IN LISTS fuzz_targets)
-			add_executable(${target_name}_fuzz_harness ${target_name}.c $<TARGET_OBJECTS:yangobj>)
-			set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
-			target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer")
-		endforeach(target_name)
-	endif()
+    if(FUZZER STREQUAL "AFL")
+        foreach(target_name IN LISTS fuzz_targets)
+            add_executable(${target_name}_fuzz_harness ${target_name}.c main.c)
+            target_link_libraries(${target_name}_fuzz_harness yang)
+        endforeach()
+    elseif()
+        foreach(target_name IN LISTS fuzz_targets)
+            add_executable(${target_name}_fuzz_harness ${target_name}.c)
+            set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
+            target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer")
+        endforeach()
+    endif()
 endif()
 
-if (ENABLE_TESTS)
-	add_executable(fuzz_regression_test fuzz_regression_test.c)
-	set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json)
-	foreach(target_name IN LISTS fuzz_regression_tests)
-	    file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/)
-	    add_executable(regress_fuzz_${target_name} ${target_name}.c main.c $<TARGET_OBJECTS:yangobj>)
-	    set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}")
-	    target_link_libraries(regress_fuzz_${target_name} yang)
-	    target_link_libraries(regress_fuzz_${target_name} ${CMAKE_THREADS_LIB_INIT})
-	    add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name})
-	endforeach(target_name)
+if(ENABLE_TESTS)
+    add_executable(fuzz_regression_test fuzz_regression_test.c)
+    set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json)
+    foreach(target_name IN LISTS fuzz_regression_tests)
+        file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/)
+        add_executable(regress_fuzz_${target_name} ${target_name}.c main.c)
+        set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}")
+        target_link_libraries(regress_fuzz_${target_name} yang)
+        add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name})
+    endforeach()
 endif()
diff --git a/tests/fuzz/lyd_parse_mem_json.c b/tests/fuzz/lyd_parse_mem_json.c
index c102f72..0acad34 100644
--- a/tests/fuzz/lyd_parse_mem_json.c
+++ b/tests/fuzz/lyd_parse_mem_json.c
@@ -6,11 +6,14 @@
 
 int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
 {
-	struct ly_ctx *ctx = NULL;
-	static bool log = false;
-	const char *schema_a = "module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
-		            "identity crypto-alg; identity interface-type; identity ethernet {base interface-type;} identity fast-ethernet {base ethernet;}}";
-	const char *schema_b = "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
+    struct ly_ctx *ctx = NULL;
+    static bool log = false;
+    const char *schema_a =
+            "module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
+            "identity crypto-alg; identity interface-type; identity ethernet {base interface-type;}"
+            "identity fast-ethernet {base ethernet;}}";
+    const char *schema_b =
+            "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
             "feature f; identity gigabit-ethernet { base defs:ethernet;}"
             "container cont {leaf leaftarget {type empty;}"
                             "list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
@@ -40,7 +43,7 @@
             "leaf bool {type boolean;}"
             "leaf empty {type empty;}"
             "leaf ident {type identityref {base defs:interface-type;}}"
- 	    "leaf inst {type instance-identifier {require-instance true;}}"
+            "leaf inst {type instance-identifier {require-instance true;}}"
             "leaf inst-noreq {type instance-identifier {require-instance false;}}"
             "leaf lref {type leafref {path /leaflisttarget; require-instance true;}}"
             "leaf lref2 {type leafref {path \"../list[id = current()/../str-norestr]/targets\"; require-instance true;}}"
@@ -48,37 +51,36 @@
             "type leafref {path /int8; require-instance true;}"
             "type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
             "type string {length 1..20;}}}}";
-    	char *data = NULL;
-	struct lyd_node *tree = NULL;
+    char *data = NULL;
+    struct lyd_node *tree = NULL;
+    LY_ERR err;
 
-	LY_ERR err;
+    if (!log) {
+        ly_log_options(0);
+        log = true;
+    }
 
-	if (!log) {
-		ly_log_options(0);
-		log = true;
-	}
+    err = ly_ctx_new(NULL, 0, &ctx);
+    if (err != LY_SUCCESS) {
+        fprintf(stderr, "Failed to create context\n");
+        exit(EXIT_FAILURE);
+    }
 
-	err = ly_ctx_new(NULL, 0, &ctx);
-	if (err != LY_SUCCESS) {
-		fprintf(stderr, "Failed to create context\n");
-		exit(EXIT_FAILURE);
-	}
+    lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
+    lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
 
-	lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
-	lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
+    data = malloc(len + 1);
+    if (data == NULL) {
+        return 0;
+    }
+    memcpy(data, buf, len);
+    data[len] = 0;
 
-	data = malloc(len + 1);
-	if (data == NULL) {
-		return 0;
-	}
-	memcpy(data, buf, len);
-	data[len] = 0;
+    lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree);
+    lyd_free_all(tree);
+    ly_ctx_destroy(ctx);
 
-	lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree);
-	lyd_free_all(tree);
-	ly_ctx_destroy(ctx);
+    free(data);
 
-	free(data);
-
-	return 0;
+    return 0;
 }
diff --git a/tests/fuzz/lyd_parse_mem_xml.c b/tests/fuzz/lyd_parse_mem_xml.c
index e938816..5574f8d 100644
--- a/tests/fuzz/lyd_parse_mem_xml.c
+++ b/tests/fuzz/lyd_parse_mem_xml.c
@@ -6,11 +6,14 @@
 
 int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
 {
-	struct ly_ctx *ctx = NULL;
-	static bool log = false;
-	const char *schema_a = "module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
-		            "identity crypto-alg; identity interface-type; identity ethernet {base interface-type;} identity fast-ethernet {base ethernet;}}";
-	const char *schema_b = "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
+    struct ly_ctx *ctx = NULL;
+    static bool log = false;
+    const char *schema_a =
+            "module defs {namespace urn:tests:defs;prefix d;yang-version 1.1;"
+            "identity crypto-alg; identity interface-type; identity ethernet {base interface-type;}"
+            "identity fast-ethernet {base ethernet;}}";
+    const char *schema_b =
+            "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
             "feature f; identity gigabit-ethernet { base defs:ethernet;}"
             "container cont {leaf leaftarget {type empty;}"
                             "list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
@@ -40,7 +43,7 @@
             "leaf bool {type boolean;}"
             "leaf empty {type empty;}"
             "leaf ident {type identityref {base defs:interface-type;}}"
- 	    "leaf inst {type instance-identifier {require-instance true;}}"
+            "leaf inst {type instance-identifier {require-instance true;}}"
             "leaf inst-noreq {type instance-identifier {require-instance false;}}"
             "leaf lref {type leafref {path /leaflisttarget; require-instance true;}}"
             "leaf lref2 {type leafref {path \"../list[id = current()/../str-norestr]/targets\"; require-instance true;}}"
@@ -48,37 +51,36 @@
             "type leafref {path /int8; require-instance true;}"
             "type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
             "type string {length 1..20;}}}}";
-    	char *data = NULL;
-	struct lyd_node *tree = NULL;
+    char *data = NULL;
+    struct lyd_node *tree = NULL;
+    LY_ERR err;
 
-	LY_ERR err;
+    if (!log) {
+        ly_log_options(0);
+        log = true;
+    }
 
-	if (!log) {
-		ly_log_options(0);
-		log = true;
-	}
+    err = ly_ctx_new(NULL, 0, &ctx);
+    if (err != LY_SUCCESS) {
+        fprintf(stderr, "Failed to create context\n");
+        exit(EXIT_FAILURE);
+    }
 
-	err = ly_ctx_new(NULL, 0, &ctx);
-	if (err != LY_SUCCESS) {
-		fprintf(stderr, "Failed to create context\n");
-		exit(EXIT_FAILURE);
-	}
+    lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
+    lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
 
-	lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL);
-	lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL);
+    data = malloc(len + 1);
+    if (data == NULL) {
+        return 0;
+    }
+    memcpy(data, buf, len);
+    data[len] = 0;
 
-	data = malloc(len + 1);
-	if (data == NULL) {
-		return 0;
-	}
-	memcpy(data, buf, len);
-	data[len] = 0;
+    lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree);
+    lyd_free_all(tree);
+    ly_ctx_destroy(ctx);
 
-	lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree);
-	lyd_free_all(tree);
-	ly_ctx_destroy(ctx);
+    free(data);
 
-	free(data);
-
-	return 0;
+    return 0;
 }
diff --git a/tests/fuzz/lys_parse_mem.c b/tests/fuzz/lys_parse_mem.c
index ea244d1..02e0a62 100644
--- a/tests/fuzz/lys_parse_mem.c
+++ b/tests/fuzz/lys_parse_mem.c
@@ -6,32 +6,32 @@
 
 int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
 {
-	struct ly_ctx *ctx = NULL;
-	static bool log = false;
-	char *data = NULL;
-	LY_ERR err;
+    struct ly_ctx *ctx = NULL;
+    static bool log = false;
+    char *data = NULL;
+    LY_ERR err;
 
-	if (!log) {
-		ly_log_options(0);
-		log = true;
-	}
+    if (!log) {
+        ly_log_options(0);
+        log = true;
+    }
 
-	err = ly_ctx_new(NULL, 0, &ctx);
-	if (err != LY_SUCCESS) {
-		fprintf(stderr, "Failed to create context\n");
-		exit(EXIT_FAILURE);
-	}
+    err = ly_ctx_new(NULL, 0, &ctx);
+    if (err != LY_SUCCESS) {
+        fprintf(stderr, "Failed to create context\n");
+        exit(EXIT_FAILURE);
+    }
 
-	data = malloc(len + 1);
-	if (data == NULL) {
-		return 0;
-	}
+    data = malloc(len + 1);
+    if (data == NULL) {
+        return 0;
+    }
 
-	memcpy(data, buf, len);
-	data[len] = 0;
+    memcpy(data, buf, len);
+    data[len] = 0;
 
-	lys_parse_mem(ctx, data, LYS_IN_YANG, NULL);
-	ly_ctx_destroy(ctx);
-	free(data);
-	return 0;
+    lys_parse_mem(ctx, data, LYS_IN_YANG, NULL);
+    ly_ctx_destroy(ctx);
+    free(data);
+    return 0;
 }
diff --git a/tests/fuzz/main.c b/tests/fuzz/main.c
index 1c0c4d7..a4b64b5 100644
--- a/tests/fuzz/main.c
+++ b/tests/fuzz/main.c
@@ -7,37 +7,41 @@
 #ifdef  __AFL_COMPILER
 
 int main(void) {
-	int ret;
-	uint8_t buf[64 * 1024];
+    int ret;
+    uint8_t buf[64 * 1024];
 
 #ifdef __AFL_LOOP
-	while (__AFL_LOOP(10000))
+    while (__AFL_LOOP(10000))
 #endif
-	{
-		ret = fread(buf, 1, sizeof(buf), stdin);
-		if (ret < 0) {
-			return 0;
-		}
+    {
+        ret = fread(buf, 1, sizeof(buf), stdin);
+        if (ret < 0) {
+            return 0;
+        }
 
-		LLVMFuzzerTestOneInput(buf, ret);
+        LLVMFuzzerTestOneInput(buf, ret);
 
-	}
+    }
 
-	return 0;
+    return 0;
 }
 
 #else
-int main(void) {
-	int ret;
-	uint8_t buf[64 * 1024];
 
-	ret = fread(buf, 1, sizeof(buf), stdin);
-	if (ret < 0) {
-		return 0;
-	}
+int
+main(void)
+{
+    int ret;
+    uint8_t buf[64 * 1024];
 
-	LLVMFuzzerTestOneInput(buf, ret);
+    ret = fread(buf, 1, sizeof(buf), stdin);
+    if (ret < 0) {
+        return 0;
+    }
 
-	return 0;
+    LLVMFuzzerTestOneInput(buf, ret);
+
+    return 0;
 }
+
 #endif /* __AFL_COMPILER */
diff --git a/tests/fuzz/yang_parse_module.c b/tests/fuzz/yang_parse_module.c
index 5c235a2..f420966 100644
--- a/tests/fuzz/yang_parse_module.c
+++ b/tests/fuzz/yang_parse_module.c
@@ -2,50 +2,38 @@
 #include <stdlib.h>
 #include <stdbool.h>
 
-#include "../../src/common.h"
-#include "../../src/tree_schema_internal.h"
-
-LY_ERR yang_parse_module(struct lys_yang_parser_ctx **context, const char *data, struct lys_module *mod);
+#include "libyang.h"
 
 int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
 {
-	struct lys_module *mod = NULL;
-	struct lys_yang_parser_ctx *context = NULL;
-	uint8_t *data = NULL;
-	struct ly_ctx *ctx = NULL;
-	static bool log = false; 
-	LY_ERR err;
-	
-	if (!log) {
-		ly_log_options(0);
-		log = true;
-	}
+    struct lys_module *mod;
+    uint8_t *data = NULL;
+    struct ly_ctx *ctx = NULL;
+    static bool log = false;
+    LY_ERR err;
 
-	err = ly_ctx_new(NULL, 0, &ctx);
-	if (err != LY_SUCCESS) {
-		fprintf(stderr, "Failed to create new context\n");
-		return 0;
-	}
+    if (!log) {
+        ly_log_options(0);
+        log = true;
+    }
 
-	data = malloc(len + 1);
-	if (data == NULL) {
-		fprintf(stderr, "Out of memory\n");
-		return 0;
-	}
-	memcpy(data, buf, len);
-	data[len] = 0;
+    err = ly_ctx_new(NULL, 0, &ctx);
+    if (err != LY_SUCCESS) {
+        fprintf(stderr, "Failed to create new context\n");
+        return 0;
+    }
 
-	mod = calloc(1, sizeof *mod);
-	if (mod == NULL) {
-		fprintf(stderr, "Out of memory\n");
-		return 0;
-	}
-	mod->ctx = ctx;
+    data = malloc(len + 1);
+    if (data == NULL) {
+        fprintf(stderr, "Out of memory\n");
+        return 0;
+    }
+    memcpy(data, buf, len);
+    data[len] = 0;
 
-	yang_parse_module(&context, (const char *) data, mod);
+    lys_parse_mem(ctx, (const char *)data, LYS_IN_YANG, &mod);
 
-	free(data);
-	free(mod);
-	ly_ctx_destroy(ctx);
-	return 0;
+    free(data);
+    ly_ctx_destroy(ctx);
+    return 0;
 }