Exemple #1
0
static void
test_mult_revisions(void **state)
{
    struct ly_ctx *ctx = *state;
    const char *sch_yang = "module main_mod {"
        "namespace \"urn:cesnet:test:a\";"
        "prefix \"a\";"
        "include submod_r { revision-date \"2016-06-19\";}"
        "include submod1;}";
    const char *sch_correct_yang = "module main_mod {"
        "namespace \"urn:cesnet:test:a\";"
        "prefix \"a\";"
        "include submod_r;"
        "include submod1;}";
    const char *sch_yin = "<module name=\"main_mod\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
        "<namespace uri=\"urn:cesnet:test:a\"/><prefix value=\"a\"/>"
        "<include module=\"submod_r\"><revision-date date=\"2016-06-19\"/></include>"
        "<include module=\"submod1\"/></module>";
    const char *sch_correct_yin = "<module name=\"main_mod\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
        "<namespace uri=\"urn:cesnet:test:a\"/><prefix value=\"a\"/>"
        "<include module=\"submod_r\"/>"
        "<include module=\"submod1\"/></module>";

    ly_ctx_set_searchdir(ctx, SCHEMA_FOLDER_YIN);

    assert_ptr_equal(lys_parse_mem(ctx, sch_yin, LYS_IN_YIN), NULL);
    assert_ptr_not_equal(lys_parse_mem(ctx, sch_correct_yin, LYS_IN_YIN), NULL);

    ly_ctx_destroy(*state, NULL);
    *state = ctx = ly_ctx_new(SCHEMA_FOLDER_YANG);

    assert_ptr_equal(lys_parse_mem(ctx, sch_yang, LYS_IN_YANG), NULL);
    assert_ptr_not_equal(lys_parse_mem(ctx, sch_correct_yang, LYS_IN_YANG), NULL);
}
Exemple #2
0
int
cmd_searchpath(const char *arg)
{
    const char *path;
    struct stat st;

    if (strchr(arg, ' ') == NULL) {
        fprintf(stderr, "Missing the search path.\n");
        return 1;
    }
    path = strchr(arg, ' ')+1;

    if (!strcmp(path, "-h") || !strcmp(path, "--help")) {
        cmd_searchpath_help();
        return 0;
    }

    if (stat(path, &st) == -1) {
        fprintf(stderr, "Failed to stat the search path (%s).\n", strerror(errno));
        return 1;
    }
    if (!S_ISDIR(st.st_mode)) {
        fprintf(stderr, "\"%s\" is not a directory.\n", path);
        return 1;
    }

    free(search_path);
    search_path = strdup(path);

    ly_ctx_set_searchdir(ctx, search_path);

    return 0;
}
Exemple #3
0
static void
test_circular_include(void **state)
{
    struct ly_ctx *ctx = *state;
    const char *sch_yang = "module main-mod {"
        "namespace \"urn:cesnet:test:a\";"
        "prefix \"a\";"
        "include circ_inc1;}";
    const char *sch_yin = "<module name=\"main-mod\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
        "<namespace uri=\"urn:cesnet:test:a\"/><prefix value=\"a\"/>"
        "<include module=\"circ_inc1\"/></module>";

    ly_ctx_set_searchdir(ctx, SCHEMA_FOLDER_YIN);

    assert_ptr_equal(lys_parse_mem(ctx, sch_yin, LYS_IN_YIN), NULL);
    assert_int_equal(ly_vecode, LYVE_CIRC_INCLUDES);

    ly_ctx_set_searchdir(ctx, SCHEMA_FOLDER_YANG);

    assert_ptr_equal(lys_parse_mem(ctx, sch_yang, LYS_IN_YANG), NULL);
    assert_int_equal(ly_vecode, LYVE_CIRC_INCLUDES);
}