blob: 09466bb401ad5465f70cd253ff9299d1a426e037 [file] [log] [blame]
Radek Krejci1798aae2020-07-14 13:26:06 +02001/*
aPiecek023f83a2021-05-11 07:37:03 +02002 * @file test_parser_json.c
Radek Krejci1798aae2020-07-14 13:26:06 +02003 * @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 */
Radek Iša56ca9e42020-09-08 18:42:00 +020014#define _UTEST_MAIN_
15#include "utests.h"
Radek Krejci1798aae2020-07-14 13:26:06 +020016
Radek Krejci1798aae2020-07-14 13:26:06 +020017#include "context.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020018#include "in.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020019#include "out.h"
Radek Krejcib4ac5a92020-11-23 17:54:33 +010020#include "parser_data.h"
Radek Krejci1798aae2020-07-14 13:26:06 +020021#include "printer_data.h"
Radek Krejcief5f7672021-04-01 17:04:12 +020022#include "tests_config.h"
Radek Krejci1798aae2020-07-14 13:26:06 +020023#include "tree_data_internal.h"
24#include "tree_schema.h"
Radek Krejci1798aae2020-07-14 13:26:06 +020025
26static int
27setup(void **state)
28{
Radek Iša56ca9e42020-09-08 18:42:00 +020029 const char *schema = "module a {namespace urn:tests:a;prefix a;yang-version 1.1; import ietf-yang-metadata {prefix md;}"
Radek Krejci1798aae2020-07-14 13:26:06 +020030 "md:annotation hint { type int8;}"
Michal Vaskodbf3e652022-10-21 08:46:25 +020031 "list l1 { key \"a b c\"; leaf a {type string;} leaf b {type string;} leaf c {type int16;}"
32 " leaf d {type string;}"
33 " container cont {leaf e {type boolean;}}"
34 "}"
Radek Krejci1798aae2020-07-14 13:26:06 +020035 "leaf foo { type string;}"
36 "container c {"
Radek Krejcib4ac5a92020-11-23 17:54:33 +010037 " leaf x {type string;}"
38 " action act { input { leaf al {type string;} } output { leaf al {type uint8;} } }"
39 " notification n1 { leaf nl {type string;} }"
Radek Krejci1798aae2020-07-14 13:26:06 +020040 "}"
41 "container cp {presence \"container switch\"; leaf y {type string;} leaf z {type int8;}}"
42 "anydata any {config false;}"
Michal Vasko76096ec2022-02-24 16:06:16 +010043 "anyxml axml;"
Radek Krejci1798aae2020-07-14 13:26:06 +020044 "leaf-list ll1 { type uint8; }"
45 "leaf foo2 { type string; default \"default-val\"; }"
46 "leaf foo3 { type uint32; }"
47 "notification n2;}";
Radek Krejci1798aae2020-07-14 13:26:06 +020048
Radek Iša56ca9e42020-09-08 18:42:00 +020049 UTEST_SETUP;
Radek Krejci1798aae2020-07-14 13:26:06 +020050
Radek Iša56ca9e42020-09-08 18:42:00 +020051 UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
52 assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG));
Radek Krejci1798aae2020-07-14 13:26:06 +020053
54 return 0;
55}
56
Radek Iša56ca9e42020-09-08 18:42:00 +020057#define CHECK_PARSE_LYD(INPUT, PARSE_OPTION, VALIDATE_OPTION, TREE) \
58 CHECK_PARSE_LYD_PARAM(INPUT, LYD_JSON, PARSE_OPTION, VALIDATE_OPTION, LY_SUCCESS, TREE)
Radek Krejci1798aae2020-07-14 13:26:06 +020059
Radek Iša56ca9e42020-09-08 18:42:00 +020060#define PARSER_CHECK_ERROR(INPUT, PARSE_OPTION, VALIDATE_OPTION, MODEL, RET_VAL, ERR_MESSAGE, ERR_PATH) \
61 assert_int_equal(RET_VAL, lyd_parse_data_mem(UTEST_LYCTX, INPUT, LYD_JSON, PARSE_OPTION, VALIDATE_OPTION, &MODEL));\
62 CHECK_LOG_CTX(ERR_MESSAGE, ERR_PATH);\
63 assert_null(MODEL)
Radek Krejci1798aae2020-07-14 13:26:06 +020064
Radek Iša56ca9e42020-09-08 18:42:00 +020065#define CHECK_LYD_STRING(IN_MODEL, PRINT_OPTION, TEXT) \
66 CHECK_LYD_STRING_PARAM(IN_MODEL, TEXT, LYD_JSON, PRINT_OPTION)
Radek Krejci1798aae2020-07-14 13:26:06 +020067
68static void
69test_leaf(void **state)
70{
Radek Krejci1798aae2020-07-14 13:26:06 +020071 struct lyd_node *tree;
72 struct lyd_node_term *leaf;
Radek Iša56ca9e42020-09-08 18:42:00 +020073 const char *data;
Radek Krejci1798aae2020-07-14 13:26:06 +020074
Radek Iša56ca9e42020-09-08 18:42:00 +020075 assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-netconf-with-defaults", "2011-06-01", NULL));
Radek Krejcib4ac5a92020-11-23 17:54:33 +010076
Radek Iša56ca9e42020-09-08 18:42:00 +020077 data = "{\"a:foo\":\"foo value\"}";
78 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
79 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "foo", 1, LYS_LEAF, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +010080 leaf = (struct lyd_node_term *)tree;
Radek Iša56ca9e42020-09-08 18:42:00 +020081 CHECK_LYD_VALUE(leaf->value, STRING, "foo value");
Radek Krejci1798aae2020-07-14 13:26:06 +020082
Radek Iša56ca9e42020-09-08 18:42:00 +020083 CHECK_LYSC_NODE(tree->next->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_SET_DFLT, 1, "foo2",
84 1, LYS_LEAF, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +010085 leaf = (struct lyd_node_term *)tree->next->next;
Radek Iša56ca9e42020-09-08 18:42:00 +020086
87 CHECK_LYD_VALUE(leaf->value, STRING, "default-val");
Radek Krejci1798aae2020-07-14 13:26:06 +020088 assert_true(leaf->flags & LYD_DEFAULT);
89
Radek Iša56ca9e42020-09-08 18:42:00 +020090 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +020091 lyd_free_all(tree);
92
93 /* make foo2 explicit */
94 data = "{\"a:foo2\":\"default-val\"}";
Radek Iša56ca9e42020-09-08 18:42:00 +020095 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +020096 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +010097 tree = tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +020098 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_SET_DFLT, 1, "foo2",
99 1, LYS_LEAF, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100100 leaf = (struct lyd_node_term *)tree;
Radek Iša56ca9e42020-09-08 18:42:00 +0200101 CHECK_LYD_VALUE(leaf->value, STRING, "default-val");
Radek Krejci1798aae2020-07-14 13:26:06 +0200102 assert_false(leaf->flags & LYD_DEFAULT);
103
Radek Iša56ca9e42020-09-08 18:42:00 +0200104 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200105 lyd_free_all(tree);
106
107 /* parse foo2 but make it implicit */
Radek Krejci5536d282020-08-04 23:27:44 +0200108 data = "{\"a:foo2\":\"default-val\",\"@a:foo2\":{\"ietf-netconf-with-defaults:default\":true}}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200109 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200110 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100111 tree = tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200112 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_SET_DFLT, 1, "foo2",
113 1, LYS_LEAF, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100114 leaf = (struct lyd_node_term *)tree;
Radek Iša56ca9e42020-09-08 18:42:00 +0200115 CHECK_LYD_VALUE(leaf->value, STRING, "default-val");
Radek Krejci1798aae2020-07-14 13:26:06 +0200116 assert_true(leaf->flags & LYD_DEFAULT);
117
Michal Vaskob68c3b42022-05-20 10:36:40 +0200118 /* print default values */
119 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200120 lyd_free_all(tree);
121
Michal Vaskoa4af6252022-05-20 10:38:54 +0200122 /* skip leaf */
123 data = "{\"a:cp\":{\"x\":\"val\",\"y\":\"valy\",\"z\":5}}";
124 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
125 assert_non_null(tree);
126
127 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, "{\"a:cp\":{\"y\":\"valy\",\"z\":5}}");
128 lyd_free_all(tree);
129
Radek Krejci1798aae2020-07-14 13:26:06 +0200130 /* multiple meatadata hint and unknown metadata xxx supposed to be skipped since it is from missing schema */
Radek Krejci5536d282020-08-04 23:27:44 +0200131 data = "{\"@a:foo\":{\"a:hint\":1,\"a:hint\":2,\"x:xxx\":{\"value\":\"/x:no/x:yes\"}},\"a:foo\":\"xxx\"}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200132 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
133 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "foo", 1, LYS_LEAF, 0, 0, NULL, 0);
134 CHECK_LYD_META(tree->meta, 1, "hint", 1, 1, INT8, "1", 1);
135 CHECK_LYD_META(tree->meta->next, 1, "hint", 0, 1, INT8, "2", 2);
Radek Krejci1798aae2020-07-14 13:26:06 +0200136 assert_null(tree->meta->next->next);
137
Radek Iša56ca9e42020-09-08 18:42:00 +0200138 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
139 "{\"a:foo\":\"xxx\",\"@a:foo\":{\"a:hint\":1,\"a:hint\":2}}");
Radek Krejci1798aae2020-07-14 13:26:06 +0200140 lyd_free_all(tree);
141
Radek Iša56ca9e42020-09-08 18:42:00 +0200142 PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200143 "Unknown (or not implemented) YANG module \"x\" of metadata \"x:xxx\".", "Data location \"/@a:foo\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200144
145 /* missing referenced metadata node */
Radek Iša56ca9e42020-09-08 18:42:00 +0200146 PARSER_CHECK_ERROR("{\"@a:foo\" : { \"a:hint\" : 1 }}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200147 "Missing JSON data instance to be coupled with @a:foo metadata.", "Data location \"/@a:foo\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200148
149 /* missing namespace for meatadata*/
Radek Iša56ca9e42020-09-08 18:42:00 +0200150 PARSER_CHECK_ERROR("{\"a:foo\" : \"value\", \"@a:foo\" : { \"hint\" : 1 }}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200151 "Metadata in JSON must be namespace-qualified, missing prefix for \"hint\".",
152 "Schema location \"/a:foo\", line number 1.");
aPiecek49e2a3a2021-05-13 10:36:46 +0200153
Michal Vaskodbf3e652022-10-21 08:46:25 +0200154 /* invalid JSON type */
155 data = "{\"a:l1\" : [{ \"a\" : \"val-a\", \"b\" : \"val-b\", \"c\" : 1, \"cont\" : { \"e\" : \"0\" } }]}";
156 PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
157 "Invalid non-boolean-encoded boolean value \"0\".",
158 "Data location \"/a:l1[a='val-a'][b='val-b'][c='1']/cont/e\", line number 1.");
159
aPiecek49e2a3a2021-05-13 10:36:46 +0200160 /* reverse solidus in JSON object member name */
161 data = "{\"@a:foo\":{\"a:hi\\nt\":1},\"a:foo\":\"xxx\"}";
162 assert_int_equal(LY_EINVAL, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
Michal Vasko62af3692023-02-09 14:00:09 +0100163 CHECK_LOG_CTX("Annotation definition for attribute \"a:hi\nt\" not found.", "Data location \"/@a:foo\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200164}
165
166static void
167test_leaflist(void **state)
168{
Radek Iša56ca9e42020-09-08 18:42:00 +0200169 const char *data;
Radek Krejci1798aae2020-07-14 13:26:06 +0200170 struct lyd_node *tree;
171 struct lyd_node_term *ll;
172
Radek Iša56ca9e42020-09-08 18:42:00 +0200173 data = "{\"a:ll1\":[10,11]}";
174 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200175 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100176 tree = tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200177 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
178 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100179 ll = (struct lyd_node_term *)tree;
Radek Iša56ca9e42020-09-08 18:42:00 +0200180 CHECK_LYD_VALUE(ll->value, UINT8, "10", 10);
Radek Krejci1798aae2020-07-14 13:26:06 +0200181
182 assert_non_null(tree->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200183 CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
184 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100185 ll = (struct lyd_node_term *)tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200186 CHECK_LYD_VALUE(ll->value, UINT8, "11", 11);
Radek Krejci1798aae2020-07-14 13:26:06 +0200187
Radek Iša56ca9e42020-09-08 18:42:00 +0200188 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200189 lyd_free_all(tree);
190
Michal Vasko4e26adc2022-03-30 11:01:16 +0200191 /* accept empty */
192 data = "{\"a:ll1\":[]}";
193 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
194 assert_null(tree);
195
Radek Krejci1798aae2020-07-14 13:26:06 +0200196 /* simple metadata */
Radek Krejci5536d282020-08-04 23:27:44 +0200197 data = "{\"a:ll1\":[10,11],\"@a:ll1\":[null,{\"a:hint\":2}]}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200198 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200199 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100200 tree = tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200201 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
202 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100203 ll = (struct lyd_node_term *)tree;
Radek Iša56ca9e42020-09-08 18:42:00 +0200204 CHECK_LYD_VALUE(ll->value, UINT8, "10", 10);
Radek Krejci1798aae2020-07-14 13:26:06 +0200205 assert_null(ll->meta);
206
207 assert_non_null(tree->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200208 CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
209 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100210 ll = (struct lyd_node_term *)tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200211 CHECK_LYD_VALUE(ll->value, UINT8, "11", 11);
212 CHECK_LYD_META(ll->meta, 1, "hint", 0, 1, INT8, "2", 2);
Radek Krejci1798aae2020-07-14 13:26:06 +0200213 assert_null(ll->meta->next);
214
Radek Iša56ca9e42020-09-08 18:42:00 +0200215 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200216 lyd_free_all(tree);
217
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100218 /* multiple meatadata hint and unknown metadata xxx supposed to be skipped since it is from missing schema */
Radek Iša56ca9e42020-09-08 18:42:00 +0200219 data = "{\"@a:ll1\" : [{\"a:hint\" : 1, \"x:xxx\" : { \"value\" : \"/x:no/x:yes\" }, "
220 "\"a:hint\" : 10},null,{\"a:hint\" : 3}], \"a:ll1\" : [1,2,3]}";
221 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200222 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100223 tree = tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200224 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
225 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100226 ll = (struct lyd_node_term *)tree;
Radek Iša56ca9e42020-09-08 18:42:00 +0200227 CHECK_LYD_VALUE(ll->value, UINT8, "1", 1);
228 CHECK_LYD_META(ll->meta, 1, "hint", 1, 1, INT8, "1", 1);
229 CHECK_LYD_META(ll->meta->next, 1, "hint", 0, 1, INT8, "10", 10);
Radek Krejci1798aae2020-07-14 13:26:06 +0200230
231 assert_non_null(tree->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200232 CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
233 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100234 ll = (struct lyd_node_term *)tree->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200235 CHECK_LYD_VALUE(ll->value, UINT8, "2", 2);
Radek Krejci1798aae2020-07-14 13:26:06 +0200236 assert_null(ll->meta);
237
238 assert_non_null(tree->next->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200239 CHECK_LYSC_NODE(tree->next->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "ll1",
240 1, LYS_LEAFLIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100241 ll = (struct lyd_node_term *)tree->next->next;
Radek Iša56ca9e42020-09-08 18:42:00 +0200242 CHECK_LYD_VALUE(ll->value, UINT8, "3", 3);
243 CHECK_LYD_META(ll->meta, 1, "hint", 0, 1, INT8, "3", 3);
Radek Krejci1798aae2020-07-14 13:26:06 +0200244 assert_null(ll->meta->next);
245
Radek Iša56ca9e42020-09-08 18:42:00 +0200246 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
247 "{\"a:ll1\":[1,2,3],\"@a:ll1\":[{\"a:hint\":1,\"a:hint\":10},null,{\"a:hint\":3}]}");
Radek Krejci1798aae2020-07-14 13:26:06 +0200248 lyd_free_all(tree);
249
250 /* missing referenced metadata node */
Radek Iša56ca9e42020-09-08 18:42:00 +0200251 PARSER_CHECK_ERROR("{\"@a:ll1\":[{\"a:hint\":1}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200252 "Missing JSON data instance to be coupled with @a:ll1 metadata.", "Data location \"/@a:ll1\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200253
Radek Iša56ca9e42020-09-08 18:42:00 +0200254 PARSER_CHECK_ERROR("{\"a:ll1\":[1],\"@a:ll1\":[{\"a:hint\":1},{\"a:hint\":2}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200255 "Missing JSON data instance #2 of a:ll1 to be coupled with metadata.", "Schema location \"/a:ll1\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200256
Radek Iša56ca9e42020-09-08 18:42:00 +0200257 PARSER_CHECK_ERROR("{\"@a:ll1\":[{\"a:hint\":1},{\"a:hint\":2},{\"a:hint\":3}],\"a:ll1\" : [1, 2]}", 0, LYD_VALIDATE_PRESENT,
Michal Vasko959f8d82022-06-16 07:51:50 +0200258 tree, LY_EVALID, "Missing JSON data instance #3 to be coupled with @a:ll1 metadata.",
259 "Data location \"/@a:ll1\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200260}
261
262static void
263test_anydata(void **state)
264{
Radek Krejci1798aae2020-07-14 13:26:06 +0200265 const char *data;
Radek Krejci1798aae2020-07-14 13:26:06 +0200266 struct lyd_node *tree;
267
Radek Krejci1798aae2020-07-14 13:26:06 +0200268 data = "{\"a:any\":{\"x:element1\":{\"element2\":\"/a:some/a:path\",\"list\":[{},{\"key\":\"a\"}]}}}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200269 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200270 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100271 tree = tree->next;
Michal Vasko76096ec2022-02-24 16:06:16 +0100272 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_R | LYS_SET_CONFIG, 1, "any",
Radek Iša56ca9e42020-09-08 18:42:00 +0200273 1, LYS_ANYDATA, 0, 0, NULL, 0);
274 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200275 lyd_free_all(tree);
Michal Vaskofbc4a252022-02-03 13:15:58 +0100276
277 data = "{\"a:any\":{}}";
278 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
279 assert_non_null(tree);
280 tree = tree->next;
Michal Vasko76096ec2022-02-24 16:06:16 +0100281 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_R | LYS_SET_CONFIG, 1, "any",
Michal Vaskofbc4a252022-02-03 13:15:58 +0100282 1, LYS_ANYDATA, 0, 0, NULL, 0);
283 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
284 lyd_free_all(tree);
Michal Vasko76096ec2022-02-24 16:06:16 +0100285
Michal Vaskoe3ed7dc2022-11-30 11:39:44 +0100286 data = "{\"a:any\":{\"node\":20}}";
Michal Vasko76096ec2022-02-24 16:06:16 +0100287 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
288 assert_non_null(tree);
289 tree = tree->next;
290 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_R | LYS_SET_CONFIG, 1, "any",
291 1, LYS_ANYDATA, 0, 0, NULL, 0);
292 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
293 lyd_free_all(tree);
294}
295
296static void
297test_anyxml(void **state)
298{
299 const char *data;
300 struct lyd_node *tree;
301
302 data = "{\"a:axml\":\"some-value in string\"}";
303 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
304 assert_non_null(tree);
305 tree = tree->next;
306 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
307 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
308 lyd_free_all(tree);
309
310 data = "{\"a:axml\":\"\"}";
311 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
312 assert_non_null(tree);
313 tree = tree->next;
314 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
315 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
316 lyd_free_all(tree);
317
318 data = "{\"a:axml\":55}";
319 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
320 assert_non_null(tree);
321 tree = tree->next;
322 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
323 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
324 lyd_free_all(tree);
325
326 data = "{\"a:axml\":false}";
327 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
328 assert_non_null(tree);
329 tree = tree->next;
330 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
331 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
332 lyd_free_all(tree);
333
334 data = "{\"a:axml\":null}";
335 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
336 assert_non_null(tree);
337 tree = tree->next;
338 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
339 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
340 lyd_free_all(tree);
341
342 data = "{\"a:axml\":[null,true,false]}";
343 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
344 assert_non_null(tree);
345 tree = tree->next;
346 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
347 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
348 lyd_free_all(tree);
349
350 data = "{\"a:axml\":[null,true,{\"name\":[25,40, false]}]}";
351 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
352 assert_non_null(tree);
353 tree = tree->next;
354 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
355 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
356 lyd_free_all(tree);
357
358 /* same as anydata tests */
359 data = "{\"a:axml\":{\"x:element1\":{\"element2\":\"/a:some/a:path\",\"list\":[{},{\"key\":\"a\"}]}}}";
360 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
361 assert_non_null(tree);
362 tree = tree->next;
363 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
364 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
365 lyd_free_all(tree);
366
367 data = "{\"a:axml\":{}}";
368 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
369 assert_non_null(tree);
370 tree = tree->next;
371 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_STATUS_CURR | LYS_CONFIG_W, 1, "axml", 1, LYS_ANYXML, 0, 0, NULL, 0);
372 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
373 lyd_free_all(tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200374}
375
376static void
377test_list(void **state)
378{
Radek Iša56ca9e42020-09-08 18:42:00 +0200379 const char *data;
Radek Krejci1798aae2020-07-14 13:26:06 +0200380 struct lyd_node *tree, *iter;
381 struct lyd_node_inner *list;
382 struct lyd_node_term *leaf;
383
384 /* check hashes */
Radek Iša56ca9e42020-09-08 18:42:00 +0200385 data = "{\"a:l1\":[{\"a\":\"one\",\"b\":\"one\",\"c\":1}]}";
386 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
387 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "l1",
388 1, LYS_LIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100389 list = (struct lyd_node_inner *)tree;
Radek Krejci1798aae2020-07-14 13:26:06 +0200390 LY_LIST_FOR(list->child, iter) {
391 assert_int_not_equal(0, iter->hash);
392 }
Radek Iša56ca9e42020-09-08 18:42:00 +0200393 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200394 lyd_free_all(tree);
395
Michal Vasko4e26adc2022-03-30 11:01:16 +0200396 /* accept empty */
397 data = "{\"a:l1\":[]}";
398 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
399 assert_null(tree);
400
Radek Krejci1798aae2020-07-14 13:26:06 +0200401 /* missing keys */
Radek Iša56ca9e42020-09-08 18:42:00 +0200402 PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200403 "List instance is missing its key \"a\".",
Michal Vaskodbf3e652022-10-21 08:46:25 +0200404 "Data location \"/a:l1[b='b'][c='1']\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200405
Radek Iša56ca9e42020-09-08 18:42:00 +0200406 PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"a\" : \"a\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vaskodbf3e652022-10-21 08:46:25 +0200407 "List instance is missing its key \"b\".", "Data location \"/a:l1[a='a']\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200408
Radek Iša56ca9e42020-09-08 18:42:00 +0200409 PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"b\" : \"b\", \"a\" : \"a\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vaskodbf3e652022-10-21 08:46:25 +0200410 "List instance is missing its key \"c\".", "Data location \"/a:l1[a='a'][b='b']\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200411
412 /* key duplicate */
Radek Iša56ca9e42020-09-08 18:42:00 +0200413 PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\", \"a\" : \"a\", \"c\" : 1}]}", 0, LYD_VALIDATE_PRESENT,
Michal Vasko959f8d82022-06-16 07:51:50 +0200414 tree, LY_EVALID, "Duplicate instance of \"c\".",
Michal Vaskodbf3e652022-10-21 08:46:25 +0200415 "Data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200416
417 /* keys order, in contrast to XML, JSON accepts keys in any order even in strict mode */
Radek Iša56ca9e42020-09-08 18:42:00 +0200418 CHECK_PARSE_LYD("{ \"a:l1\": [ {\"d\" : \"d\", \"a\" : \"a\", \"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree);
419 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "l1",
420 1, LYS_LIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100421 list = (struct lyd_node_inner *)tree;
422 assert_non_null(leaf = (struct lyd_node_term *)list->child);
Radek Iša56ca9e42020-09-08 18:42:00 +0200423 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "a", 1, LYS_LEAF, 1, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100424 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200425 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "b", 1, LYS_LEAF, 1, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100426 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200427 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100428 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Michal Vaskodbf3e652022-10-21 08:46:25 +0200429 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 1, LYS_LEAF, 1, 0, NULL, 0);
Radek Iša56ca9e42020-09-08 18:42:00 +0200430 CHECK_LOG_CTX(NULL, NULL);
Radek Krejci5536d282020-08-04 23:27:44 +0200431
Radek Iša56ca9e42020-09-08 18:42:00 +0200432 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
433 "{\"a:l1\":[{\"a\":\"a\",\"b\":\"b\",\"c\":1,\"d\":\"d\"}]}");
Radek Krejci1798aae2020-07-14 13:26:06 +0200434 lyd_free_all(tree);
435
436 /* */
Radek Iša56ca9e42020-09-08 18:42:00 +0200437 CHECK_PARSE_LYD("{\"a:l1\":[{\"c\":1,\"b\":\"b\",\"a\":\"a\"}]}", LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree);
438 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM, 1, "l1",
439 1, LYS_LIST, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100440 list = (struct lyd_node_inner *)tree;
441 assert_non_null(leaf = (struct lyd_node_term *)list->child);
Radek Iša56ca9e42020-09-08 18:42:00 +0200442 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "a",
443 1, LYS_LEAF, 1, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100444 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200445 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "b",
446 1, LYS_LEAF, 1, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100447 assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
Radek Iša56ca9e42020-09-08 18:42:00 +0200448 CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c",
449 1, LYS_LEAF, 1, 0, NULL, 0);
450 CHECK_LOG_CTX(NULL, NULL);
Radek Krejci5536d282020-08-04 23:27:44 +0200451
Radek Iša56ca9e42020-09-08 18:42:00 +0200452 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
453 "{\"a:l1\":[{\"a\":\"a\",\"b\":\"b\",\"c\":1}]}");
Radek Krejci1798aae2020-07-14 13:26:06 +0200454 lyd_free_all(tree);
455
Radek Krejci5536d282020-08-04 23:27:44 +0200456 data = "{\"a:cp\":{\"@\":{\"a:hint\":1}}}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200457 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200458 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100459 tree = tree->next;
Michal Vaskoe16c7b72021-02-26 10:39:06 +0100460 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_PRESENCE, 1, "cp",
Radek Iša56ca9e42020-09-08 18:42:00 +0200461 1, LYS_CONTAINER, 0, 0, NULL, 0);
462 CHECK_LYD_META(tree->meta, 1, "hint", 0, 1, INT8, "1", 1);
Radek Krejci1798aae2020-07-14 13:26:06 +0200463 assert_null(tree->meta->next);
Radek Krejci5536d282020-08-04 23:27:44 +0200464
Radek Iša56ca9e42020-09-08 18:42:00 +0200465 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200466 lyd_free_all(tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200467}
468
469static void
470test_container(void **state)
471{
Radek Iša56ca9e42020-09-08 18:42:00 +0200472 const char *data;
Radek Krejci1798aae2020-07-14 13:26:06 +0200473 struct lyd_node *tree;
474 struct lyd_node_inner *cont;
475
Radek Iša56ca9e42020-09-08 18:42:00 +0200476 CHECK_PARSE_LYD("{\"a:c\":{}}", 0, LYD_VALIDATE_PRESENT, tree);
477 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c",
478 1, LYS_CONTAINER, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100479 cont = (struct lyd_node_inner *)tree;
Radek Krejci1798aae2020-07-14 13:26:06 +0200480 assert_true(cont->flags & LYD_DEFAULT);
Radek Krejci5536d282020-08-04 23:27:44 +0200481
Radek Iša56ca9e42020-09-08 18:42:00 +0200482 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, "{}");
Radek Krejci1798aae2020-07-14 13:26:06 +0200483 lyd_free_all(tree);
484
Radek Krejci5536d282020-08-04 23:27:44 +0200485 data = "{\"a:cp\":{}}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200486 CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200487 assert_non_null(tree);
Michal Vasko26123192020-11-09 21:02:34 +0100488 tree = tree->next;
Michal Vaskoe16c7b72021-02-26 10:39:06 +0100489 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_PRESENCE, 1, "cp",
Radek Iša56ca9e42020-09-08 18:42:00 +0200490 1, LYS_CONTAINER, 0, 0, NULL, 0);
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100491 cont = (struct lyd_node_inner *)tree;
Radek Krejci1798aae2020-07-14 13:26:06 +0200492 assert_false(cont->flags & LYD_DEFAULT);
Radek Krejci5536d282020-08-04 23:27:44 +0200493
Radek Iša56ca9e42020-09-08 18:42:00 +0200494 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200495 lyd_free_all(tree);
Michal Vaskoa4af6252022-05-20 10:38:54 +0200496
497 /* skip container */
498 CHECK_PARSE_LYD("{\"a:unknown\":{\"a\":\"val\",\"b\":5}}", 0, LYD_VALIDATE_PRESENT, tree);
499 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, "{}");
500 lyd_free_all(tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200501}
502
503static void
504test_opaq(void **state)
505{
Radek Krejci1798aae2020-07-14 13:26:06 +0200506 const char *data;
Radek Krejci1798aae2020-07-14 13:26:06 +0200507 struct lyd_node *tree;
508
Radek Krejci1798aae2020-07-14 13:26:06 +0200509 /* invalid value, no flags */
510 data = "{\"a:foo3\":[null]}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200511 PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200512 "Invalid non-number-encoded uint32 value \"\".", "Schema location \"/a:foo3\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200513
514 /* opaq flag */
Michal Vasko1a85d332021-08-27 10:35:28 +0200515 CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
Radek Krejci8df109d2021-04-23 12:19:08 +0200516 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)tree, 0, 0, LY_VALUE_JSON, "foo3", 0, 0, NULL, 0, "");
Radek Iša56ca9e42020-09-08 18:42:00 +0200517 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200518 lyd_free_all(tree);
519
520 /* missing key, no flags */
521 data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"d\":\"val_d\"}]}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200522 PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200523 "List instance is missing its key \"c\".",
Michal Vaskodbf3e652022-10-21 08:46:25 +0200524 "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200525
526 /* opaq flag */
Michal Vasko1a85d332021-08-27 10:35:28 +0200527 CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
Radek Krejci8df109d2021-04-23 12:19:08 +0200528 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)tree, 0, 0x1, LY_VALUE_JSON, "l1", 0, 0, NULL, 0, "");
Radek Iša56ca9e42020-09-08 18:42:00 +0200529 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200530 lyd_free_all(tree);
531
532 /* invalid key, no flags */
533 data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"c\":\"val_c\"}]}";
Radek Iša56ca9e42020-09-08 18:42:00 +0200534 PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vasko959f8d82022-06-16 07:51:50 +0200535 "Invalid non-number-encoded int16 value \"val_c\".",
Michal Vaskoa4dfb3c2022-10-25 14:59:31 +0200536 "Data location \"/a:l1[a='val_a'][b='val_b']/c\", line number 1.");
Radek Krejci1798aae2020-07-14 13:26:06 +0200537
538 /* opaq flag */
Michal Vasko1a85d332021-08-27 10:35:28 +0200539 CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
Radek Krejci8df109d2021-04-23 12:19:08 +0200540 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)tree, 0, 0x1, LY_VALUE_JSON, "l1", 0, 0, NULL, 0, "");
Radek Iša56ca9e42020-09-08 18:42:00 +0200541 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200542 lyd_free_all(tree);
543
544 data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"c\":{\"val\":\"val_c\"}}]}";
Michal Vasko1a85d332021-08-27 10:35:28 +0200545 CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
Radek Krejci8df109d2021-04-23 12:19:08 +0200546 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)tree, 0, 0x1, LY_VALUE_JSON, "l1", 0, 0, NULL, 0, "");
Radek Iša56ca9e42020-09-08 18:42:00 +0200547 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200548 lyd_free_all(tree);
549
550 data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\"}]}";
Michal Vasko1a85d332021-08-27 10:35:28 +0200551 CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
Radek Krejci8df109d2021-04-23 12:19:08 +0200552 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)tree, 0, 0x1, LY_VALUE_JSON, "l1", 0, 0, NULL, 0, "");
Radek Iša56ca9e42020-09-08 18:42:00 +0200553 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200554 lyd_free_all(tree);
aPiecekb7b29e62021-05-11 10:02:43 +0200555
Michal Vasko6a6e3082022-05-10 10:32:38 +0200556 /* invalid metadata */
aPiecekc5f36a72021-05-18 14:12:31 +0200557 data = "{\"@a:foo\":\"str\",\"@a:foo3\":1,\"a:foo3\":2}";
Michal Vasko6a6e3082022-05-10 10:32:38 +0200558 PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
Michal Vaskof8ebf132022-11-21 14:06:48 +0100559 "Unknown module of node \"@a:foo\".", "Data location \"/@a:foo\".");
Michal Vasko62af3692023-02-09 14:00:09 +0100560 CHECK_LOG_CTX("Missing JSON data instance to be coupled with @a:foo metadata.", "Data location \"/@a:foo\", line number 1.");
aPiecekc5f36a72021-05-18 14:12:31 +0200561
aPiecekb7b29e62021-05-11 10:02:43 +0200562 /* empty name */
563 PARSER_CHECK_ERROR("{\"@a:foo\":{\"\":0}}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
564 "A JSON object member name cannot be a zero-length string.", "Line number 1.");
Michal Vasko1a85d332021-08-27 10:35:28 +0200565
566 /* opaque data tree format print */
567 data =
568 "{\n"
569 " \"ietf-netconf-nmda:get-data\": {\n"
570 " \"data\": {\n"
571 " \"ietf-keystore:keystore\": {\n"
572 " \"asymmetric-keys\": {\n"
573 " \"asymmetric-key\": [\n"
574 " {\n"
575 " \"name\": \"genkey\",\n"
576 " \"algorithm\": \"rsa2048\"\n"
577 " }\n"
578 " ]\n"
579 " }\n"
580 " },\n"
581 " \"ietf-netconf-server:netconf-server\": {\n"
582 " \"listen\": {\n"
583 " \"idle-timeout\": 3600,\n"
584 " \"endpoint\": [\n"
585 " {\n"
586 " \"name\": \"default-ssh\",\n"
587 " \"ssh\": {\n"
588 " \"tcp-server-parameters\": {\n"
589 " \"local-address\": \"0.0.0.0\",\n"
590 " \"local-port\": 830\n"
591 " },\n"
592 " \"ssh-server-parameters\": {\n"
593 " \"server-identity\": {\n"
594 " \"host-key\": [\n"
595 " {\n"
596 " \"name\": \"default-key\",\n"
597 " \"public-key\": {\n"
598 " \"keystore-reference\": \"genkey\"\n"
599 " }\n"
600 " }\n"
601 " ]\n"
602 " },\n"
603 " \"client-authentication\": {\n"
604 " \"supported-authentication-methods\": {\n"
605 " \"publickey\": [null],\n"
606 " \"passsword\": [null],\n"
607 " \"other\": [\n"
608 " \"interactive\",\n"
609 " \"gssapi\"\n"
610 " ]\n"
611 " }\n"
612 " }\n"
613 " }\n"
614 " }\n"
615 " }\n"
616 " ]\n"
617 " }\n"
618 " }\n"
619 " }\n"
620 " }\n"
621 "}\n";
622 CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
623 CHECK_LYD_STRING(tree, LYD_PRINT_WITHSIBLINGS, data);
624 lyd_free_all(tree);
Radek Krejci1798aae2020-07-14 13:26:06 +0200625}
626
627static void
628test_rpc(void **state)
629{
Radek Krejci1798aae2020-07-14 13:26:06 +0200630 const char *data;
631 struct ly_in *in;
Radek Krejci1798aae2020-07-14 13:26:06 +0200632 struct lyd_node *tree, *op;
633 const struct lyd_node *node;
Michal Vaskobbdadda2022-01-06 11:40:10 +0100634 const char *dsc = "Edit data in an NMDA datastore.\n"
635 "\n"
636 "If an error condition occurs such that an error severity\n"
637 "<rpc-error> element is generated, the server will stop\n"
638 "processing the <edit-data> operation and restore the\n"
639 "specified configuration to its complete state at\n"
640 "the start of this <edit-data> operation.";
Radek Krejci1798aae2020-07-14 13:26:06 +0200641
Michal Vaskobbdadda2022-01-06 11:40:10 +0100642 assert_non_null((ly_ctx_load_module(UTEST_LYCTX, "ietf-netconf-nmda", "2019-01-07", NULL)));
Radek Krejci1798aae2020-07-14 13:26:06 +0200643
Michal Vaskobbdadda2022-01-06 11:40:10 +0100644 data = "{\"ietf-netconf-nmda:edit-data\":{"
645 "\"datastore\":\"ietf-datastores:running\","
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100646 "\"config\":{\"a:cp\":{\"z\":[null],\"@z\":{\"ietf-netconf:operation\":\"replace\"}},"
647 "\"a:l1\":[{\"@\":{\"ietf-netconf:operation\":\"replace\"},\"a\":\"val_a\",\"b\":\"val_b\",\"c\":\"val_c\"}]}"
Michal Vasko2552ea32020-12-08 15:32:34 +0100648 "}}";
Radek Krejci1798aae2020-07-14 13:26:06 +0200649 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
Michal Vasko1e4c68e2021-02-18 15:03:01 +0100650 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_JSON, LYD_TYPE_RPC_YANG, &tree, &op));
Radek Krejci1798aae2020-07-14 13:26:06 +0200651 ly_in_free(in, 0);
652
653 assert_non_null(op);
Radek Krejci1798aae2020-07-14 13:26:06 +0200654
Radek Krejci2a9fc652021-01-22 17:44:34 +0100655 CHECK_LYSC_ACTION((struct lysc_node_action *)op->schema, dsc, 0, LYS_STATUS_CURR,
Michal Vaskobbdadda2022-01-06 11:40:10 +0100656 1, 0, 0, 1, "edit-data", LYS_RPC,
657 0, 0, 0, 0, 0, NULL, 0);
Radek Iša56ca9e42020-09-08 18:42:00 +0200658
Michal Vasko2552ea32020-12-08 15:32:34 +0100659 node = tree;
Radek Krejci2a9fc652021-01-22 17:44:34 +0100660 CHECK_LYSC_ACTION((struct lysc_node_action *)node->schema, dsc, 0, LYS_STATUS_CURR,
Michal Vaskobbdadda2022-01-06 11:40:10 +0100661 1, 0, 0, 1, "edit-data", LYS_RPC,
662 0, 0, 0, 0, 0, NULL, 0);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200663 node = lyd_child(node)->next;
Michal Vaskobbdadda2022-01-06 11:40:10 +0100664 CHECK_LYSC_NODE(node->schema, "Inline config content.", 0, LYS_STATUS_CURR | LYS_IS_INPUT, 1, "config",
665 0, LYS_ANYDATA, 1, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200666
667 node = ((struct lyd_node_any *)node)->value.tree;
Michal Vaskoe16c7b72021-02-26 10:39:06 +0100668 CHECK_LYSC_NODE(node->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_PRESENCE, 1, "cp",
Radek Iša56ca9e42020-09-08 18:42:00 +0200669 1, LYS_CONTAINER, 0, 0, NULL, 0);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200670 node = lyd_child(node);
Radek Krejci1798aae2020-07-14 13:26:06 +0200671 /* z has no value */
Radek Krejci8df109d2021-04-23 12:19:08 +0200672 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)node, 0x1, 0, LY_VALUE_JSON, "z", 0, 0, NULL, 0, "");
Radek Krejci1798aae2020-07-14 13:26:06 +0200673 node = node->parent->next;
674 /* l1 key c has invalid value so it is at the end */
Radek Krejci8df109d2021-04-23 12:19:08 +0200675 CHECK_LYD_NODE_OPAQ((struct lyd_node_opaq *)node, 0x1, 0x1, LY_VALUE_JSON, "l1", 0, 0, NULL, 0, "");
Radek Krejci1798aae2020-07-14 13:26:06 +0200676
Radek Iša56ca9e42020-09-08 18:42:00 +0200677 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200678 lyd_free_all(tree);
679
680 /* wrong namespace, element name, whatever... */
681 /* TODO */
Radek Krejci1798aae2020-07-14 13:26:06 +0200682}
683
684static void
685test_action(void **state)
686{
Radek Krejci1798aae2020-07-14 13:26:06 +0200687 const char *data;
688 struct ly_in *in;
Radek Krejci1798aae2020-07-14 13:26:06 +0200689 struct lyd_node *tree, *op;
Radek Krejci1798aae2020-07-14 13:26:06 +0200690
Michal Vasko2552ea32020-12-08 15:32:34 +0100691 data = "{\"a:c\":{\"act\":{\"al\":\"value\"}}}";
Radek Krejci1798aae2020-07-14 13:26:06 +0200692 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
Michal Vasko1e4c68e2021-02-18 15:03:01 +0100693 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_JSON, LYD_TYPE_RPC_YANG, &tree, &op));
Radek Krejci1798aae2020-07-14 13:26:06 +0200694 ly_in_free(in, 0);
695
696 assert_non_null(op);
Radek Krejci2a9fc652021-01-22 17:44:34 +0100697 CHECK_LYSC_ACTION((struct lysc_node_action *)op->schema, NULL, 0, LYS_STATUS_CURR,
Radek Iša56ca9e42020-09-08 18:42:00 +0200698 1, 0, 0, 1, "act", LYS_ACTION,
699 1, 0, 0, 1, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200700
Radek Iša56ca9e42020-09-08 18:42:00 +0200701 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200702 lyd_free_all(tree);
703
704 /* wrong namespace, element name, whatever... */
705 /* TODO */
Radek Krejci1798aae2020-07-14 13:26:06 +0200706}
707
708static void
709test_notification(void **state)
710{
Radek Krejci1798aae2020-07-14 13:26:06 +0200711 const char *data;
712 struct ly_in *in;
Radek Krejci1798aae2020-07-14 13:26:06 +0200713 struct lyd_node *tree, *ntf;
Radek Krejci1798aae2020-07-14 13:26:06 +0200714
Michal Vasko2552ea32020-12-08 15:32:34 +0100715 data = "{\"a:c\":{\"n1\":{\"nl\":\"value\"}}}";
Radek Krejci1798aae2020-07-14 13:26:06 +0200716 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
Michal Vasko1e4c68e2021-02-18 15:03:01 +0100717 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_JSON, LYD_TYPE_NOTIF_YANG, &tree, &ntf));
Radek Krejci1798aae2020-07-14 13:26:06 +0200718 ly_in_free(in, 0);
719
720 assert_non_null(ntf);
Radek Krejci2a9fc652021-01-22 17:44:34 +0100721 CHECK_LYSC_NOTIF((struct lysc_node_notif *)ntf->schema, 1, NULL, 0, 0x4, 1, 0, "n1", 1, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200722
Michal Vasko2552ea32020-12-08 15:32:34 +0100723 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 1, LYS_CONTAINER, 0, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200724
Radek Iša56ca9e42020-09-08 18:42:00 +0200725 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200726 lyd_free_all(tree);
727
Radek Krejci1798aae2020-07-14 13:26:06 +0200728 data = "{\"a:n2\":{}}";
729 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
Michal Vasko1e4c68e2021-02-18 15:03:01 +0100730 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_JSON, LYD_TYPE_NOTIF_YANG, &tree, &ntf));
Radek Krejci1798aae2020-07-14 13:26:06 +0200731 ly_in_free(in, 0);
732
733 assert_non_null(ntf);
Radek Krejci2a9fc652021-01-22 17:44:34 +0100734 CHECK_LYSC_NOTIF((struct lysc_node_notif *)ntf->schema, 0, NULL, 0, 0x4, 1, 0, "n2", 0, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200735
736 assert_non_null(tree);
737 assert_ptr_equal(ntf, tree);
738
Radek Iša56ca9e42020-09-08 18:42:00 +0200739 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
Radek Krejci1798aae2020-07-14 13:26:06 +0200740 lyd_free_all(tree);
741
742 /* wrong namespace, element name, whatever... */
743 /* TODO */
Radek Krejci1798aae2020-07-14 13:26:06 +0200744}
745
746static void
747test_reply(void **state)
748{
Radek Krejci1798aae2020-07-14 13:26:06 +0200749 const char *data;
750 struct ly_in *in;
Michal Vasko2552ea32020-12-08 15:32:34 +0100751 struct lyd_node *tree, *op;
Radek Krejci1798aae2020-07-14 13:26:06 +0200752 const struct lyd_node *node;
753
Michal Vasko2552ea32020-12-08 15:32:34 +0100754 data = "{\"a:c\":{\"act\":{\"al\":25}}}";
Radek Krejci1798aae2020-07-14 13:26:06 +0200755 assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
Michal Vasko1e4c68e2021-02-18 15:03:01 +0100756 assert_int_equal(LY_SUCCESS, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_JSON, LYD_TYPE_REPLY_YANG, &tree, &op));
Radek Krejci1798aae2020-07-14 13:26:06 +0200757 ly_in_free(in, 0);
758
Radek Krejci1798aae2020-07-14 13:26:06 +0200759 assert_non_null(op);
Radek Krejci2a9fc652021-01-22 17:44:34 +0100760 CHECK_LYSC_ACTION((struct lysc_node_action *)op->schema, NULL, 0, LYS_STATUS_CURR,
Radek Iša56ca9e42020-09-08 18:42:00 +0200761 1, 0, 0, 1, "act", LYS_ACTION,
762 1, 0, 0, 1, 0, NULL, 0);
Radek Krejcia1c1e542020-09-29 16:06:52 +0200763 node = lyd_child(op);
Michal Vaskod1e53b92021-01-28 13:11:06 +0100764 CHECK_LYSC_NODE(node->schema, NULL, 0, LYS_STATUS_CURR | LYS_IS_OUTPUT, 1, "al", 0, LYS_LEAF, 1, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200765
Michal Vasko2552ea32020-12-08 15:32:34 +0100766 CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 1, LYS_CONTAINER, 0, 0, NULL, 0);
Radek Krejci1798aae2020-07-14 13:26:06 +0200767
768 /* TODO print only rpc-reply node and then output subtree */
Radek Iša56ca9e42020-09-08 18:42:00 +0200769 CHECK_LYD_STRING(lyd_child(op), LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, "{\"a:al\":25}");
Michal Vasko2552ea32020-12-08 15:32:34 +0100770 CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, "{\"a:c\":{\"act\":{\"al\":25}}}");
Radek Krejci1798aae2020-07-14 13:26:06 +0200771 lyd_free_all(tree);
772
773 /* wrong namespace, element name, whatever... */
774 /* TODO */
Radek Krejci1798aae2020-07-14 13:26:06 +0200775}
776
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100777int
778main(void)
Radek Krejci1798aae2020-07-14 13:26:06 +0200779{
780 const struct CMUnitTest tests[] = {
Radek Iša56ca9e42020-09-08 18:42:00 +0200781 UTEST(test_leaf, setup),
782 UTEST(test_leaflist, setup),
783 UTEST(test_anydata, setup),
Michal Vasko76096ec2022-02-24 16:06:16 +0100784 UTEST(test_anyxml, setup),
Radek Iša56ca9e42020-09-08 18:42:00 +0200785 UTEST(test_list, setup),
786 UTEST(test_container, setup),
787 UTEST(test_opaq, setup),
788 UTEST(test_rpc, setup),
789 UTEST(test_action, setup),
790 UTEST(test_notification, setup),
791 UTEST(test_reply, setup),
Radek Krejci1798aae2020-07-14 13:26:06 +0200792 };
793
794 return cmocka_run_group_tests(tests, NULL, NULL);
795}