blob: 418d2b4fd9c2243a8ab13f20f7d5c976f70e9a3d [file] [log] [blame]
Michal Vaskob1b5c262020-03-05 14:29:47 +01001/**
2 * @file test_validation.c
Michal Vaskocde73ac2019-11-14 16:10:27 +01003 * @author: Radek Krejci <rkrejci@cesnet.cz>
Michal Vaskob1b5c262020-03-05 14:29:47 +01004 * @brief unit tests for functions from validation.c
Michal Vaskocde73ac2019-11-14 16:10:27 +01005 *
Michal Vaskob1b5c262020-03-05 14:29:47 +01006 * Copyright (c) 2020 CESNET, z.s.p.o.
Michal Vaskocde73ac2019-11-14 16:10:27 +01007 *
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_
15#include "utests.h"
Michal Vaskocde73ac2019-11-14 16:10:27 +010016
Michal Vaskocde73ac2019-11-14 16:10:27 +010017#include <stdio.h>
18#include <string.h>
19
Radek Krejci70593c12020-06-13 20:48:09 +020020#include "context.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020021#include "in.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020022#include "out.h"
Radek Krejcib4ac5a92020-11-23 17:54:33 +010023#include "parser_data.h"
Radek Krejci70593c12020-06-13 20:48:09 +020024#include "printer_data.h"
25#include "tests/config.h"
Radek Krejci70593c12020-06-13 20:48:09 +020026#include "tree_data_internal.h"
Radek Krejcib4ac5a92020-11-23 17:54:33 +010027#include "tree_schema.h"
Michal Vaskocde73ac2019-11-14 16:10:27 +010028
Radek Iša56ca9e42020-09-08 18:42:00 +020029#define LYD_TREE_CREATE(INPUT, MODEL) \
30 CHECK_PARSE_LYD_PARAM(INPUT, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_SUCCESS, MODEL)
Michal Vaskocde73ac2019-11-14 16:10:27 +010031
Michal Vaskocde73ac2019-11-14 16:10:27 +010032static void
Radek Iša56ca9e42020-09-08 18:42:00 +020033test_when(void **state)
Michal Vaskocde73ac2019-11-14 16:10:27 +010034{
Radek Iša56ca9e42020-09-08 18:42:00 +020035 struct lyd_node *tree;
36 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +010037 "module a {\n"
38 " namespace urn:tests:a;\n"
39 " prefix a;\n"
40 " yang-version 1.1;\n"
41 "\n"
42 " container cont {\n"
43 " leaf a {\n"
44 " when \"../../c = 'val_c'\";\n"
45 " type string;\n"
46 " }\n"
47 " leaf b {\n"
48 " type string;\n"
49 " }\n"
50 " }\n"
51 " leaf c {\n"
52 " when \"/cont/b = 'val_b'\";\n"
53 " type string;\n"
54 " }\n"
55 "}";
Radek Iša56ca9e42020-09-08 18:42:00 +020056
57 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
58
59 CHECK_PARSE_LYD_PARAM("<c xmlns=\"urn:tests:a\">hey</c>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +010060 CHECK_LOG_CTX("When condition \"/cont/b = 'val_b'\" not satisfied.", "Schema location /a:c, data location /a:c.");
Radek Iša56ca9e42020-09-08 18:42:00 +020061
62 LYD_TREE_CREATE("<cont xmlns=\"urn:tests:a\"><b>val_b</b></cont><c xmlns=\"urn:tests:a\">hey</c>", tree);
63 CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 0, LYS_LEAF, 0, 0, NULL, 1);
64 assert_int_equal(LYD_WHEN_TRUE, tree->next->flags);
65 lyd_free_all(tree);
66
67 LYD_TREE_CREATE("<cont xmlns=\"urn:tests:a\"><a>val</a><b>val_b</b></cont><c xmlns=\"urn:tests:a\">val_c</c>", tree);
68 CHECK_LYSC_NODE(lyd_child(tree)->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "a", 1, LYS_LEAF, 1, 0, NULL, 1);
69 assert_int_equal(LYD_WHEN_TRUE, lyd_child(tree)->flags);
70 CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 0, LYS_LEAF, 0, 0, NULL, 1);
71 assert_int_equal(LYD_WHEN_TRUE, tree->next->flags);
72 lyd_free_all(tree);
73}
74
75static void
Christian Hoppsb6ecaea2021-02-06 09:45:38 -050076test_mandatory_when(void **state)
77{
78 struct lyd_node *tree;
79 const char *schema =
80 "module a {\n"
81 " namespace urn:tests:a;\n"
82 " prefix a;\n"
83 " yang-version 1.1;\n"
84 "\n"
85 " container cont {\n"
86 " leaf a {\n"
87 " type string;\n"
88 " }\n"
89 " leaf b {\n"
90 " when \"../a = 'val_a'\";\n"
91 " mandatory true;\n"
92 " type string;\n"
93 " }\n"
94 " }\n"
95 " leaf c {\n"
96 " type string;\n"
97 " }\n"
98 " leaf d {\n"
99 " when \"../c = 'val_c'\";\n"
100 " mandatory true;\n"
101 " type string;\n"
102 " }\n"
103 "}";
104
105 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
106
107 CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:a\">hey</d>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
108 CHECK_LOG_CTX("When condition \"../c = 'val_c'\" not satisfied.", "Schema location /a:d, data location /a:d.");
109
110 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:a\"><b>hey</b></cont>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
111 CHECK_LOG_CTX("When condition \"../a = 'val_a'\" not satisfied.", "Schema location /a:cont/b, data location /a:cont/b.");
112
113 LYD_TREE_CREATE("<c xmlns=\"urn:tests:a\">val_c</c><d xmlns=\"urn:tests:a\">hey</d>", tree);
114 CHECK_LYSC_NODE(tree->next->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_MAND_TRUE, 1, "d", 0, LYS_LEAF, 0, 0, NULL, 1);
115 assert_int_equal(LYD_WHEN_TRUE, tree->next->next->flags);
116 lyd_free_all(tree);
117
118 LYD_TREE_CREATE("<cont xmlns=\"urn:tests:a\"><a>val_a</a><b>hey</b></cont>", tree);
119 CHECK_LYSC_NODE(lyd_child(tree)->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_MAND_TRUE, 1, "b", 0, LYS_LEAF, tree->schema, 0, NULL, 1);
120 assert_int_equal(LYD_WHEN_TRUE, lyd_child(tree)->next->flags);
121 lyd_free_all(tree);
122}
123
124static void
Radek Iša56ca9e42020-09-08 18:42:00 +0200125test_mandatory(void **state)
126{
127 struct lyd_node *tree;
128 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100129 "module b {\n"
130 " namespace urn:tests:b;\n"
131 " prefix b;\n"
132 " yang-version 1.1;\n"
133 "\n"
134 " choice choic {\n"
135 " mandatory true;\n"
136 " leaf a {\n"
137 " type string;\n"
138 " }\n"
139 " case b {\n"
140 " leaf l {\n"
141 " type string;\n"
142 " }\n"
143 " }\n"
144 " }\n"
145 " leaf c {\n"
146 " mandatory true;\n"
147 " type string;\n"
148 " }\n"
149 " leaf d {\n"
150 " type empty;\n"
151 " }\n"
152 "}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200153
154 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
155
156 CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:b\"/>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Michal Vasko538b8952021-02-17 11:27:26 +0100157 CHECK_LOG_CTX("Mandatory choice \"choic\" data do not exist.", "Schema location /b:choic.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200158
159 CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:b\">string</l><d xmlns=\"urn:tests:b\"/>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100160 CHECK_LOG_CTX("Mandatory node \"c\" instance does not exist.", "Schema location /b:c.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200161
162 CHECK_PARSE_LYD_PARAM("<a xmlns=\"urn:tests:b\">string</a>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100163 CHECK_LOG_CTX("Mandatory node \"c\" instance does not exist.", "Schema location /b:c.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200164
165 LYD_TREE_CREATE("<a xmlns=\"urn:tests:b\">string</a><c xmlns=\"urn:tests:b\">string2</c>", tree);
166 lyd_free_siblings(tree);
167}
168
169static void
170test_minmax(void **state)
171{
172 struct lyd_node *tree;
173 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100174 "module c {\n"
175 " namespace urn:tests:c;\n"
176 " prefix c;\n"
177 " yang-version 1.1;\n"
178 "\n"
179 " choice choic {\n"
180 " leaf a {\n"
181 " type string;\n"
182 " }\n"
183 " case b {\n"
184 " leaf-list l {\n"
185 " min-elements 3;\n"
186 " type string;\n"
187 " }\n"
188 " }\n"
189 " }\n"
190 " list lt {\n"
191 " max-elements 4;\n"
192 " key \"k\";\n"
193 " leaf k {\n"
194 " type string;\n"
195 " }\n"
196 " }\n"
197 " leaf d {\n"
198 " type empty;\n"
199 " }\n"
200 "}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200201
202 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
203
Michal Vasko6c16cda2021-02-04 11:05:52 +0100204 CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:c\">mate</l>"
205 "<d xmlns=\"urn:tests:c\"/>",
206 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100207 CHECK_LOG_CTX("Too few \"l\" instances.", "Schema location /c:choic/b/l.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200208
209 CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:c\">val1</l>"
210 "<l xmlns=\"urn:tests:c\">val2</l>",
211 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100212 CHECK_LOG_CTX("Too few \"l\" instances.", "Schema location /c:choic/b/l.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200213
214 LYD_TREE_CREATE("<l xmlns=\"urn:tests:c\">val1</l>"
215 "<l xmlns=\"urn:tests:c\">val2</l>"
216 "<l xmlns=\"urn:tests:c\">val3</l>", tree);
217 lyd_free_all(tree);
218
219 CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:c\">val1</l>"
220 "<l xmlns=\"urn:tests:c\">val2</l>"
221 "<l xmlns=\"urn:tests:c\">val3</l>"
222 "<lt xmlns=\"urn:tests:c\"><k>val1</k></lt>"
223 "<lt xmlns=\"urn:tests:c\"><k>val2</k></lt>"
224 "<lt xmlns=\"urn:tests:c\"><k>val3</k></lt>"
225 "<lt xmlns=\"urn:tests:c\"><k>val4</k></lt>"
Radek Krejci2efc45b2020-12-22 16:25:44 +0100226 "<lt xmlns=\"urn:tests:c\"><k>val5</k></lt>"
227 "<lt xmlns=\"urn:tests:c\"><k>val6</k></lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
228 CHECK_LOG_CTX("Too many \"lt\" instances.", "Schema location /c:lt, data location /c:lt[k='val5'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200229}
230
231const char *schema_d =
232 "module d {\n"
233 " namespace urn:tests:d;\n"
234 " prefix d;\n"
235 " yang-version 1.1;\n"
236 "\n"
237 " list lt {\n"
238 " key \"k\";\n"
239 " unique \"l1\";\n"
240 " leaf k {\n"
241 " type string;\n"
242 " }\n"
243 " leaf l1 {\n"
244 " type string;\n"
245 " }\n"
246 " }\n"
247 " list lt2 {\n"
248 " key \"k\";\n"
249 " unique \"cont/l2 l4\";\n"
250 " unique \"l5 l6\";\n"
251 " leaf k {\n"
252 " type string;\n"
253 " }\n"
254 " container cont {\n"
255 " leaf l2 {\n"
256 " type string;\n"
257 " }\n"
258 " }\n"
259 " leaf l4 {\n"
260 " type string;\n"
261 " }\n"
262 " leaf l5 {\n"
263 " type string;\n"
264 " }\n"
265 " leaf l6 {\n"
266 " type string;\n"
267 " }\n"
268 " list lt3 {\n"
269 " key \"kk\";\n"
270 " unique \"l3\";\n"
271 " leaf kk {\n"
272 " type string;\n"
273 " }\n"
274 " leaf l3 {\n"
275 " type string;\n"
276 " }\n"
277 " }\n"
278 " }\n"
279 "}";
280
281static void
282test_unique(void **state)
283{
284 struct lyd_node *tree;
285
286 UTEST_ADD_MODULE(schema_d, LYS_IN_YANG, NULL, NULL);
287
288 LYD_TREE_CREATE("<lt xmlns=\"urn:tests:d\">\n"
289 " <k>val1</k>\n"
290 " <l1>same</l1>\n"
291 "</lt>\n"
292 "<lt xmlns=\"urn:tests:d\">\n"
293 " <k>val2</k>\n"
294 "</lt>", tree);
295 lyd_free_all(tree);
296
297 LYD_TREE_CREATE("<lt xmlns=\"urn:tests:d\">\n"
298 " <k>val1</k>\n"
299 " <l1>same</l1>\n"
300 "</lt>\n"
301 "<lt xmlns=\"urn:tests:d\">\n"
302 " <k>val2</k>\n"
303 " <l1>not-same</l1>\n"
304 "</lt>", tree);
305 lyd_free_all(tree);
306
307 CHECK_PARSE_LYD_PARAM("<lt xmlns=\"urn:tests:d\">\n"
308 " <k>val1</k>\n"
309 " <l1>same</l1>\n"
310 "</lt>\n"
311 "<lt xmlns=\"urn:tests:d\">\n"
312 " <k>val2</k>\n"
313 " <l1>same</l1>\n"
314 "</lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100315 CHECK_LOG_CTX("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val1']\" and \"/d:lt[k='val2']\".",
316 "Schema location /d:lt, data location /d:lt[k='val2'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200317
318 /* now try with more instances */
319 LYD_TREE_CREATE("<lt xmlns=\"urn:tests:d\">\n"
320 " <k>val1</k>\n"
321 " <l1>1</l1>\n"
322 "</lt>\n"
323 "<lt xmlns=\"urn:tests:d\">\n"
324 " <k>val2</k>\n"
325 " <l1>2</l1>\n"
326 "</lt>\n"
327 "<lt xmlns=\"urn:tests:d\">\n"
328 " <k>val3</k>\n"
329 " <l1>3</l1>\n"
330 "</lt>\n"
331 "<lt xmlns=\"urn:tests:d\">\n"
332 " <k>val4</k>\n"
333 " <l1>4</l1>\n"
334 "</lt>\n"
335 "<lt xmlns=\"urn:tests:d\">\n"
336 " <k>val5</k>\n"
337 " <l1>5</l1>\n"
338 "</lt>\n"
339 "<lt xmlns=\"urn:tests:d\">\n"
340 " <k>val6</k>\n"
341 " <l1>6</l1>\n"
342 "</lt>\n"
343 "<lt xmlns=\"urn:tests:d\">\n"
344 " <k>val7</k>\n"
345 " <l1>7</l1>\n"
346 "</lt>\n"
347 "<lt xmlns=\"urn:tests:d\">\n"
348 " <k>val8</k>\n"
349 " <l1>8</l1>\n"
350 "</lt>", tree);
351 lyd_free_all(tree);
352
353 LYD_TREE_CREATE("<lt xmlns=\"urn:tests:d\">\n"
354 " <k>val1</k>\n"
355 " <l1>1</l1>\n"
356 "</lt>\n"
357 "<lt xmlns=\"urn:tests:d\">\n"
358 " <k>val2</k>\n"
359 " <l1>2</l1>\n"
360 "</lt>\n"
361 "<lt xmlns=\"urn:tests:d\">\n"
362 " <k>val3</k>\n"
363 " <l1>3</l1>\n"
364 "</lt>\n"
365 "<lt xmlns=\"urn:tests:d\">\n"
366 " <k>val4</k>\n"
367 "</lt>\n"
368 "<lt xmlns=\"urn:tests:d\">\n"
369 " <k>val5</k>\n"
370 " <l1>5</l1>\n"
371 "</lt>\n"
372 "<lt xmlns=\"urn:tests:d\">\n"
373 " <k>val6</k>\n"
374 " <l1>6</l1>\n"
375 "</lt>\n"
376 "<lt xmlns=\"urn:tests:d\">\n"
377 " <k>val7</k>\n"
378 "</lt>\n"
379 "<lt xmlns=\"urn:tests:d\">\n"
380 " <k>val8</k>\n"
381 "</lt>", tree);
382 lyd_free_all(tree);
383
384 CHECK_PARSE_LYD_PARAM("<lt xmlns=\"urn:tests:d\">\n"
385 " <k>val1</k>\n"
386 " <l1>1</l1>\n"
387 "</lt>\n"
388 "<lt xmlns=\"urn:tests:d\">\n"
389 " <k>val2</k>\n"
390 " <l1>2</l1>\n"
391 "</lt>\n"
392 "<lt xmlns=\"urn:tests:d\">\n"
393 " <k>val3</k>\n"
394 "</lt>\n"
395 "<lt xmlns=\"urn:tests:d\">\n"
396 " <k>val4</k>\n"
397 " <l1>4</l1>\n"
398 "</lt>\n"
399 "<lt xmlns=\"urn:tests:d\">\n"
400 " <k>val5</k>\n"
401 "</lt>\n"
402 "<lt xmlns=\"urn:tests:d\">\n"
403 " <k>val6</k>\n"
404 "</lt>\n"
405 "<lt xmlns=\"urn:tests:d\">\n"
406 " <k>val7</k>\n"
407 " <l1>2</l1>\n"
408 "</lt>\n"
409 "<lt xmlns=\"urn:tests:d\">\n"
410 " <k>val8</k>\n"
411 " <l1>8</l1>\n"
412 "</lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100413 CHECK_LOG_CTX("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val7']\" and \"/d:lt[k='val2']\".",
414 "Schema location /d:lt, data location /d:lt[k='val2'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200415}
416
417static void
418test_unique_nested(void **state)
419{
420 struct lyd_node *tree;
421
422 UTEST_ADD_MODULE(schema_d, LYS_IN_YANG, NULL, NULL);
423
424 /* nested list uniquest are compared only with instances in the same parent list instance */
425 LYD_TREE_CREATE("<lt2 xmlns=\"urn:tests:d\">\n"
426 " <k>val1</k>\n"
427 " <cont>\n"
428 " <l2>1</l2>\n"
429 " </cont>\n"
430 " <l4>1</l4>\n"
431 "</lt2>\n"
432 "<lt2 xmlns=\"urn:tests:d\">\n"
433 " <k>val2</k>\n"
434 " <cont>\n"
435 " <l2>2</l2>\n"
436 " </cont>\n"
437 " <l4>2</l4>\n"
438 " <lt3>\n"
439 " <kk>val1</kk>\n"
440 " <l3>1</l3>\n"
441 " </lt3>\n"
442 " <lt3>\n"
443 " <kk>val2</kk>\n"
444 " <l3>2</l3>\n"
445 " </lt3>\n"
446 "</lt2>\n"
447 "<lt2 xmlns=\"urn:tests:d\">\n"
448 " <k>val3</k>\n"
449 " <cont>\n"
450 " <l2>3</l2>\n"
451 " </cont>\n"
452 " <l4>3</l4>\n"
453 " <lt3>\n"
454 " <kk>val1</kk>\n"
455 " <l3>2</l3>\n"
456 " </lt3>\n"
457 "</lt2>\n"
458 "<lt2 xmlns=\"urn:tests:d\">\n"
459 " <k>val4</k>\n"
460 " <cont>\n"
461 " <l2>4</l2>\n"
462 " </cont>\n"
463 " <l4>4</l4>\n"
464 " <lt3>\n"
465 " <kk>val1</kk>\n"
466 " <l3>3</l3>\n"
467 " </lt3>\n"
468 "</lt2>\n"
469 "<lt2 xmlns=\"urn:tests:d\">\n"
470 " <k>val5</k>\n"
471 " <cont>\n"
472 " <l2>5</l2>\n"
473 " </cont>\n"
474 " <l4>5</l4>\n"
475 " <lt3>\n"
476 " <kk>val1</kk>\n"
477 " <l3>3</l3>\n"
478 " </lt3>\n"
479 "</lt2>", tree);
480 lyd_free_all(tree);
481
482 CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
483 " <k>val1</k>\n"
484 " <cont>\n"
485 " <l2>1</l2>\n"
486 " </cont>\n"
487 " <l4>1</l4>\n"
488 "</lt2>\n"
489 "<lt2 xmlns=\"urn:tests:d\">\n"
490 " <k>val2</k>\n"
491 " <cont>\n"
492 " <l2>2</l2>\n"
493 " </cont>\n"
494 " <lt3>\n"
495 " <kk>val1</kk>\n"
496 " <l3>1</l3>\n"
497 " </lt3>\n"
498 " <lt3>\n"
499 " <kk>val2</kk>\n"
500 " <l3>2</l3>\n"
501 " </lt3>\n"
502 " <lt3>\n"
503 " <kk>val3</kk>\n"
504 " <l3>1</l3>\n"
505 " </lt3>\n"
506 "</lt2>\n"
507 "<lt2 xmlns=\"urn:tests:d\">\n"
508 " <k>val3</k>\n"
509 " <cont>\n"
510 " <l2>3</l2>\n"
511 " </cont>\n"
512 " <l4>1</l4>\n"
513 " <lt3>\n"
514 " <kk>val1</kk>\n"
515 " <l3>2</l3>\n"
516 " </lt3>\n"
517 "</lt2>\n"
518 "<lt2 xmlns=\"urn:tests:d\">\n"
519 " <k>val4</k>\n"
520 " <cont>\n"
521 " <l2>4</l2>\n"
522 " </cont>\n"
523 " <lt3>\n"
524 " <kk>val1</kk>\n"
525 " <l3>3</l3>\n"
526 " </lt3>\n"
527 "</lt2>\n"
528 "<lt2 xmlns=\"urn:tests:d\">\n"
529 " <k>val5</k>\n"
530 " <cont>\n"
531 " <l2>5</l2>\n"
532 " </cont>\n"
533 " <lt3>\n"
534 " <kk>val1</kk>\n"
535 " <l3>3</l3>\n"
536 " </lt3>\n"
537 "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100538 CHECK_LOG_CTX("Unique data leaf(s) \"l3\" not satisfied in \"/d:lt2[k='val2']/lt3[kk='val3']\" and \"/d:lt2[k='val2']/lt3[kk='val1']\".",
539 "Schema location /d:lt2/lt3, data location /d:lt2[k='val2']/lt3[kk='val1'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200540
541 CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
542 " <k>val1</k>\n"
543 " <cont>\n"
544 " <l2>1</l2>\n"
545 " </cont>\n"
546 " <l4>1</l4>\n"
547 "</lt2>\n"
548 "<lt2 xmlns=\"urn:tests:d\">\n"
549 " <k>val2</k>\n"
550 " <cont>\n"
551 " <l2>2</l2>\n"
552 " </cont>\n"
553 " <l4>2</l4>\n"
554 "</lt2>\n"
555 "<lt2 xmlns=\"urn:tests:d\">\n"
556 " <k>val3</k>\n"
557 " <cont>\n"
558 " <l2>3</l2>\n"
559 " </cont>\n"
560 " <l4>3</l4>\n"
561 "</lt2>\n"
562 "<lt2 xmlns=\"urn:tests:d\">\n"
563 " <k>val4</k>\n"
564 " <cont>\n"
565 " <l2>2</l2>\n"
566 " </cont>\n"
567 " <l4>2</l4>\n"
568 "</lt2>\n"
569 "<lt2 xmlns=\"urn:tests:d\">\n"
570 " <k>val5</k>\n"
571 " <cont>\n"
572 " <l2>5</l2>\n"
573 " </cont>\n"
574 " <l4>5</l4>\n"
575 "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100576 CHECK_LOG_CTX("Unique data leaf(s) \"cont/l2 l4\" not satisfied in \"/d:lt2[k='val4']\" and \"/d:lt2[k='val2']\".",
577 "Schema location /d:lt2, data location /d:lt2[k='val2'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200578
579 CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
580 " <k>val1</k>\n"
581 " <cont>\n"
582 " <l2>1</l2>\n"
583 " </cont>\n"
584 " <l4>1</l4>\n"
585 " <l5>1</l5>\n"
586 " <l6>1</l6>\n"
587 "</lt2>\n"
588 "<lt2 xmlns=\"urn:tests:d\">\n"
589 " <k>val2</k>\n"
590 " <cont>\n"
591 " <l2>2</l2>\n"
592 " </cont>\n"
593 " <l4>1</l4>\n"
594 " <l5>1</l5>\n"
595 "</lt2>\n"
596 "<lt2 xmlns=\"urn:tests:d\">\n"
597 " <k>val3</k>\n"
598 " <cont>\n"
599 " <l2>3</l2>\n"
600 " </cont>\n"
601 " <l4>1</l4>\n"
602 " <l5>3</l5>\n"
603 " <l6>3</l6>\n"
604 "</lt2>\n"
605 "<lt2 xmlns=\"urn:tests:d\">\n"
606 " <k>val4</k>\n"
607 " <cont>\n"
608 " <l2>4</l2>\n"
609 " </cont>\n"
610 " <l4>1</l4>\n"
611 " <l6>1</l6>\n"
612 "</lt2>\n"
613 "<lt2 xmlns=\"urn:tests:d\">\n"
614 " <k>val5</k>\n"
615 " <cont>\n"
616 " <l2>5</l2>\n"
617 " </cont>\n"
618 " <l4>1</l4>\n"
619 " <l5>3</l5>\n"
620 " <l6>3</l6>\n"
621 "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
622 CHECK_LOG_CTX("Unique data leaf(s) \"l5 l6\" not satisfied in \"/d:lt2[k='val5']\" and \"/d:lt2[k='val3']\".",
Radek Krejci2efc45b2020-12-22 16:25:44 +0100623 "Schema location /d:lt2, data location /d:lt2[k='val3'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200624}
625
626static void
627test_dup(void **state)
628{
629 struct lyd_node *tree;
630 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100631 "module e {\n"
632 " namespace urn:tests:e;\n"
633 " prefix e;\n"
634 " yang-version 1.1;\n"
635 "\n"
636 " choice choic {\n"
637 " leaf a {\n"
638 " type string;\n"
639 " }\n"
640 " case b {\n"
641 " leaf-list l {\n"
642 " type string;\n"
643 " }\n"
644 " }\n"
645 " }\n"
646 " list lt {\n"
647 " key \"k\";\n"
648 " leaf k {\n"
649 " type string;\n"
650 " }\n"
651 " }\n"
652 " leaf d {\n"
653 " type uint32;\n"
654 " }\n"
655 " leaf-list ll {\n"
656 " type string;\n"
657 " }\n"
658 " container cont {\n"
659 " list lt {\n"
660 " key \"k\";\n"
661 " leaf k {\n"
662 " type string;\n"
663 " }\n"
664 " }\n"
665 " leaf d {\n"
666 " type uint32;\n"
667 " }\n"
668 " leaf-list ll {\n"
669 " type string;\n"
670 " }\n"
671 " leaf-list ll2 {\n"
672 " type enumeration {\n"
673 " enum one;\n"
674 " enum two;\n"
675 " }\n"
676 " }\n"
677 " }\n"
678 "}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200679
680 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
681
682 CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:e\">25</d><d xmlns=\"urn:tests:e\">50</d>",
683 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100684 CHECK_LOG_CTX("Duplicate instance of \"d\".", "Schema location /e:d, data location /e:d.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200685
686 CHECK_PARSE_LYD_PARAM("<lt xmlns=\"urn:tests:e\"><k>A</k></lt>"
687 "<lt xmlns=\"urn:tests:e\"><k>B</k></lt>"
688 "<lt xmlns=\"urn:tests:e\"><k>A</k></lt>",
689 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100690 CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Schema location /e:lt, data location /e:lt[k='A'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200691
692 CHECK_PARSE_LYD_PARAM("<ll xmlns=\"urn:tests:e\">A</ll>"
693 "<ll xmlns=\"urn:tests:e\">B</ll>"
694 "<ll xmlns=\"urn:tests:e\">B</ll>",
695 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100696 CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Schema location /e:ll, data location /e:ll[.='B'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200697
698 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"></cont><cont xmlns=\"urn:tests:e\"/>",
699 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100700 CHECK_LOG_CTX("Duplicate instance of \"cont\".", "Schema location /e:cont, data location /e:cont.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200701
702 /* same tests again but using hashes */
703 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><d>25</d><d>50</d><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll></cont>",
704 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100705 CHECK_LOG_CTX("Duplicate instance of \"d\".", "Schema location /e:cont/d, data location /e:cont/d, line number 1.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200706
707 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
708 "<lt><k>a</k></lt>"
709 "<lt><k>b</k></lt>"
710 "<lt><k>c</k></lt>"
711 "<lt><k>d</k></lt>"
712 "<lt><k>c</k></lt></cont>",
713 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100714 CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Schema location /e:cont/lt, data location /e:cont/lt[k='c'], line number 1.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200715
716 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
717 "<ll>a</ll><ll>b</ll><ll>c</ll><ll>d</ll><ll>d</ll></cont>",
718 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100719 CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Schema location /e:cont/ll, data location /e:cont/ll[.='d'], line number 1.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200720
721 /* cases */
722 CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:e\">a</l>"
723 "<l xmlns=\"urn:tests:e\">b</l>"
724 "<l xmlns=\"urn:tests:e\">c</l>"
725 "<l xmlns=\"urn:tests:e\">b</l>",
726 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100727 CHECK_LOG_CTX("Duplicate instance of \"l\".", "Schema location /e:choic/b/l, data location /e:l[.='b'].");
Radek Iša56ca9e42020-09-08 18:42:00 +0200728
729 CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:e\">a</l><l xmlns=\"urn:tests:e\">b</l>"
730 "<l xmlns=\"urn:tests:e\">c</l>"
731 "<a xmlns=\"urn:tests:e\">aa</a>",
732 LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +0100733 CHECK_LOG_CTX("Data for both cases \"a\" and \"b\" exist.", "Schema location /e:choic.");
Radek Iša56ca9e42020-09-08 18:42:00 +0200734}
735
736static void
737test_defaults(void **state)
738{
739 struct lyd_node *tree, *node, *diff;
740 const struct lys_module *mod;
741 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100742 "module f {\n"
743 " namespace urn:tests:f;\n"
744 " prefix f;\n"
745 " yang-version 1.1;\n"
746 "\n"
747 " choice choic {\n"
748 " default \"c\";\n"
749 " leaf a {\n"
750 " type string;\n"
751 " }\n"
752 " case b {\n"
753 " leaf l {\n"
754 " type string;\n"
755 " }\n"
756 " }\n"
757 " case c {\n"
758 " leaf-list ll1 {\n"
759 " type string;\n"
760 " default \"def1\";\n"
761 " default \"def2\";\n"
762 " default \"def3\";\n"
763 " }\n"
764 " }\n"
765 " }\n"
766 " leaf d {\n"
767 " type uint32;\n"
768 " default 15;\n"
769 " }\n"
770 " leaf-list ll2 {\n"
771 " type string;\n"
772 " default \"dflt1\";\n"
773 " default \"dflt2\";\n"
774 " }\n"
775 " container cont {\n"
776 " choice choic {\n"
777 " default \"c\";\n"
778 " leaf a {\n"
779 " type string;\n"
780 " }\n"
781 " case b {\n"
782 " leaf l {\n"
783 " type string;\n"
784 " }\n"
785 " }\n"
786 " case c {\n"
787 " leaf-list ll1 {\n"
788 " type string;\n"
789 " default \"def1\";\n"
790 " default \"def2\";\n"
791 " default \"def3\";\n"
792 " }\n"
793 " }\n"
794 " }\n"
795 " leaf d {\n"
796 " type uint32;\n"
797 " default 15;\n"
798 " }\n"
799 " leaf-list ll2 {\n"
800 " type string;\n"
801 " default \"dflt1\";\n"
802 " default \"dflt2\";\n"
803 " }\n"
804 " }\n"
805 "}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200806
807 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, &mod);
808
809 assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG));
810 assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-netconf-with-defaults", "2011-06-01", NULL));\
811
812 /* get defaults */
813 tree = NULL;
814 assert_int_equal(lyd_validate_module(&tree, mod, 0, &diff), LY_SUCCESS);
815 assert_non_null(tree);
816 assert_non_null(diff);
817
818 /* check all defaults exist */
819 CHECK_LYD_STRING_PARAM(tree,
820 "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
821 "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
822 "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
823 "<d xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
824 "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
825 "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
826 "<cont xmlns=\"urn:tests:f\">\n"
827 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
828 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
829 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
830 " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
831 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
832 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
833 "</cont>\n",
834 LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_WITHSIBLINGS);
835
836 /* check diff */
837 CHECK_LYD_STRING_PARAM(diff,
838 "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def1</ll1>\n"
839 "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def2</ll1>\n"
840 "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def3</ll1>\n"
841 "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">15</d>\n"
842 "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">dflt1</ll2>\n"
843 "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">dflt2</ll2>\n"
844 "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n"
845 " <ll1 yang:operation=\"create\">def1</ll1>\n"
846 " <ll1 yang:operation=\"create\">def2</ll1>\n"
847 " <ll1 yang:operation=\"create\">def3</ll1>\n"
848 " <d yang:operation=\"create\">15</d>\n"
849 " <ll2 yang:operation=\"create\">dflt1</ll2>\n"
850 " <ll2 yang:operation=\"create\">dflt2</ll2>\n"
851 "</cont>\n",
852 LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_WITHSIBLINGS);
853 lyd_free_all(diff);
854
855 /* create another explicit case and validate */
856 assert_int_equal(lyd_new_term(NULL, mod, "l", "value", 0, &node), LY_SUCCESS);
857 assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
858 assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
859
860 /* check data tree */
861 CHECK_LYD_STRING_PARAM(tree,
862 "<l xmlns=\"urn:tests:f\">value</l>\n"
863 "<d xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
864 "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
865 "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
866 "<cont xmlns=\"urn:tests:f\">\n"
867 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
868 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
869 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
870 " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
871 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
872 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
873 "</cont>\n",
874 LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_WITHSIBLINGS);
875
876 /* check diff */
877 CHECK_LYD_STRING_PARAM(diff,
878 "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def1</ll1>\n"
879 "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def2</ll1>\n"
880 "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def3</ll1>\n",
881 LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_WITHSIBLINGS);
882 lyd_free_all(diff);
883
884 /* create explicit leaf-list and leaf and validate */
885 assert_int_equal(lyd_new_term(NULL, mod, "d", "15", 0, &node), LY_SUCCESS);
886 assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
887 assert_int_equal(lyd_new_term(NULL, mod, "ll2", "dflt2", 0, &node), LY_SUCCESS);
888 assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
889 assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
890
891 /* check data tree */
892 CHECK_LYD_STRING_PARAM(tree,
893 "<l xmlns=\"urn:tests:f\">value</l>\n"
894 "<d xmlns=\"urn:tests:f\">15</d>\n"
895 "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
896 "<cont xmlns=\"urn:tests:f\">\n"
897 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
898 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
899 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
900 " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
901 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
902 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
903 "</cont>\n",
904 LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_WITHSIBLINGS);
905
906 /* check diff */
907 CHECK_LYD_STRING_PARAM(diff,
908 "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">15</d>\n"
909 "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt1</ll2>\n"
910 "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt2</ll2>\n",
911 LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_WITHSIBLINGS);
912 lyd_free_all(diff);
913
914 /* create first explicit container, which should become implicit */
915 assert_int_equal(lyd_new_inner(NULL, mod, "cont", 0, &node), LY_SUCCESS);
916 assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
917 assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
918
919 /* check data tree */
920 CHECK_LYD_STRING_PARAM(tree,
921 "<l xmlns=\"urn:tests:f\">value</l>\n"
922 "<d xmlns=\"urn:tests:f\">15</d>\n"
923 "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
924 "<cont xmlns=\"urn:tests:f\">\n"
925 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
926 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
927 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
928 " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
929 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
930 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
931 "</cont>\n",
932 LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_WITHSIBLINGS);
933 /* check diff */
934 assert_null(diff);
935
936 /* create second explicit container, which should become implicit, so the first tree node should be removed */
937 assert_int_equal(lyd_new_inner(NULL, mod, "cont", 0, &node), LY_SUCCESS);
938 assert_int_equal(lyd_insert_sibling(tree, node, &tree), LY_SUCCESS);
939 assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
940
941 /* check data tree */
942 CHECK_LYD_STRING_PARAM(tree,
943 "<l xmlns=\"urn:tests:f\">value</l>\n"
944 "<d xmlns=\"urn:tests:f\">15</d>\n"
945 "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
946 "<cont xmlns=\"urn:tests:f\">\n"
947 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
948 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
949 " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
950 " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
951 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
952 " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
953 "</cont>\n",
954 LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_WITHSIBLINGS);
955 /* check diff */
956 assert_null(diff);
957
958 /* similar changes for nested defaults */
959 assert_int_equal(lyd_new_term(tree->prev, NULL, "ll1", "def3", 0, NULL), LY_SUCCESS);
960 assert_int_equal(lyd_new_term(tree->prev, NULL, "d", "5", 0, NULL), LY_SUCCESS);
961 assert_int_equal(lyd_new_term(tree->prev, NULL, "ll2", "non-dflt", 0, NULL), LY_SUCCESS);
962 assert_int_equal(lyd_validate_all(&tree, UTEST_LYCTX, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
963
964 /* check data tree */
965 CHECK_LYD_STRING_PARAM(tree,
966 "<l xmlns=\"urn:tests:f\">value</l>\n"
967 "<d xmlns=\"urn:tests:f\">15</d>\n"
968 "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
969 "<cont xmlns=\"urn:tests:f\">\n"
970 " <ll1>def3</ll1>\n"
971 " <d>5</d>\n"
972 " <ll2>non-dflt</ll2>\n"
973 "</cont>\n",
974 LYD_XML, LYD_PRINT_WITHSIBLINGS);
975
976 /* check diff */
977 CHECK_LYD_STRING_PARAM(diff,
978 "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
979 " <ll1 yang:operation=\"delete\">def1</ll1>\n"
980 " <ll1 yang:operation=\"delete\">def2</ll1>\n"
981 " <ll1 yang:operation=\"delete\">def3</ll1>\n"
982 " <d yang:operation=\"delete\">15</d>\n"
983 " <ll2 yang:operation=\"delete\">dflt1</ll2>\n"
984 " <ll2 yang:operation=\"delete\">dflt2</ll2>\n"
985 "</cont>\n",
986 LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_WITHSIBLINGS);
987 lyd_free_all(diff);
988 lyd_free_all(tree);
989}
990
991static void
992test_state(void **state)
993{
994 const char *data;
995 struct lyd_node *tree;
996 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100997 "module h {\n"
998 " namespace urn:tests:h;\n"
999 " prefix h;\n"
1000 " yang-version 1.1;\n"
1001 "\n"
1002 " container cont {\n"
1003 " container cont2 {\n"
1004 " config false;\n"
1005 " leaf l {\n"
1006 " type string;\n"
1007 " }\n"
1008 " }\n"
1009 " }\n"
1010 "}";
Radek Iša56ca9e42020-09-08 18:42:00 +02001011
1012 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
1013
1014 data = "<cont xmlns=\"urn:tests:h\">\n"
1015 " <cont2>\n"
1016 " <l>val</l>\n"
1017 " </cont2>\n"
1018 "</cont>\n";
1019 CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_NO_STATE, 0, LY_EVALID, tree);
Michal Vasko224e7772021-02-18 14:22:33 +01001020 CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.",
Radek Krejci2efc45b2020-12-22 16:25:44 +01001021 "Schema location /h:cont/cont2, data location /h:cont, line number 3.");
Radek Iša56ca9e42020-09-08 18:42:00 +02001022
1023 CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
1024 assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, NULL));
Michal Vasko224e7772021-02-18 14:22:33 +01001025 CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.",
Radek Krejci2efc45b2020-12-22 16:25:44 +01001026 "Schema location /h:cont/cont2, data location /h:cont/cont2.");
Radek Iša56ca9e42020-09-08 18:42:00 +02001027 lyd_free_all(tree);
1028}
1029
1030static void
1031test_must(void **state)
1032{
1033 struct lyd_node *tree;
1034 const char *schema =
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001035 "module i {\n"
1036 " namespace urn:tests:i;\n"
1037 " prefix i;\n"
1038 " yang-version 1.1;\n"
1039 "\n"
1040 " container cont {\n"
1041 " leaf l {\n"
1042 " type string;\n"
1043 " }\n"
1044 " leaf l2 {\n"
1045 " must \"../l = 'right'\";\n"
1046 " type string;\n"
1047 " }\n"
1048 " }\n"
1049 "}";
Michal Vaskocde73ac2019-11-14 16:10:27 +01001050
Radek Iša56ca9e42020-09-08 18:42:00 +02001051 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
Michal Vaskocde73ac2019-11-14 16:10:27 +01001052
Radek Iša56ca9e42020-09-08 18:42:00 +02001053 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:i\">\n"
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001054 " <l>wrong</l>\n"
1055 " <l2>val</l2>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001056 "</cont>\n", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
Radek Krejci2efc45b2020-12-22 16:25:44 +01001057 CHECK_LOG_CTX("Must condition \"../l = 'right'\" not satisfied.",
1058 "Schema location /i:cont/l2, data location /i:cont/l2.");
Michal Vaskocc048b22020-03-27 15:52:38 +01001059
Radek Iša56ca9e42020-09-08 18:42:00 +02001060 LYD_TREE_CREATE("<cont xmlns=\"urn:tests:i\">\n"
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001061 " <l>right</l>\n"
1062 " <l2>val</l2>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001063 "</cont>\n", tree);
1064 lyd_free_all(tree);
Michal Vaskocc048b22020-03-27 15:52:38 +01001065}
1066
Radek Iša56ca9e42020-09-08 18:42:00 +02001067const char *schema_j =
1068 "module j {\n"
1069 " namespace urn:tests:j;\n"
1070 " prefix j;\n"
1071 " yang-version 1.1;\n"
1072 "\n"
1073 " feature feat1;\n"
1074 "\n"
1075 " container cont {\n"
1076 " must \"false()\";\n"
1077 " list l1 {\n"
1078 " key \"k\";\n"
1079 " leaf k {\n"
1080 " type string;\n"
1081 " }\n"
1082 " action act {\n"
1083 " if-feature feat1;\n"
1084 " input {\n"
1085 " must \"../../lf1 = 'true'\";\n"
1086 " leaf lf2 {\n"
1087 " type leafref {\n"
1088 " path /lf3;\n"
1089 " }\n"
1090 " }\n"
1091 " }\n"
1092 " output {\n"
1093 " must \"../../lf1 = 'true2'\";\n"
1094 " leaf lf2 {\n"
1095 " type leafref {\n"
1096 " path /lf4;\n"
1097 " }\n"
1098 " }\n"
1099 " }\n"
1100 " }\n"
1101 " }\n"
1102 "\n"
1103 " leaf lf1 {\n"
1104 " type string;\n"
1105 " }\n"
1106 " }\n"
1107 "\n"
1108 " leaf lf3 {\n"
1109 " type string;\n"
1110 " }\n"
1111 "\n"
1112 " leaf lf4 {\n"
1113 " type string;\n"
1114 " }\n"
1115 "}";
1116const char *feats_j[] = {"feat1", NULL};
1117
Michal Vaskofea12c62020-03-30 11:00:15 +02001118static void
1119test_action(void **state)
1120{
Michal Vasko63f3d842020-07-08 10:10:14 +02001121 struct ly_in *in;
Michal Vaskofea12c62020-03-30 11:00:15 +02001122 struct lyd_node *tree, *op_tree;
Michal Vaskofea12c62020-03-30 11:00:15 +02001123
Radek Iša56ca9e42020-09-08 18:42:00 +02001124 UTEST_ADD_MODULE(schema_j, LYS_IN_YANG, feats_j, NULL);
1125
1126 assert_int_equal(LY_SUCCESS, ly_in_new_memory(
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001127 "<cont xmlns=\"urn:tests:j\">\n"
1128 " <l1>\n"
1129 " <k>val1</k>\n"
1130 " <act>\n"
1131 " <lf2>target</lf2>\n"
1132 " </act>\n"
1133 " </l1>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001134 "</cont>\n", &in));
Michal Vaskoe0665742021-02-11 11:08:44 +01001135 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_YANG_RPC, &op_tree, NULL));
Michal Vaskofea12c62020-03-30 11:00:15 +02001136 assert_non_null(op_tree);
1137
1138 /* missing leafref */
Michal Vaskoe0665742021-02-11 11:08:44 +01001139 assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_TYPE_YANG_RPC, NULL));
Radek Krejci2efc45b2020-12-22 16:25:44 +01001140 CHECK_LOG_CTX("Invalid leafref value \"target\" - no existing target instance \"/lf3\".",
Radek Krejci2a9fc652021-01-22 17:44:34 +01001141 "Schema location /j:cont/l1/act/input/lf2, data location /j:cont/l1[k='val1']/act/lf2.");
Michal Vasko63f3d842020-07-08 10:10:14 +02001142 ly_in_free(in, 0);
Michal Vaskofea12c62020-03-30 11:00:15 +02001143
Radek Iša56ca9e42020-09-08 18:42:00 +02001144 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001145 " <lf1>not true</lf1>\n"
1146 "</cont>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001147 "<lf3 xmlns=\"urn:tests:j\">target</lf3>\n",
1148 LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
Michal Vaskofea12c62020-03-30 11:00:15 +02001149
Michal Vaskofea12c62020-03-30 11:00:15 +02001150 /* input must false */
Michal Vaskoe0665742021-02-11 11:08:44 +01001151 assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_TYPE_YANG_RPC, NULL));
Radek Krejci2efc45b2020-12-22 16:25:44 +01001152 CHECK_LOG_CTX("Must condition \"../../lf1 = 'true'\" not satisfied.",
1153 "Data location /j:cont/l1[k='val1']/act.");
Michal Vaskofea12c62020-03-30 11:00:15 +02001154
Radek Iša56ca9e42020-09-08 18:42:00 +02001155 lyd_free_all(tree);
1156 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001157 " <lf1>true</lf1>\n"
1158 "</cont>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001159 "<lf3 xmlns=\"urn:tests:j\">target</lf3>\n",
1160 LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
Michal Vaskofea12c62020-03-30 11:00:15 +02001161
1162 /* success */
Michal Vaskoe0665742021-02-11 11:08:44 +01001163 assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_TYPE_YANG_RPC, NULL));
Michal Vaskofea12c62020-03-30 11:00:15 +02001164
Michal Vaskocb7526d2020-03-30 15:08:26 +02001165 lyd_free_tree(op_tree);
1166 lyd_free_siblings(tree);
Michal Vaskocb7526d2020-03-30 15:08:26 +02001167}
1168
1169static void
1170test_reply(void **state)
1171{
Michal Vasko63f3d842020-07-08 10:10:14 +02001172 struct ly_in *in;
Michal Vasko2552ea32020-12-08 15:32:34 +01001173 struct lyd_node *tree, *op_tree;
Michal Vaskocb7526d2020-03-30 15:08:26 +02001174
Radek Iša56ca9e42020-09-08 18:42:00 +02001175 UTEST_ADD_MODULE(schema_j, LYS_IN_YANG, feats_j, NULL);
1176
1177 assert_int_equal(LY_SUCCESS, ly_in_new_memory(
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001178 "<cont xmlns=\"urn:tests:j\">\n"
1179 " <l1>\n"
1180 " <k>val1</k>\n"
1181 " <act>\n"
1182 " <lf2>target</lf2>\n"
1183 " </act>\n"
1184 " </l1>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001185 "</cont>\n", &in));
Michal Vaskoe0665742021-02-11 11:08:44 +01001186 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_YANG_REPLY, &op_tree, NULL));
Michal Vaskocb7526d2020-03-30 15:08:26 +02001187 assert_non_null(op_tree);
Michal Vasko63f3d842020-07-08 10:10:14 +02001188 ly_in_free(in, 0);
Michal Vaskocb7526d2020-03-30 15:08:26 +02001189
1190 /* missing leafref */
Michal Vaskoe0665742021-02-11 11:08:44 +01001191 assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_TYPE_YANG_REPLY, NULL));
Radek Krejci2efc45b2020-12-22 16:25:44 +01001192 CHECK_LOG_CTX("Invalid leafref value \"target\" - no existing target instance \"/lf4\".",
Radek Krejci2a9fc652021-01-22 17:44:34 +01001193 "Schema location /j:cont/l1/act/output/lf2, data location /j:cont/l1[k='val1']/act/lf2.");
Michal Vaskocb7526d2020-03-30 15:08:26 +02001194
Radek Iša56ca9e42020-09-08 18:42:00 +02001195 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001196 " <lf1>not true</lf1>\n"
1197 "</cont>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001198 "<lf4 xmlns=\"urn:tests:j\">target</lf4>\n",
1199 LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
Michal Vaskocb7526d2020-03-30 15:08:26 +02001200
Michal Vaskocb7526d2020-03-30 15:08:26 +02001201 /* input must false */
Michal Vaskoe0665742021-02-11 11:08:44 +01001202 assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_TYPE_YANG_REPLY, NULL));
Radek Krejci2efc45b2020-12-22 16:25:44 +01001203 CHECK_LOG_CTX("Must condition \"../../lf1 = 'true2'\" not satisfied.", "Data location /j:cont/l1[k='val1']/act.");
Michal Vaskocb7526d2020-03-30 15:08:26 +02001204
Radek Iša56ca9e42020-09-08 18:42:00 +02001205 lyd_free_all(tree);
1206 CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001207 " <lf1>true2</lf1>\n"
1208 "</cont>\n"
Radek Iša56ca9e42020-09-08 18:42:00 +02001209 "<lf4 xmlns=\"urn:tests:j\">target</lf4>\n",
1210 LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
Michal Vaskocb7526d2020-03-30 15:08:26 +02001211
1212 /* success */
Michal Vaskoe0665742021-02-11 11:08:44 +01001213 assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_TYPE_YANG_REPLY, NULL));
Michal Vaskocb7526d2020-03-30 15:08:26 +02001214
Michal Vaskofea12c62020-03-30 11:00:15 +02001215 lyd_free_tree(op_tree);
Radek Iša56ca9e42020-09-08 18:42:00 +02001216 lyd_free_all(tree);
Michal Vaskofea12c62020-03-30 11:00:15 +02001217}
1218
Radek Krejcib4ac5a92020-11-23 17:54:33 +01001219int
1220main(void)
Michal Vaskocde73ac2019-11-14 16:10:27 +01001221{
1222 const struct CMUnitTest tests[] = {
Radek Iša56ca9e42020-09-08 18:42:00 +02001223 UTEST(test_when),
1224 UTEST(test_mandatory),
Christian Hoppsb6ecaea2021-02-06 09:45:38 -05001225 UTEST(test_mandatory_when),
Radek Iša56ca9e42020-09-08 18:42:00 +02001226 UTEST(test_minmax),
1227 UTEST(test_unique),
1228 UTEST(test_unique_nested),
1229 UTEST(test_dup),
1230 UTEST(test_defaults),
1231 UTEST(test_state),
1232 UTEST(test_must),
1233 UTEST(test_action),
1234 UTEST(test_reply),
Michal Vaskocde73ac2019-11-14 16:10:27 +01001235 };
1236
Radek Iša56ca9e42020-09-08 18:42:00 +02001237 return cmocka_run_group_tests(tests, NULL, NULL);
Michal Vaskocde73ac2019-11-14 16:10:27 +01001238}