Skip to content

Commit acf092d

Browse files
michalvaskomanoe
authored andcommitted
tests BUGFIX libyang ctx search dir
1 parent 7122475 commit acf092d

6 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/ly_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
/** YANG module dir */
4141
#define LY_YANG_MODULE_DIR "@YANG_MODULE_DIR@"
4242

43+
/** lib source dir */
44+
#define LY_SRC_DIR "@CMAKE_CURRENT_SOURCE_DIR@"
45+
4346
/** atomic compiler operations, to be able to use uint32_t */
4447
#ifndef _WIN32
4548
# define LY_ATOMIC_INC_BARRIER(var) __sync_fetch_and_add(&(var), 1)

tests/fuzz/lyd_parse_mem_json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
6060
log = true;
6161
}
6262

63-
err = ly_ctx_new(NULL, 0, &ctx);
63+
err = ly_ctx_new(LY_SRC_DIR "/modules", 0, &ctx);
6464
if (err != LY_SUCCESS) {
6565
fprintf(stderr, "Failed to create context\n");
6666
exit(EXIT_FAILURE);

tests/fuzz/lyd_parse_mem_xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
6060
log = true;
6161
}
6262

63-
err = ly_ctx_new(NULL, 0, &ctx);
63+
err = ly_ctx_new(LY_SRC_DIR "/modules", 0, &ctx);
6464
if (err != LY_SUCCESS) {
6565
fprintf(stderr, "Failed to create context\n");
6666
exit(EXIT_FAILURE);

tests/fuzz/lys_parse_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
1616
log = true;
1717
}
1818

19-
err = ly_ctx_new(NULL, 0, &ctx);
19+
err = ly_ctx_new(LY_SRC_DIR "/modules", 0, &ctx);
2020
if (err != LY_SUCCESS) {
2121
fprintf(stderr, "Failed to create context\n");
2222
exit(EXIT_FAILURE);

tests/fuzz/yang_parse_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len)
1717
log = true;
1818
}
1919

20-
err = ly_ctx_new(NULL, 0, &ctx);
20+
err = ly_ctx_new(LY_SRC_DIR "/modules", 0, &ctx);
2121
if (err != LY_SUCCESS) {
2222
fprintf(stderr, "Failed to create new context\n");
2323
return 0;

tests/perf/perf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,10 @@ main(int argc, char **argv)
912912
(tries > 1) ? "times" : "time");
913913

914914
/* create context */
915-
if ((ret = ly_ctx_new(TESTS_SRC "/perf", 0, &ctx))) {
915+
if ((ret = ly_ctx_new(LY_SRC_DIR "/modules", 0, &ctx))) {
916+
goto cleanup;
917+
}
918+
if ((ret = ly_ctx_set_searchdir(ctx, TESTS_SRC "/perf"))) {
916919
goto cleanup;
917920
}
918921

0 commit comments

Comments
 (0)