blob: e60101835cc8a223ef9a05d2c3123c69ec34b07d [file] [log] [blame]
Radek Krejci3a4889a2020-05-19 17:01:58 +02001/*
2 * @file test_schema.c
3 * @author: Radek Krejci <rkrejci@cesnet.cz>
4 * @brief unit tests for schema related functions
5 *
6 * Copyright (c) 2018-2019 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 */
Radek Iša56ca9e42020-09-08 18:42:00 +020014#define _UTEST_MAIN_
Radek Krejci18abde42020-06-13 20:04:39 +020015#include "test_schema.h"
16
Radek Krejcica376bd2020-06-11 16:04:06 +020017#include <string.h>
18
Radek Krejci18abde42020-06-13 20:04:39 +020019#include "log.h"
20#include "parser_schema.h"
Radek Krejci8297b792020-08-16 14:49:05 +020021#include "set.h"
Radek Krejci18abde42020-06-13 20:04:39 +020022#include "tree_schema.h"
Radek Krejci3a4889a2020-05-19 17:01:58 +020023
Radek Krejci18abde42020-06-13 20:04:39 +020024LY_ERR
25test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
Radek Krejcib4ac5a92020-11-23 17:54:33 +010026 const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
27 const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
Radek Krejci18abde42020-06-13 20:04:39 +020028{
29 *module_data = user_data;
Radek Krejci85ac8312021-03-03 20:21:33 +010030 if ((*module_data)[0] == '<') {
31 *format = LYS_IN_YIN;
32 } else {
33 *format = LYS_IN_YANG;
34 }
Radek Krejci18abde42020-06-13 20:04:39 +020035 *free_module_data = NULL;
36 return LY_SUCCESS;
37}
Radek Krejci3a4889a2020-05-19 17:01:58 +020038
39/**
Radek Krejci18abde42020-06-13 20:04:39 +020040 * DECLARE OTHER SCHEMA TESTS
Radek Krejci3a4889a2020-05-19 17:01:58 +020041 */
Radek Krejci18abde42020-06-13 20:04:39 +020042/* test_schema_common.c */
43void test_getnext(void **state);
44void test_date(void **state);
45void test_revisions(void **state);
aPiecek4f49a142021-06-29 15:32:39 +020046void test_collision_typedef(void **state);
aPiecek0b365612021-06-30 13:12:58 +020047void test_collision_grouping(void **state);
aPiecek14d07f02021-06-30 09:46:50 +020048void test_collision_identity(void **state);
49void test_collision_feature(void **state);
Michal Vasko6b26e742020-07-17 15:02:10 +020050void test_accessible_tree(void **state);
Radek Krejci589c5472021-01-20 10:29:06 +010051void test_includes(void **state);
Radek Krejci18abde42020-06-13 20:04:39 +020052
53/* test_schema_stmts.c */
54void test_identity(void **state);
55void test_feature(void **state);
Radek Krejci3a4889a2020-05-19 17:01:58 +020056
Radek Krejci85ac8312021-03-03 20:21:33 +010057/* test_schema_extensions.c */
58void test_extension_argument(void **state);
59void test_extension_argument_element(void **state);
60
Radek Krejcib4ac5a92020-11-23 17:54:33 +010061int
62main(void)
Radek Krejci3a4889a2020-05-19 17:01:58 +020063{
64 const struct CMUnitTest tests[] = {
65 /** test_schema_common.c */
Radek Iša56ca9e42020-09-08 18:42:00 +020066 UTEST(test_getnext),
67 UTEST(test_date),
68 UTEST(test_revisions),
aPiecek4f49a142021-06-29 15:32:39 +020069 UTEST(test_collision_typedef),
aPiecek0b365612021-06-30 13:12:58 +020070 UTEST(test_collision_grouping),
aPiecek14d07f02021-06-30 09:46:50 +020071 UTEST(test_collision_identity),
72 UTEST(test_collision_feature),
Radek Iša56ca9e42020-09-08 18:42:00 +020073 UTEST(test_accessible_tree),
Radek Krejci589c5472021-01-20 10:29:06 +010074 UTEST(test_includes),
Radek Krejci3a4889a2020-05-19 17:01:58 +020075
76 /** test_schema_stmts.c */
Radek Iša56ca9e42020-09-08 18:42:00 +020077 UTEST(test_identity),
78 UTEST(test_feature),
Radek Krejci85ac8312021-03-03 20:21:33 +010079
80 /** test_schema_extensions.c */
81 UTEST(test_extension_argument),
82 UTEST(test_extension_argument_element),
Radek Krejci3a4889a2020-05-19 17:01:58 +020083 };
84
85 return cmocka_run_group_tests(tests, NULL, NULL);
86}