blob: 5209dd182d1c3e0bb7bcf4c68378297c8c3f8f72 [file] [log] [blame]
tadeas-vintrlikbf8aa6e2021-11-03 13:07:34 +01001/*
2 * @file test_schema_mount.c
3 * @author: Tadeas Vintrlik <xvintr04@stud.fit.vutbr.cz>
4 * @brief unit tests for Schema Mount extension support
5 *
6 * Copyright (c) 2021 CESNET, z.s.p.o.
7 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
14#define _UTEST_MAIN_
15#include "utests.h"
16
17#include "libyang.h"
18
19static int
20setup(void **state)
21{
22 UTEST_SETUP;
23
24 assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG));
25 assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-yang-schema-mount", "2019-01-14", NULL));
26
27 return 0;
28}
29
30static void
31test_compile(void **state)
32{
33 struct lys_module *mod;
34 const char *data = "module test-parent {yang-version 1.1;namespace \"urn:test-parent\";"
35 "prefix \"tp\"; import ietf-yang-schema-mount {prefix yangmnt;} container root {"
36 "yangmnt:mount-point \"root\" {}}}";
37
38 assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, &mod));
39}
40
41static void
42test_parse_no_yanglib(void **state)
43{
44 struct ly_ctx *new;
45 const char *data = "<root/>";
46
47 assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &new));
48}
49
50int
51main(void)
52{
53 const struct CMUnitTest tests[] = {
54 UTEST(test_compile, setup),
55 };
56
57 return cmocka_run_group_tests(tests, NULL, NULL);
58}