blob: 949ffdfa0a51716af8d2efd4591eb9772186346a [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);
Michal Vaskoac4450e2021-11-09 13:53:40 +010052void test_key_order(void **state);
Michal Vaskof4fa90d2021-11-11 15:05:19 +010053void test_disabled_enum(void **state);
Radek Krejci18abde42020-06-13 20:04:39 +020054
55/* test_schema_stmts.c */
56void test_identity(void **state);
57void test_feature(void **state);
Radek Krejci3a4889a2020-05-19 17:01:58 +020058
Radek Krejci85ac8312021-03-03 20:21:33 +010059/* test_schema_extensions.c */
60void test_extension_argument(void **state);
61void test_extension_argument_element(void **state);
62
Radek Krejcib4ac5a92020-11-23 17:54:33 +010063int
64main(void)
Radek Krejci3a4889a2020-05-19 17:01:58 +020065{
66 const struct CMUnitTest tests[] = {
67 /** test_schema_common.c */
Radek Iša56ca9e42020-09-08 18:42:00 +020068 UTEST(test_getnext),
69 UTEST(test_date),
70 UTEST(test_revisions),
aPiecek4f49a142021-06-29 15:32:39 +020071 UTEST(test_collision_typedef),
aPiecek0b365612021-06-30 13:12:58 +020072 UTEST(test_collision_grouping),
aPiecek14d07f02021-06-30 09:46:50 +020073 UTEST(test_collision_identity),
74 UTEST(test_collision_feature),
Radek Iša56ca9e42020-09-08 18:42:00 +020075 UTEST(test_accessible_tree),
Radek Krejci589c5472021-01-20 10:29:06 +010076 UTEST(test_includes),
Michal Vaskoac4450e2021-11-09 13:53:40 +010077 UTEST(test_key_order),
Michal Vaskof4fa90d2021-11-11 15:05:19 +010078 UTEST(test_disabled_enum),
Radek Krejci3a4889a2020-05-19 17:01:58 +020079
80 /** test_schema_stmts.c */
Radek Iša56ca9e42020-09-08 18:42:00 +020081 UTEST(test_identity),
82 UTEST(test_feature),
Radek Krejci85ac8312021-03-03 20:21:33 +010083
84 /** test_schema_extensions.c */
85 UTEST(test_extension_argument),
86 UTEST(test_extension_argument_element),
Radek Krejci3a4889a2020-05-19 17:01:58 +020087 };
88
89 return cmocka_run_group_tests(tests, NULL, NULL);
90}