blob: 2fe71c63f6d9672aef859026258860a30f998d92 [file] [log] [blame]
Radek Krejci509e2592019-05-15 16:30:48 +02001/*
2 * @file test_parser_xml.c
3 * @author: Radek Krejci <rkrejci@cesnet.cz>
4 * @brief unit tests for functions from parser_xml.c
5 *
6 * Copyright (c) 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 */
14
Radek Krejci70593c12020-06-13 20:48:09 +020015#include "context.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020016#include "in.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020017#include "out.h"
Radek Krejcib4ac5a92020-11-23 17:54:33 +010018#include "parser_data.h"
Radek Krejci70593c12020-06-13 20:48:09 +020019#include "printer_data.h"
20#include "tests/config.h"
21#include "tree_data_internal.h"
22#include "tree_schema.h"
Radek Krejcib4ac5a92020-11-23 17:54:33 +010023#include "utests.h"
Radek Krejci509e2592019-05-15 16:30:48 +020024
25#define BUFSIZE 1024
26char logbuf[BUFSIZE] = {0};
27int store = -1; /* negative for infinite logging, positive for limited logging */
28
29struct ly_ctx *ctx; /* context for tests */
30
31/* set to 0 to printing error messages to stderr instead of checking them in code */
32#define ENABLE_LOGGER_CHECKING 1
33
34#if ENABLE_LOGGER_CHECKING
35static void
36logger(LY_LOG_LEVEL level, const char *msg, const char *path)
37{
38 (void) level; /* unused */
39 if (store) {
40 if (path && path[0]) {
41 snprintf(logbuf, BUFSIZE - 1, "%s %s", msg, path);
42 } else {
43 strncpy(logbuf, msg, BUFSIZE - 1);
44 }
45 if (store > 0) {
46 --store;
47 }
48 }
49}
Radek Krejcib4ac5a92020-11-23 17:54:33 +010050
Radek Krejci509e2592019-05-15 16:30:48 +020051#endif
52
53static int
54setup(void **state)
55{
56 (void) state; /* unused */
57
Radek Krejcib4ac5a92020-11-23 17:54:33 +010058 const char *schema_a =
59 "module a {\n"
60 " namespace urn:tests:a;\n"
61 " prefix a;\n"
62 " yang-version 1.1;\n"
63 " list l1 {\n"
64 " key \"a b c\";\n"
65 " leaf a {type string;}\n"
66 " leaf b {type string;}\n"
67 " leaf c {type int16;}\n"
68 " leaf d {type string;}}\n"
69 " leaf foo { type string;}\n"
70 " container c {\n"
71 " leaf x {type string;}\n"
72 " action act { input { leaf al {type string;} } output { leaf al {type uint8;} } }\n"
73 " notification n1 { leaf nl {type string;}}}\n"
74 " container cp {presence \"container switch\"; leaf y {type string;} leaf z {type int8;}}\n"
75 " anydata any {config false;}\n"
76 " leaf foo2 { type string; default \"default-val\"; }\n"
77 " leaf foo3 { type uint32; }\n"
78 " notification n2;}";
Michal Vaskob36053d2020-03-26 15:49:30 +010079 const struct lys_module *mod;
Michal Vasko7b1ad1a2020-11-02 15:41:27 +010080 const char *feats[] = {"writable-running", NULL};
Radek Krejci509e2592019-05-15 16:30:48 +020081
82#if ENABLE_LOGGER_CHECKING
83 ly_set_log_clb(logger, 1);
84#endif
85
Michal Vasko8d544252020-03-02 10:19:52 +010086 assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
Michal Vasko7b1ad1a2020-11-02 15:41:27 +010087 assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01", feats)));
88 assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
Michal Vasko3a41dff2020-07-15 14:30:28 +020089 assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
Radek Krejci509e2592019-05-15 16:30:48 +020090
91 return 0;
92}
93
94static int
95teardown(void **state)
96{
97#if ENABLE_LOGGER_CHECKING
98 if (*state) {
99 fprintf(stderr, "%s\n", logbuf);
100 }
101#else
102 (void) state; /* unused */
103#endif
104
105 ly_ctx_destroy(ctx, NULL);
106 ctx = NULL;
107
108 return 0;
109}
110
111void
112logbuf_clean(void)
113{
114 logbuf[0] = '\0';
115}
116
117#if ENABLE_LOGGER_CHECKING
118# define logbuf_assert(str) assert_string_equal(logbuf, str)
119#else
120# define logbuf_assert(str)
121#endif
122
Radek Krejci509e2592019-05-15 16:30:48 +0200123static void
124test_leaf(void **state)
125{
126 *state = test_leaf;
127
128 const char *data = "<foo xmlns=\"urn:tests:a\">foo value</foo>";
129 struct lyd_node *tree;
130 struct lyd_node_term *leaf;
131
Michal Vasko63f3d842020-07-08 10:10:14 +0200132 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejci509e2592019-05-15 16:30:48 +0200133 assert_non_null(tree);
134 assert_int_equal(LYS_LEAF, tree->schema->nodetype);
135 assert_string_equal("foo", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100136 leaf = (struct lyd_node_term *)tree;
Michal Vaskoba99a3e2020-08-18 15:50:05 +0200137 assert_string_equal("foo value", leaf->value.canonical);
Radek Krejci509e2592019-05-15 16:30:48 +0200138
Michal Vasko8d544252020-03-02 10:19:52 +0100139 assert_int_equal(LYS_LEAF, tree->next->next->schema->nodetype);
140 assert_string_equal("foo2", tree->next->next->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100141 leaf = (struct lyd_node_term *)tree->next->next;
Michal Vaskoba99a3e2020-08-18 15:50:05 +0200142 assert_string_equal("default-val", leaf->value.canonical);
Michal Vasko8d544252020-03-02 10:19:52 +0100143 assert_true(leaf->flags & LYD_DEFAULT);
144
Radek Krejci509e2592019-05-15 16:30:48 +0200145 lyd_free_all(tree);
Michal Vasko8d544252020-03-02 10:19:52 +0100146
147 /* make foo2 explicit */
148 data = "<foo2 xmlns=\"urn:tests:a\">default-val</foo2>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200149 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko8d544252020-03-02 10:19:52 +0100150 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100151 tree = tree->next;
Michal Vasko8d544252020-03-02 10:19:52 +0100152 assert_int_equal(LYS_LEAF, tree->schema->nodetype);
153 assert_string_equal("foo2", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100154 leaf = (struct lyd_node_term *)tree;
Michal Vaskoba99a3e2020-08-18 15:50:05 +0200155 assert_string_equal("default-val", leaf->value.canonical);
Michal Vasko8d544252020-03-02 10:19:52 +0100156 assert_false(leaf->flags & LYD_DEFAULT);
157
158 lyd_free_all(tree);
159
Radek Krejci1798aae2020-07-14 13:26:06 +0200160 /* parse foo2 but make it implicit, skip metadata xxx from missing schema */
161 data = "<foo2 xmlns=\"urn:tests:a\" xmlns:wd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" wd:default=\"true\" xmlns:x=\"urn:x\" x:xxx=\"false\">default-val</foo2>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200162 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko8d544252020-03-02 10:19:52 +0100163 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100164 tree = tree->next;
Michal Vasko8d544252020-03-02 10:19:52 +0100165 assert_int_equal(LYS_LEAF, tree->schema->nodetype);
166 assert_string_equal("foo2", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100167 leaf = (struct lyd_node_term *)tree;
Michal Vaskoba99a3e2020-08-18 15:50:05 +0200168 assert_string_equal("default-val", leaf->value.canonical);
Michal Vasko8d544252020-03-02 10:19:52 +0100169 assert_true(leaf->flags & LYD_DEFAULT);
170
171 lyd_free_all(tree);
172
Radek Krejci509e2592019-05-15 16:30:48 +0200173 *state = NULL;
174}
175
Radek Krejciee4cab22019-07-17 17:07:47 +0200176static void
177test_anydata(void **state)
178{
179 *state = test_anydata;
180
Michal Vasko52927e22020-03-16 17:26:14 +0100181 const char *data;
182 char *str;
Radek Krejciee4cab22019-07-17 17:07:47 +0200183 struct lyd_node *tree;
Radek Krejciee4cab22019-07-17 17:07:47 +0200184
Radek Krejci241f6b52020-05-21 18:13:49 +0200185 struct ly_out *out;
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100186
Radek Krejci84ce7b12020-06-11 17:28:25 +0200187 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
Radek Krejcia5bba312020-01-09 15:41:20 +0100188
Michal Vasko52927e22020-03-16 17:26:14 +0100189 data =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100190 "<any xmlns=\"urn:tests:a\">\n"
191 " <element1>\n"
192 " <x:element2 x:attr2=\"test\" xmlns:a=\"urn:tests:a\" xmlns:x=\"urn:x\">a:data</x:element2>\n"
193 " </element1>\n"
194 " <element1a/>\n"
195 "</any>\n";
Michal Vasko63f3d842020-07-08 10:10:14 +0200196 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejciee4cab22019-07-17 17:07:47 +0200197 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100198 tree = tree->next;
Radek Krejciee4cab22019-07-17 17:07:47 +0200199 assert_int_equal(LYS_ANYDATA, tree->schema->nodetype);
200 assert_string_equal("any", tree->schema->name);
Michal Vasko52927e22020-03-16 17:26:14 +0100201
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100202 lyd_print_tree(out, tree, LYD_XML, 0);
Michal Vasko52927e22020-03-16 17:26:14 +0100203 assert_string_equal(str,
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100204 "<any xmlns=\"urn:tests:a\">\n"
205 " <element1>\n"
206 " <element2 xmlns=\"urn:x\" xmlns:x=\"urn:x\" x:attr2=\"test\" xmlns:a=\"urn:tests:a\">a:data</element2>\n"
207 " </element1>\n"
208 " <element1a/>\n"
209 "</any>\n");
Radek Krejci241f6b52020-05-21 18:13:49 +0200210 ly_out_reset(out);
Radek Krejciee4cab22019-07-17 17:07:47 +0200211
212 lyd_free_all(tree);
Radek Krejci241f6b52020-05-21 18:13:49 +0200213 ly_out_free(out, NULL, 1);
Radek Krejcia5bba312020-01-09 15:41:20 +0100214
Radek Krejciee4cab22019-07-17 17:07:47 +0200215 *state = NULL;
216}
217
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200218static void
219test_list(void **state)
220{
221 *state = test_list;
222
Michal Vasko44685da2020-03-17 15:38:06 +0100223 const char *data = "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b><c>1</c></l1>";
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200224 struct lyd_node *tree, *iter;
225 struct lyd_node_inner *list;
Radek Krejci710226d2019-07-24 17:24:59 +0200226 struct lyd_node_term *leaf;
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200227
Radek Krejci710226d2019-07-24 17:24:59 +0200228 /* check hashes */
Michal Vasko63f3d842020-07-08 10:10:14 +0200229 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200230 assert_non_null(tree);
231 assert_int_equal(LYS_LIST, tree->schema->nodetype);
232 assert_string_equal("l1", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100233 list = (struct lyd_node_inner *)tree;
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200234 LY_LIST_FOR(list->child, iter) {
235 assert_int_not_equal(0, iter->hash);
236 }
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200237 lyd_free_all(tree);
Radek Krejci710226d2019-07-24 17:24:59 +0200238
Michal Vasko9f96a052020-03-10 09:41:45 +0100239 /* missing keys */
Michal Vasko44685da2020-03-17 15:38:06 +0100240 data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200241 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko44685da2020-03-17 15:38:06 +0100242 logbuf_assert("List instance is missing its key \"a\". /a:l1[b='b'][c='1']");
Michal Vasko9f96a052020-03-10 09:41:45 +0100243
244 data = "<l1 xmlns=\"urn:tests:a\"><a>a</a></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200245 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko9f96a052020-03-10 09:41:45 +0100246 logbuf_assert("List instance is missing its key \"b\". /a:l1[a='a']");
247
248 data = "<l1 xmlns=\"urn:tests:a\"><b>b</b><a>a</a></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200249 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko9f96a052020-03-10 09:41:45 +0100250 logbuf_assert("List instance is missing its key \"c\". /a:l1[a='a'][b='b']");
251
252 /* key duplicate */
Michal Vasko44685da2020-03-17 15:38:06 +0100253 data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a><c>1</c></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200254 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko44685da2020-03-17 15:38:06 +0100255 logbuf_assert("Duplicate instance of \"c\". /a:l1[a='a'][b='b'][c='1'][c='1']/c");
Michal Vasko9f96a052020-03-10 09:41:45 +0100256
Radek Krejci710226d2019-07-24 17:24:59 +0200257 /* keys order */
Michal Vasko44685da2020-03-17 15:38:06 +0100258 data = "<l1 xmlns=\"urn:tests:a\"><d>d</d><a>a</a><c>1</c><b>b</b></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200259 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejci710226d2019-07-24 17:24:59 +0200260 assert_non_null(tree);
261 assert_int_equal(LYS_LIST, tree->schema->nodetype);
262 assert_string_equal("l1", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100263 list = (struct lyd_node_inner *)tree;
264 assert_non_null(leaf = (struct lyd_node_term *)list->child);
Radek Krejci710226d2019-07-24 17:24:59 +0200265 assert_string_equal("a", leaf->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100266 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Krejci710226d2019-07-24 17:24:59 +0200267 assert_string_equal("b", leaf->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100268 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Krejci710226d2019-07-24 17:24:59 +0200269 assert_string_equal("c", leaf->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100270 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Krejci710226d2019-07-24 17:24:59 +0200271 assert_string_equal("d", leaf->schema->name);
272 logbuf_assert("Invalid position of the key \"b\" in a list.");
273 lyd_free_all(tree);
274
Michal Vasko44685da2020-03-17 15:38:06 +0100275 data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200276 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejci710226d2019-07-24 17:24:59 +0200277 assert_non_null(tree);
278 assert_int_equal(LYS_LIST, tree->schema->nodetype);
279 assert_string_equal("l1", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100280 list = (struct lyd_node_inner *)tree;
281 assert_non_null(leaf = (struct lyd_node_term *)list->child);
Radek Krejci710226d2019-07-24 17:24:59 +0200282 assert_string_equal("a", leaf->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100283 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Krejci710226d2019-07-24 17:24:59 +0200284 assert_string_equal("b", leaf->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100285 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Krejci710226d2019-07-24 17:24:59 +0200286 assert_string_equal("c", leaf->schema->name);
287 logbuf_assert("Invalid position of the key \"a\" in a list.");
288 logbuf_clean();
289 lyd_free_all(tree);
290
Michal Vasko63f3d842020-07-08 10:10:14 +0200291 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT, 0, &tree));
Radek Krejci710226d2019-07-24 17:24:59 +0200292 logbuf_assert("Invalid position of the key \"b\" in a list. Line number 1.");
293
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200294 *state = NULL;
295}
296
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200297static void
298test_container(void **state)
299{
300 *state = test_container;
301
302 const char *data = "<c xmlns=\"urn:tests:a\"/>";
303 struct lyd_node *tree;
304 struct lyd_node_inner *cont;
305
Michal Vasko63f3d842020-07-08 10:10:14 +0200306 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200307 assert_non_null(tree);
308 assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
309 assert_string_equal("c", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100310 cont = (struct lyd_node_inner *)tree;
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200311 assert_true(cont->flags & LYD_DEFAULT);
312 lyd_free_all(tree);
313
314 data = "<cp xmlns=\"urn:tests:a\"/>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200315 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200316 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100317 tree = tree->next;
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200318 assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
319 assert_string_equal("cp", tree->schema->name);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100320 cont = (struct lyd_node_inner *)tree;
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200321 assert_false(cont->flags & LYD_DEFAULT);
322 lyd_free_all(tree);
323
324 *state = NULL;
325}
326
Michal Vasko44685da2020-03-17 15:38:06 +0100327static void
328test_opaq(void **state)
329{
330 *state = test_opaq;
331
332 const char *data;
333 char *str;
334 struct lyd_node *tree;
335
Radek Krejci241f6b52020-05-21 18:13:49 +0200336 struct ly_out *out;
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100337
Radek Krejci84ce7b12020-06-11 17:28:25 +0200338 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
Radek Krejcia5bba312020-01-09 15:41:20 +0100339
Michal Vasko44685da2020-03-17 15:38:06 +0100340 /* invalid value, no flags */
341 data = "<foo3 xmlns=\"urn:tests:a\"/>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200342 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko1ce933a2020-03-30 12:38:22 +0200343 logbuf_assert("Invalid empty uint32 value. /a:foo3");
Michal Vasko44685da2020-03-17 15:38:06 +0100344 assert_null(tree);
345
346 /* opaq flag */
Michal Vasko54b50282020-11-23 17:00:32 +0100347 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, &tree));
Michal Vasko44685da2020-03-17 15:38:06 +0100348 assert_non_null(tree);
349 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100350 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "foo3");
Michal Vasko44685da2020-03-17 15:38:06 +0100351 assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
352
Radek Krejci52f65552020-09-01 17:03:35 +0200353 lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
Michal Vasko44685da2020-03-17 15:38:06 +0100354 assert_string_equal(str, "<foo3 xmlns=\"urn:tests:a\"/>");
Radek Krejci241f6b52020-05-21 18:13:49 +0200355 ly_out_reset(out);
Michal Vasko44685da2020-03-17 15:38:06 +0100356 lyd_free_all(tree);
357
358 /* missing key, no flags */
359 data = "<l1 xmlns=\"urn:tests:a\"><a>val_a</a><b>val_b</b><d>val_d</d></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200360 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko44685da2020-03-17 15:38:06 +0100361 logbuf_assert("List instance is missing its key \"c\". /a:l1[a='val_a'][b='val_b']");
362 assert_null(tree);
363
364 /* opaq flag */
Michal Vasko54b50282020-11-23 17:00:32 +0100365 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, &tree));
Michal Vasko44685da2020-03-17 15:38:06 +0100366 assert_non_null(tree);
367 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100368 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
Michal Vasko44685da2020-03-17 15:38:06 +0100369 assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
370
Radek Krejci52f65552020-09-01 17:03:35 +0200371 lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
Michal Vasko44685da2020-03-17 15:38:06 +0100372 assert_string_equal(str, data);
Radek Krejci241f6b52020-05-21 18:13:49 +0200373 ly_out_reset(out);
Michal Vasko44685da2020-03-17 15:38:06 +0100374 lyd_free_all(tree);
375
376 /* invalid key, no flags */
377 data = "<l1 xmlns=\"urn:tests:a\"><a>val_a</a><b>val_b</b><c>val_c</c></l1>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200378 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vaskof872e202020-05-27 11:49:06 +0200379 logbuf_assert("Invalid int16 value \"val_c\". /a:l1/c");
Michal Vasko44685da2020-03-17 15:38:06 +0100380 assert_null(tree);
381
382 /* opaq flag */
Michal Vasko54b50282020-11-23 17:00:32 +0100383 assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, &tree));
Michal Vasko44685da2020-03-17 15:38:06 +0100384 assert_non_null(tree);
385 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100386 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
Michal Vasko44685da2020-03-17 15:38:06 +0100387 assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
388
Radek Krejci52f65552020-09-01 17:03:35 +0200389 lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
Michal Vasko44685da2020-03-17 15:38:06 +0100390 assert_string_equal(str, data);
Radek Krejci241f6b52020-05-21 18:13:49 +0200391 ly_out_reset(out);
Michal Vasko44685da2020-03-17 15:38:06 +0100392 lyd_free_all(tree);
393
Michal Vasko413c7f22020-05-05 12:34:06 +0200394 /* opaq flag and fail */
Michal Vasko63f3d842020-07-08 10:10:14 +0200395 assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, "<a xmlns=\"ns\"><b>x</b><c xml:id=\"D\">1</c></a>", LYD_XML,
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100396 LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
Radek Krejci1798aae2020-07-14 13:26:06 +0200397 logbuf_assert("Unknown XML prefix \"xml\". Line number 1.");
Michal Vasko413c7f22020-05-05 12:34:06 +0200398 assert_null(tree);
Radek Krejci241f6b52020-05-21 18:13:49 +0200399 ly_out_free(out, NULL, 1);
Radek Krejcia5bba312020-01-09 15:41:20 +0100400
Michal Vasko44685da2020-03-17 15:38:06 +0100401 *state = NULL;
402}
403
Michal Vaskob36053d2020-03-26 15:49:30 +0100404static void
405test_rpc(void **state)
406{
407 *state = test_rpc;
408
409 const char *data;
Michal Vasko63f3d842020-07-08 10:10:14 +0200410 struct ly_in *in;
Michal Vaskob36053d2020-03-26 15:49:30 +0100411 char *str;
412 struct lyd_node *tree, *op;
Michal Vasko1bf09392020-03-27 12:38:10 +0100413 const struct lyd_node *node;
Michal Vaskob36053d2020-03-26 15:49:30 +0100414
Radek Krejci241f6b52020-05-21 18:13:49 +0200415 struct ly_out *out;
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100416
Radek Krejci84ce7b12020-06-11 17:28:25 +0200417 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
Radek Krejcia5bba312020-01-09 15:41:20 +0100418
Michal Vaskob36053d2020-03-26 15:49:30 +0100419 data =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100420 "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
421 " <edit-config>\n"
422 " <target>\n"
423 " <running/>\n"
424 " </target>\n"
425 " <config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
426 " <l1 xmlns=\"urn:tests:a\" nc:operation=\"replace\">\n"
427 " <a>val_a</a>\n"
428 " <b>val_b</b>\n"
429 " <c>val_c</c>\n"
430 " </l1>\n"
431 " <cp xmlns=\"urn:tests:a\">\n"
432 " <z nc:operation=\"delete\"/>\n"
433 " </cp>\n"
434 " </config>\n"
435 " </edit-config>\n"
436 "</rpc>\n";
Michal Vasko63f3d842020-07-08 10:10:14 +0200437 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
438 assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &tree, &op));
439 ly_in_free(in, 0);
Michal Vasko1bf09392020-03-27 12:38:10 +0100440
441 assert_non_null(op);
442 assert_string_equal(op->schema->name, "edit-config");
443
Michal Vaskob36053d2020-03-26 15:49:30 +0100444 assert_non_null(tree);
445 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100446 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc");
Michal Vasko1bf09392020-03-27 12:38:10 +0100447 assert_non_null(((struct lyd_node_opaq *)tree)->attr);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200448 node = lyd_child(tree);
Michal Vasko1bf09392020-03-27 12:38:10 +0100449 assert_string_equal(node->schema->name, "edit-config");
Radek Krejcia1c1e542020-09-29 16:06:52 +0200450 node = lyd_child(node)->next;
Michal Vasko1bf09392020-03-27 12:38:10 +0100451 assert_string_equal(node->schema->name, "config");
Michal Vaskob104f112020-07-17 09:54:54 +0200452
Michal Vasko1bf09392020-03-27 12:38:10 +0100453 node = ((struct lyd_node_any *)node)->value.tree;
Michal Vasko1bf09392020-03-27 12:38:10 +0100454 assert_non_null(node->schema);
455 assert_string_equal(node->schema->name, "cp");
Radek Krejcia1c1e542020-09-29 16:06:52 +0200456 node = lyd_child(node);
Michal Vasko1bf09392020-03-27 12:38:10 +0100457 /* z has no value */
458 assert_null(node->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100459 assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "z");
Michal Vaskob104f112020-07-17 09:54:54 +0200460 node = node->parent->next;
461 /* l1 key c has invalid value so it is at the end */
462 assert_null(node->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100463 assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "l1");
Michal Vaskob36053d2020-03-26 15:49:30 +0100464
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100465 lyd_print_tree(out, tree, LYD_XML, 0);
Michal Vasko1bf09392020-03-27 12:38:10 +0100466 assert_string_equal(str,
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100467 "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
468 " <edit-config>\n"
469 " <target>\n"
470 " <running/>\n"
471 " </target>\n"
472 " <config>\n"
473 " <cp xmlns=\"urn:tests:a\">\n"
474 " <z xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" nc:operation=\"delete\"/>\n"
475 " </cp>\n"
476 " <l1 xmlns=\"urn:tests:a\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" nc:operation=\"replace\">\n"
477 " <a>val_a</a>\n"
478 " <b>val_b</b>\n"
479 " <c>val_c</c>\n"
480 " </l1>\n"
481 " </config>\n"
482 " </edit-config>\n"
483 "</rpc>\n");
Radek Krejci241f6b52020-05-21 18:13:49 +0200484 ly_out_reset(out);
Michal Vaskob36053d2020-03-26 15:49:30 +0100485 lyd_free_all(tree);
486
487 /* wrong namespace, element name, whatever... */
Michal Vaskoa8edff02020-03-27 14:47:01 +0100488 /* TODO */
489
Radek Krejci241f6b52020-05-21 18:13:49 +0200490 ly_out_free(out, NULL, 1);
Radek Krejcia5bba312020-01-09 15:41:20 +0100491
Michal Vaskoa8edff02020-03-27 14:47:01 +0100492 *state = NULL;
493}
494
495static void
496test_action(void **state)
497{
498 *state = test_action;
499
500 const char *data;
Michal Vasko63f3d842020-07-08 10:10:14 +0200501 struct ly_in *in;
Michal Vaskoa8edff02020-03-27 14:47:01 +0100502 char *str;
503 struct lyd_node *tree, *op;
504 const struct lyd_node *node;
505
Radek Krejci241f6b52020-05-21 18:13:49 +0200506 struct ly_out *out;
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100507
Radek Krejci84ce7b12020-06-11 17:28:25 +0200508 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
Radek Krejcia5bba312020-01-09 15:41:20 +0100509
Michal Vaskoa8edff02020-03-27 14:47:01 +0100510 data =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100511 "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
512 " <action xmlns=\"urn:ietf:params:xml:ns:yang:1\">\n"
513 " <c xmlns=\"urn:tests:a\">\n"
514 " <act>\n"
515 " <al>value</al>\n"
516 " </act>\n"
517 " </c>\n"
518 " </action>\n"
519 "</rpc>\n";
Michal Vasko63f3d842020-07-08 10:10:14 +0200520 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
521 assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &tree, &op));
522 ly_in_free(in, 0);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100523
524 assert_non_null(op);
525 assert_string_equal(op->schema->name, "act");
526
527 assert_non_null(tree);
528 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100529 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc");
Michal Vaskoa8edff02020-03-27 14:47:01 +0100530 assert_non_null(((struct lyd_node_opaq *)tree)->attr);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200531 node = lyd_child(tree);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100532 assert_null(node->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100533 assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "action");
Michal Vaskoa8edff02020-03-27 14:47:01 +0100534 assert_null(((struct lyd_node_opaq *)node)->attr);
535
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100536 lyd_print_tree(out, tree, LYD_XML, 0);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100537 assert_string_equal(str,
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100538 "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
539 " <action xmlns=\"urn:ietf:params:xml:ns:yang:1\">\n"
540 " <c xmlns=\"urn:tests:a\">\n"
541 " <act>\n"
542 " <al>value</al>\n"
543 " </act>\n"
544 " </c>\n"
545 " </action>\n"
546 "</rpc>\n");
Radek Krejci241f6b52020-05-21 18:13:49 +0200547 ly_out_reset(out);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100548 lyd_free_all(tree);
549
550 /* wrong namespace, element name, whatever... */
551 /* TODO */
552
Radek Krejci241f6b52020-05-21 18:13:49 +0200553 ly_out_free(out, NULL, 1);
Radek Krejcia5bba312020-01-09 15:41:20 +0100554
Michal Vaskoa8edff02020-03-27 14:47:01 +0100555 *state = NULL;
556}
557
558static void
559test_notification(void **state)
560{
561 *state = test_notification;
562
563 const char *data;
Michal Vasko63f3d842020-07-08 10:10:14 +0200564 struct ly_in *in;
Michal Vaskoa8edff02020-03-27 14:47:01 +0100565 char *str;
566 struct lyd_node *tree, *ntf;
567 const struct lyd_node *node;
568
Radek Krejci241f6b52020-05-21 18:13:49 +0200569 struct ly_out *out;
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100570
Radek Krejci84ce7b12020-06-11 17:28:25 +0200571 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
Radek Krejcia5bba312020-01-09 15:41:20 +0100572
Michal Vaskoa8edff02020-03-27 14:47:01 +0100573 data =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100574 "<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">\n"
575 " <eventTime>2037-07-08T00:01:00Z</eventTime>\n"
576 " <c xmlns=\"urn:tests:a\">\n"
577 " <n1>\n"
578 " <nl>value</nl>\n"
579 " </n1>\n"
580 " </c>\n"
581 "</notification>\n";
Michal Vasko63f3d842020-07-08 10:10:14 +0200582 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
583 assert_int_equal(LY_SUCCESS, lyd_parse_notif(ctx, in, LYD_XML, &tree, &ntf));
584 ly_in_free(in, 0);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100585
586 assert_non_null(ntf);
587 assert_string_equal(ntf->schema->name, "n1");
588
589 assert_non_null(tree);
590 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100591 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "notification");
Michal Vaskoa8edff02020-03-27 14:47:01 +0100592 assert_null(((struct lyd_node_opaq *)tree)->attr);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200593 node = lyd_child(tree);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100594 assert_null(node->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100595 assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "eventTime");
Michal Vaskoa8edff02020-03-27 14:47:01 +0100596 assert_string_equal(((struct lyd_node_opaq *)node)->value, "2037-07-08T00:01:00Z");
597 assert_null(((struct lyd_node_opaq *)node)->attr);
598 node = node->next;
599 assert_non_null(node->schema);
600 assert_string_equal(node->schema->name, "c");
601
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100602 lyd_print_tree(out, tree, LYD_XML, 0);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100603 assert_string_equal(str, data);
Radek Krejci241f6b52020-05-21 18:13:49 +0200604 ly_out_reset(out);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100605 lyd_free_all(tree);
606
607 /* top-level notif without envelope */
608 data = "<n2 xmlns=\"urn:tests:a\"/>";
Michal Vasko63f3d842020-07-08 10:10:14 +0200609 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
610 assert_int_equal(LY_SUCCESS, lyd_parse_notif(ctx, in, LYD_XML, &tree, &ntf));
611 ly_in_free(in, 0);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100612
613 assert_non_null(ntf);
614 assert_string_equal(ntf->schema->name, "n2");
615
616 assert_non_null(tree);
617 assert_ptr_equal(ntf, tree);
618
Radek Krejci52f65552020-09-01 17:03:35 +0200619 lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100620 assert_string_equal(str, data);
Radek Krejci241f6b52020-05-21 18:13:49 +0200621 ly_out_reset(out);
Michal Vaskoa8edff02020-03-27 14:47:01 +0100622 lyd_free_all(tree);
623
624 /* wrong namespace, element name, whatever... */
625 /* TODO */
Michal Vaskob36053d2020-03-26 15:49:30 +0100626
Radek Krejci241f6b52020-05-21 18:13:49 +0200627 ly_out_free(out, NULL, 1);
Radek Krejcia5bba312020-01-09 15:41:20 +0100628
Michal Vaskob36053d2020-03-26 15:49:30 +0100629 *state = NULL;
630}
631
Michal Vasko1ce933a2020-03-30 12:38:22 +0200632static void
633test_reply(void **state)
634{
635 *state = test_reply;
636
637 const char *data;
Michal Vasko63f3d842020-07-08 10:10:14 +0200638 struct ly_in *in;
Michal Vasko1ce933a2020-03-30 12:38:22 +0200639 char *str;
640 struct lyd_node *request, *tree, *op;
641 const struct lyd_node *node;
642
Radek Krejci241f6b52020-05-21 18:13:49 +0200643 struct ly_out *out;
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100644
Radek Krejci84ce7b12020-06-11 17:28:25 +0200645 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
Radek Krejcia5bba312020-01-09 15:41:20 +0100646
Michal Vasko1ce933a2020-03-30 12:38:22 +0200647 data =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100648 "<c xmlns=\"urn:tests:a\">\n"
649 " <act>\n"
650 " <al>value</al>\n"
651 " </act>\n"
652 "</c>\n";
Michal Vasko63f3d842020-07-08 10:10:14 +0200653 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
654 assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &request, NULL));
655 ly_in_free(in, 0);
656
Michal Vasko1ce933a2020-03-30 12:38:22 +0200657 data =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100658 "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\">\n"
659 " <al xmlns=\"urn:tests:a\">25</al>\n"
660 "</rpc-reply>\n";
Michal Vasko63f3d842020-07-08 10:10:14 +0200661 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
662 assert_int_equal(LY_SUCCESS, lyd_parse_reply(request, in, LYD_XML, &tree, &op));
663 ly_in_free(in, 0);
Michal Vasko1ce933a2020-03-30 12:38:22 +0200664 lyd_free_all(request);
665
666 assert_non_null(op);
667 assert_string_equal(op->schema->name, "act");
Radek Krejcia1c1e542020-09-29 16:06:52 +0200668 node = lyd_child(op);
Michal Vasko1ce933a2020-03-30 12:38:22 +0200669 assert_non_null(node->schema);
670 assert_string_equal(node->schema->name, "al");
671 assert_true(node->schema->flags & LYS_CONFIG_R);
672
673 assert_non_null(tree);
674 assert_null(tree->schema);
Michal Vaskoad92b672020-11-12 13:11:31 +0100675 assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc-reply");
Michal Vasko1ce933a2020-03-30 12:38:22 +0200676 assert_non_null(((struct lyd_node_opaq *)tree)->attr);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200677 node = lyd_child(tree);
Michal Vasko1ce933a2020-03-30 12:38:22 +0200678 assert_non_null(node->schema);
679 assert_string_equal(node->schema->name, "c");
680
681 /* TODO print only rpc-reply node and then output subtree */
Radek Krejcia1c1e542020-09-29 16:06:52 +0200682 lyd_print_tree(out, lyd_child(op), LYD_XML, LYD_PRINT_SHRINK);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100683 assert_string_equal(str, "<al xmlns=\"urn:tests:a\">25</al>");
Radek Krejci241f6b52020-05-21 18:13:49 +0200684 ly_out_reset(out);
Michal Vasko1ce933a2020-03-30 12:38:22 +0200685 lyd_free_all(tree);
686
687 /* wrong namespace, element name, whatever... */
688 /* TODO */
689
Radek Krejci241f6b52020-05-21 18:13:49 +0200690 ly_out_free(out, NULL, 1);
Radek Krejcia5bba312020-01-09 15:41:20 +0100691
Michal Vasko1ce933a2020-03-30 12:38:22 +0200692 *state = NULL;
693}
694
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100695int
696main(void)
Radek Krejci509e2592019-05-15 16:30:48 +0200697{
698 const struct CMUnitTest tests[] = {
699 cmocka_unit_test_setup_teardown(test_leaf, setup, teardown),
Radek Krejciee4cab22019-07-17 17:07:47 +0200700 cmocka_unit_test_setup_teardown(test_anydata, setup, teardown),
Radek Krejci1f05b6a2019-07-18 16:15:06 +0200701 cmocka_unit_test_setup_teardown(test_list, setup, teardown),
Radek Krejcib6f7ae52019-07-19 10:31:42 +0200702 cmocka_unit_test_setup_teardown(test_container, setup, teardown),
Michal Vasko44685da2020-03-17 15:38:06 +0100703 cmocka_unit_test_setup_teardown(test_opaq, setup, teardown),
Michal Vasko1bf09392020-03-27 12:38:10 +0100704 cmocka_unit_test_setup_teardown(test_rpc, setup, teardown),
Michal Vaskoa8edff02020-03-27 14:47:01 +0100705 cmocka_unit_test_setup_teardown(test_action, setup, teardown),
706 cmocka_unit_test_setup_teardown(test_notification, setup, teardown),
Michal Vasko1ce933a2020-03-30 12:38:22 +0200707 cmocka_unit_test_setup_teardown(test_reply, setup, teardown),
Radek Krejci509e2592019-05-15 16:30:48 +0200708 };
709
710 return cmocka_run_group_tests(tests, NULL, NULL);
711}