Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file test_diff.c |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 5 | * @brief tests for lyd_diff() |
| 6 | * |
| 7 | * Copyright (c) 2020 CESNET, z.s.p.o. |
| 8 | * |
| 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
| 14 | */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 15 | #define _UTEST_MAIN_ |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 16 | #include "utests.h" |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 17 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 18 | #include "libyang.h" |
| 19 | |
Michal Vasko | 58d89e9 | 2023-05-23 09:56:19 +0200 | [diff] [blame^] | 20 | #define CHECK_PARSE_LYD(INPUT, OUTPUT) \ |
| 21 | CHECK_PARSE_LYD_PARAM(INPUT, LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, OUTPUT) |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 22 | |
Michal Vasko | 58d89e9 | 2023-05-23 09:56:19 +0200 | [diff] [blame^] | 23 | #define CHECK_LYD_STRING(INPUT, TEXT) \ |
| 24 | CHECK_LYD_STRING_PARAM(INPUT, TEXT, LYD_XML, LYD_PRINT_WITHSIBLINGS) |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 25 | |
Michal Vasko | 58d89e9 | 2023-05-23 09:56:19 +0200 | [diff] [blame^] | 26 | #define CHECK_PARSE_LYD_DIFF(INPUT_1, INPUT_2, OUT_DIFF) \ |
| 27 | assert_int_equal(LY_SUCCESS, lyd_diff_siblings(INPUT_1, INPUT_2, 0, &OUT_DIFF));\ |
| 28 | assert_non_null(OUT_DIFF) |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 29 | |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 30 | #define TEST_DIFF_3(XML1, XML2, XML3, DIFF1, DIFF2, MERGE) \ |
| 31 | { \ |
| 32 | struct lyd_node *data1;\ |
| 33 | struct lyd_node *data2;\ |
| 34 | struct lyd_node *data3;\ |
Michal Vasko | 2bf4af4 | 2023-01-04 12:08:38 +0100 | [diff] [blame] | 35 | /*create*/\ |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 36 | CHECK_PARSE_LYD(XML1, data1);\ |
| 37 | CHECK_PARSE_LYD(XML2, data2);\ |
| 38 | CHECK_PARSE_LYD(XML3, data3);\ |
Michal Vasko | 2bf4af4 | 2023-01-04 12:08:38 +0100 | [diff] [blame] | 39 | /* diff1 */ \ |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 40 | struct lyd_node *diff1;\ |
| 41 | CHECK_PARSE_LYD_DIFF(data1, data2, diff1); \ |
| 42 | CHECK_LYD_STRING(diff1, DIFF1); \ |
| 43 | assert_int_equal(lyd_diff_apply_all(&data1, diff1), LY_SUCCESS); \ |
| 44 | CHECK_LYD(data1, data2); \ |
Michal Vasko | 2bf4af4 | 2023-01-04 12:08:38 +0100 | [diff] [blame] | 45 | /* diff2 */ \ |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 46 | struct lyd_node *diff2;\ |
| 47 | CHECK_PARSE_LYD_DIFF(data2, data3, diff2); \ |
| 48 | CHECK_LYD_STRING(diff2, DIFF2); \ |
| 49 | assert_int_equal(lyd_diff_apply_all(&data2, diff2), LY_SUCCESS);\ |
| 50 | CHECK_LYD(data2, data3);\ |
Michal Vasko | 2bf4af4 | 2023-01-04 12:08:38 +0100 | [diff] [blame] | 51 | /* merge */ \ |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 52 | assert_int_equal(lyd_diff_merge_all(&diff1, diff2, 0), LY_SUCCESS);\ |
| 53 | CHECK_LYD_STRING(diff1, MERGE); \ |
Michal Vasko | 2bf4af4 | 2023-01-04 12:08:38 +0100 | [diff] [blame] | 54 | /* cleanup */ \ |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 55 | lyd_free_all(data1);\ |
| 56 | lyd_free_all(data2);\ |
| 57 | lyd_free_all(data3);\ |
| 58 | lyd_free_all(diff1);\ |
| 59 | lyd_free_all(diff2);\ |
| 60 | } |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 61 | |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 62 | const char *schema1 = |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 63 | "module defaults {\n" |
| 64 | " yang-version 1.1;\n" |
| 65 | " namespace \"urn:libyang:tests:defaults\";\n" |
| 66 | " prefix df;\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 67 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 68 | " feature unhide;\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 69 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 70 | " typedef defint32 {\n" |
| 71 | " type int32;\n" |
| 72 | " default \"42\";\n" |
| 73 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 74 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 75 | " leaf hiddenleaf {\n" |
| 76 | " if-feature \"unhide\";\n" |
| 77 | " type int32;\n" |
| 78 | " default \"42\";\n" |
| 79 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 80 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 81 | " container df {\n" |
| 82 | " leaf foo {\n" |
| 83 | " type defint32;\n" |
| 84 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 85 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 86 | " leaf hiddenleaf {\n" |
| 87 | " if-feature \"unhide\";\n" |
| 88 | " type int32;\n" |
| 89 | " default \"42\";\n" |
| 90 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 91 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 92 | " container bar {\n" |
| 93 | " presence \"\";\n" |
| 94 | " leaf hi {\n" |
| 95 | " type int32;\n" |
| 96 | " default \"42\";\n" |
| 97 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 98 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 99 | " leaf ho {\n" |
| 100 | " type int32;\n" |
| 101 | " mandatory true;\n" |
| 102 | " }\n" |
| 103 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 104 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 105 | " leaf-list llist {\n" |
| 106 | " type defint32;\n" |
| 107 | " ordered-by user;\n" |
| 108 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 109 | "" |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 110 | " list ul {\n" |
| 111 | " key \"l1\";\n" |
| 112 | " ordered-by user;\n" |
| 113 | " leaf l1 {\n" |
| 114 | " type string;\n" |
| 115 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 116 | "" |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 117 | " leaf l2 {\n" |
| 118 | " type int32;\n" |
| 119 | " }\n" |
| 120 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 121 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 122 | " leaf-list dllist {\n" |
| 123 | " type uint8;\n" |
| 124 | " default \"1\";\n" |
| 125 | " default \"2\";\n" |
| 126 | " default \"3\";\n" |
| 127 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 128 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 129 | " list list {\n" |
| 130 | " key \"name\";\n" |
| 131 | " leaf name {\n" |
| 132 | " type string;\n" |
| 133 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 134 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 135 | " leaf value {\n" |
| 136 | " type int32;\n" |
| 137 | " default \"42\";\n" |
| 138 | " }\n" |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 139 | " list list2 {\n" |
| 140 | " key \"name2\";\n" |
| 141 | " leaf name2 {\n" |
| 142 | " type string;\n" |
| 143 | " }\n" |
| 144 | " leaf value2 {\n" |
| 145 | " type int32;\n" |
| 146 | " }\n" |
| 147 | " }\n" |
| 148 | " }\n"; |
| 149 | const char *schema2 = |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 150 | " choice select {\n" |
| 151 | " default \"a\";\n" |
| 152 | " case a {\n" |
| 153 | " choice a {\n" |
| 154 | " leaf a1 {\n" |
| 155 | " type int32;\n" |
| 156 | " default \"42\";\n" |
| 157 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 158 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 159 | " leaf a2 {\n" |
| 160 | " type int32;\n" |
| 161 | " default \"24\";\n" |
| 162 | " }\n" |
| 163 | " }\n" |
| 164 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 165 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 166 | " leaf b {\n" |
| 167 | " type string;\n" |
| 168 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 169 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 170 | " container c {\n" |
| 171 | " presence \"\";\n" |
| 172 | " leaf x {\n" |
| 173 | " type int32;\n" |
| 174 | " default \"42\";\n" |
| 175 | " }\n" |
| 176 | " }\n" |
| 177 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 178 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 179 | " choice select2 {\n" |
| 180 | " default \"s2b\";\n" |
| 181 | " leaf s2a {\n" |
| 182 | " type int32;\n" |
| 183 | " default \"42\";\n" |
| 184 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 185 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 186 | " case s2b {\n" |
| 187 | " choice s2b {\n" |
| 188 | " default \"b1\";\n" |
| 189 | " case b1 {\n" |
| 190 | " leaf b1_1 {\n" |
| 191 | " type int32;\n" |
| 192 | " default \"42\";\n" |
| 193 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 194 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 195 | " leaf b1_2 {\n" |
| 196 | " type string;\n" |
| 197 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 198 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 199 | " leaf b1_status {\n" |
| 200 | " type int32;\n" |
| 201 | " default \"42\";\n" |
| 202 | " config false;\n" |
| 203 | " }\n" |
| 204 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 205 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 206 | " leaf b2 {\n" |
| 207 | " type int32;\n" |
| 208 | " default \"42\";\n" |
| 209 | " }\n" |
| 210 | " }\n" |
| 211 | " }\n" |
| 212 | " }\n" |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 213 | " list kl {\n" |
| 214 | " config \"false\";\n" |
| 215 | " leaf l1 {\n" |
| 216 | " type string;\n" |
| 217 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 218 | "" |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 219 | " leaf l2 {\n" |
| 220 | " type int32;\n" |
| 221 | " }\n" |
| 222 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 223 | "" |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 224 | " leaf-list kll {\n" |
| 225 | " config \"false\";\n" |
| 226 | " type string;\n" |
| 227 | " }\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 228 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 229 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 230 | " container hidden {\n" |
| 231 | " leaf foo {\n" |
| 232 | " type int32;\n" |
| 233 | " default \"42\";\n" |
| 234 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 235 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 236 | " leaf baz {\n" |
| 237 | " type int32;\n" |
| 238 | " default \"42\";\n" |
| 239 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 240 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 241 | " leaf papa {\n" |
| 242 | " type int32;\n" |
| 243 | " default \"42\";\n" |
| 244 | " config false;\n" |
| 245 | " }\n" |
| 246 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 247 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 248 | " rpc rpc1 {\n" |
| 249 | " input {\n" |
| 250 | " leaf inleaf1 {\n" |
| 251 | " type string;\n" |
| 252 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 253 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 254 | " leaf inleaf2 {\n" |
| 255 | " type string;\n" |
| 256 | " default \"def1\";\n" |
| 257 | " }\n" |
| 258 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 259 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 260 | " output {\n" |
| 261 | " leaf outleaf1 {\n" |
| 262 | " type string;\n" |
| 263 | " default \"def2\";\n" |
| 264 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 265 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 266 | " leaf outleaf2 {\n" |
| 267 | " type string;\n" |
| 268 | " }\n" |
| 269 | " }\n" |
| 270 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 271 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 272 | " notification notif {\n" |
| 273 | " leaf ntfleaf1 {\n" |
| 274 | " type string;\n" |
| 275 | " default \"def3\";\n" |
| 276 | " }\n" |
Michal Vasko | 22e0f3a | 2021-09-22 12:19:23 +0200 | [diff] [blame] | 277 | "" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 278 | " leaf ntfleaf2 {\n" |
| 279 | " type string;\n" |
| 280 | " }\n" |
| 281 | " }\n" |
| 282 | "}\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 283 | |
| 284 | static int |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 285 | setup(void **state) |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 286 | { |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 287 | char *schema; |
| 288 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 289 | UTEST_SETUP; |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 290 | |
| 291 | /* create one schema, longer than 4095 chars */ |
| 292 | schema = malloc(strlen(schema1) + strlen(schema2) + 1); |
| 293 | strcpy(schema, schema1); |
| 294 | strcat(schema, schema2); |
| 295 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 296 | UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL); |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 297 | free(schema); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 298 | |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | static void |
| 303 | test_invalid(void **state) |
| 304 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 305 | (void) state; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 306 | const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\"><foo>42</foo></df>"; |
| 307 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 308 | struct lyd_node *model_1; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 309 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 310 | CHECK_PARSE_LYD(xml, model_1); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 311 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 312 | struct lyd_node *diff = NULL; |
| 313 | |
| 314 | assert_int_equal(lyd_diff_siblings(model_1, lyd_child(model_1), 0, &diff), LY_EINVAL); |
Michal Vasko | 62af369 | 2023-02-09 14:00:09 +0100 | [diff] [blame] | 315 | CHECK_LOG_CTX("Invalid arguments - cannot create diff for unrelated data (lyd_diff()).", NULL); |
| 316 | |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 317 | assert_int_equal(lyd_diff_siblings(NULL, NULL, 0, NULL), LY_EINVAL); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 318 | |
| 319 | lyd_free_all(model_1); |
| 320 | lyd_free_all(diff); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | static void |
| 324 | test_same(void **state) |
| 325 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 326 | (void) state; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 327 | const char *xml = |
| 328 | "<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">\n" |
| 329 | " <enable-nacm>true</enable-nacm>\n" |
| 330 | " <read-default>permit</read-default>\n" |
| 331 | " <write-default>deny</write-default>\n" |
| 332 | " <exec-default>permit</exec-default>\n" |
| 333 | " <enable-external-groups>true</enable-external-groups>\n" |
| 334 | "</nacm><df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 335 | " <foo>42</foo><b1_1>42</b1_1>\n" |
| 336 | "</df><hidden xmlns=\"urn:libyang:tests:defaults\">\n" |
| 337 | " <foo>42</foo><baz>42</baz></hidden>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 338 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 339 | struct lyd_node *model_1; |
| 340 | struct lyd_node *model_2; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 341 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 342 | assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG)); |
| 343 | assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-netconf-acm", "2018-02-14", NULL)); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 344 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 345 | CHECK_PARSE_LYD(xml, model_1); |
| 346 | CHECK_PARSE_LYD(xml, model_2); |
| 347 | |
| 348 | struct lyd_node *diff = NULL; |
| 349 | |
| 350 | assert_int_equal(lyd_diff_siblings(model_1, model_2, 0, &diff), LY_SUCCESS); |
| 351 | assert_null(diff); |
| 352 | assert_int_equal(lyd_diff_apply_all(&model_1, diff), LY_SUCCESS); |
| 353 | CHECK_LYD(model_1, model_2); |
| 354 | |
| 355 | lyd_free_all(model_1); |
| 356 | lyd_free_all(model_2); |
| 357 | lyd_free_all(diff); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | static void |
| 361 | test_empty1(void **state) |
| 362 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 363 | (void) state; |
| 364 | const char *xml_in = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 365 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 366 | " <foo>42</foo>\n" |
| 367 | " <b1_1>42</b1_1>\n" |
| 368 | "</df>\n" |
| 369 | "<hidden xmlns=\"urn:libyang:tests:defaults\">\n" |
| 370 | " <foo>42</foo>\n" |
| 371 | " <baz>42</baz>\n" |
| 372 | "</hidden>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 373 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 374 | struct lyd_node *model_1 = NULL; |
| 375 | struct lyd_node *model_2; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 376 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 377 | CHECK_PARSE_LYD(xml_in, model_2); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 378 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 379 | struct lyd_node *diff; |
| 380 | |
| 381 | CHECK_PARSE_LYD_DIFF(model_1, model_2, diff); |
| 382 | CHECK_LYD_STRING(diff, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 383 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n" |
| 384 | " <foo>42</foo>\n" |
| 385 | " <b1_1>42</b1_1>\n" |
| 386 | "</df>\n" |
| 387 | "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n" |
| 388 | " <foo>42</foo>\n" |
| 389 | " <baz>42</baz>\n" |
| 390 | "</hidden>\n"); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 391 | assert_int_equal(lyd_diff_apply_all(&model_1, diff), LY_SUCCESS); |
| 392 | CHECK_LYD(model_1, model_2); |
| 393 | |
| 394 | lyd_free_all(model_1); |
| 395 | lyd_free_all(model_2); |
| 396 | lyd_free_all(diff); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | static void |
| 400 | test_empty2(void **state) |
| 401 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 402 | (void) state; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 403 | const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 404 | " <foo>42</foo>\n" |
| 405 | " <b1_1>42</b1_1>\n" |
| 406 | "</df><hidden xmlns=\"urn:libyang:tests:defaults\">\n" |
| 407 | " <foo>42</foo>\n" |
| 408 | " <baz>42</baz>\n" |
| 409 | "</hidden>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 410 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 411 | struct lyd_node *model_1; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 412 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 413 | CHECK_PARSE_LYD(xml, model_1); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 414 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 415 | struct lyd_node *diff; |
| 416 | |
| 417 | CHECK_PARSE_LYD_DIFF(model_1, NULL, diff); |
| 418 | CHECK_LYD_STRING(diff, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 419 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">\n" |
| 420 | " <foo>42</foo>\n" |
| 421 | " <b1_1>42</b1_1>\n" |
| 422 | "</df>\n" |
| 423 | "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">\n" |
| 424 | " <foo>42</foo>\n" |
| 425 | " <baz>42</baz>\n" |
| 426 | "</hidden>\n"); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 427 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 428 | assert_int_equal(lyd_diff_apply_all(&model_1, diff), LY_SUCCESS); |
| 429 | assert_ptr_equal(model_1, NULL); |
| 430 | |
| 431 | lyd_free_all(diff); |
| 432 | lyd_free_all(model_1); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | static void |
| 436 | test_empty_nested(void **state) |
| 437 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 438 | (void) state; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 439 | const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\"><foo>42</foo></df>"; |
| 440 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 441 | struct lyd_node *model_1; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 442 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 443 | CHECK_PARSE_LYD(xml, model_1); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 444 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 445 | struct lyd_node *diff = NULL; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 446 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 447 | assert_int_equal(lyd_diff_siblings(NULL, NULL, 0, &diff), LY_SUCCESS); |
| 448 | assert_null(diff); |
| 449 | |
| 450 | struct lyd_node *diff1; |
| 451 | |
| 452 | CHECK_PARSE_LYD_DIFF(NULL, lyd_child(model_1), diff1); |
| 453 | CHECK_LYD_STRING(diff1, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 454 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 455 | " <foo yang:operation=\"create\">42</foo>\n" |
| 456 | "</df>\n"); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 457 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 458 | struct lyd_node *diff2; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 459 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 460 | CHECK_PARSE_LYD_DIFF(lyd_child(model_1), NULL, diff2); |
| 461 | CHECK_LYD_STRING(diff2, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 462 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 463 | " <foo yang:operation=\"delete\">42</foo>\n" |
| 464 | "</df>\n"); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 465 | |
| 466 | lyd_free_all(model_1); |
| 467 | lyd_free_all(diff1); |
| 468 | lyd_free_all(diff2); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | static void |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 472 | test_delete_merge(void **state) |
| 473 | { |
| 474 | (void) state; |
| 475 | struct lyd_node *diff1, *diff2; |
| 476 | const char *xml1 = |
| 477 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 478 | " <list>\n" |
| 479 | " <name>a</name>\n" |
| 480 | " <list2 yang:operation=\"delete\">\n" |
| 481 | " <name2>a</name2>\n" |
| 482 | " </list2>\n" |
| 483 | " </list>\n" |
| 484 | "</df>\n"; |
| 485 | const char *xml2 = |
| 486 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 487 | " <list yang:operation=\"delete\">\n" |
| 488 | " <name>a</name>\n" |
| 489 | " </list>\n" |
| 490 | "</df>\n"; |
| 491 | const char *xml_merge = |
| 492 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 493 | " <list yang:operation=\"delete\">\n" |
| 494 | " <name>a</name>\n" |
| 495 | " <list2 yang:operation=\"delete\">\n" |
| 496 | " <name2>a</name2>\n" |
| 497 | " </list2>\n" |
| 498 | " </list>\n" |
| 499 | "</df>\n"; |
| 500 | |
| 501 | CHECK_PARSE_LYD(xml1, diff1); |
| 502 | CHECK_PARSE_LYD(xml2, diff2); |
| 503 | |
| 504 | assert_int_equal(lyd_diff_merge_all(&diff1, diff2, 0), LY_SUCCESS); |
| 505 | CHECK_LYD_STRING(diff1, xml_merge); |
| 506 | |
| 507 | lyd_free_all(diff1); |
| 508 | lyd_free_all(diff2); |
| 509 | } |
| 510 | |
| 511 | static void |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 512 | test_leaf(void **state) |
| 513 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 514 | (void) state; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 515 | const char *xml1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 516 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 517 | " <foo>42</foo>\n" |
| 518 | "</df>\n" |
| 519 | "<hidden xmlns=\"urn:libyang:tests:defaults\">\n" |
| 520 | " <foo>42</foo>\n" |
| 521 | " <baz>42</baz>\n" |
| 522 | "</hidden>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 523 | const char *xml2 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 524 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 525 | " <foo>41</foo>\n" |
| 526 | " <b1_1>42</b1_1>\n" |
| 527 | "</df>\n"; |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 528 | const char *xml3 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 529 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 530 | " <foo>40</foo>\n" |
| 531 | "</df>\n" |
| 532 | "<hidden xmlns=\"urn:libyang:tests:defaults\">\n" |
| 533 | " <foo>40</foo>\n" |
| 534 | "</hidden>\n"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 535 | const char *out_diff_1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 536 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 537 | " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"42\">41</foo>\n" |
| 538 | " <b1_1 yang:operation=\"create\">42</b1_1>\n" |
| 539 | "</df>\n" |
| 540 | "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">\n" |
| 541 | " <foo>42</foo>\n" |
| 542 | " <baz>42</baz>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 543 | "</hidden>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 544 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 545 | const char *out_diff_2 = "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 546 | " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"41\">40</foo>\n" |
| 547 | " <b1_1 yang:operation=\"delete\">42</b1_1>\n" |
| 548 | "</df>\n" |
| 549 | "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n" |
| 550 | " <foo>40</foo>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 551 | "</hidden>\n"; |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 552 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 553 | const char *out_merge = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 554 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 555 | " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"42\">40</foo>\n" |
| 556 | "</df>\n" |
| 557 | "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 558 | " <foo yang:operation=\"replace\" yang:orig-value=\"42\" yang:orig-default=\"false\">40</foo>\n" |
| 559 | " <baz yang:operation=\"delete\">42</baz>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 560 | "</hidden>\n"; |
| 561 | |
| 562 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | static void |
| 566 | test_list(void **state) |
| 567 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 568 | (void) state; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 569 | const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 570 | " <list>\n" |
| 571 | " <name>a</name>\n" |
| 572 | " <value>1</value>\n" |
| 573 | " </list>\n" |
| 574 | " <list>\n" |
| 575 | " <name>b</name>\n" |
| 576 | " <value>2</value>\n" |
| 577 | " </list>\n" |
| 578 | "</df>\n"; |
| 579 | const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 580 | " <list>\n" |
| 581 | " <name>b</name>\n" |
| 582 | " <value>-2</value>\n" |
| 583 | " </list>\n" |
| 584 | " <list>\n" |
| 585 | " <name>c</name>\n" |
| 586 | " <value>3</value>\n" |
| 587 | " </list>\n" |
| 588 | "</df>\n"; |
| 589 | const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 590 | " <list>\n" |
| 591 | " <name>b</name>\n" |
| 592 | " <value>-2</value>\n" |
| 593 | " </list>\n" |
| 594 | " <list>\n" |
| 595 | " <name>a</name>\n" |
| 596 | " <value>2</value>\n" |
| 597 | " </list>\n" |
| 598 | "</df>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 599 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 600 | const char *out_diff_1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 601 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 602 | " <list yang:operation=\"delete\">\n" |
| 603 | " <name>a</name>\n" |
| 604 | " <value>1</value>\n" |
| 605 | " </list>\n" |
| 606 | " <list yang:operation=\"none\">\n" |
| 607 | " <name>b</name>\n" |
| 608 | " <value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>\n" |
| 609 | " </list>\n" |
| 610 | " <list yang:operation=\"create\">\n" |
| 611 | " <name>c</name>\n" |
| 612 | " <value>3</value>\n" |
| 613 | " </list>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 614 | "</df>\n"; |
| 615 | const char *out_diff_2 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 616 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 617 | " <list yang:operation=\"delete\">\n" |
| 618 | " <name>c</name>\n" |
| 619 | " <value>3</value>\n" |
| 620 | " </list>\n" |
| 621 | " <list yang:operation=\"create\">\n" |
| 622 | " <name>a</name>\n" |
| 623 | " <value>2</value>\n" |
| 624 | " </list>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 625 | "</df>\n"; |
| 626 | const char *out_merge = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 627 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 628 | " <list yang:operation=\"none\">\n" |
| 629 | " <name>a</name>\n" |
| 630 | " <value yang:operation=\"replace\" yang:orig-value=\"1\" yang:orig-default=\"false\">2</value>\n" |
| 631 | " </list>\n" |
| 632 | " <list yang:operation=\"none\">\n" |
| 633 | " <name>b</name>\n" |
| 634 | " <value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>\n" |
| 635 | " </list>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 636 | "</df>\n"; |
| 637 | |
| 638 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | static void |
Michal Vasko | 58d89e9 | 2023-05-23 09:56:19 +0200 | [diff] [blame^] | 642 | test_nested_list(void **state) |
| 643 | { |
| 644 | struct lyd_node *data1, *data2, *diff; |
| 645 | const char *xml1, *xml2; |
| 646 | |
| 647 | (void) state; |
| 648 | |
| 649 | xml1 = |
| 650 | "<df xmlns=\"urn:libyang:tests:defaults\">" |
| 651 | " <list>" |
| 652 | " <name>n1</name>" |
| 653 | " <value>25</value>" |
| 654 | " <list2>" |
| 655 | " <name2>n22</name2>" |
| 656 | " <value2>26</value2>" |
| 657 | " </list2>" |
| 658 | " </list>" |
| 659 | " <list>" |
| 660 | " <name>n2</name>" |
| 661 | " <value>25</value>" |
| 662 | " <list2>" |
| 663 | " <name2>n22</name2>" |
| 664 | " <value2>26</value2>" |
| 665 | " </list2>" |
| 666 | " </list>" |
| 667 | " <list>" |
| 668 | " <name>n3</name>" |
| 669 | " <value>25</value>" |
| 670 | " <list2>" |
| 671 | " <name2>n22</name2>" |
| 672 | " <value2>26</value2>" |
| 673 | " </list2>" |
| 674 | " </list>" |
| 675 | " <list>" |
| 676 | " <name>n4</name>" |
| 677 | " <value>25</value>" |
| 678 | " <list2>" |
| 679 | " <name2>n22</name2>" |
| 680 | " <value2>26</value2>" |
| 681 | " </list2>" |
| 682 | " </list>" |
| 683 | " <list>" |
| 684 | " <name>n0</name>" |
| 685 | " <value>26</value>" |
| 686 | " <list2>" |
| 687 | " <name2>n22</name2>" |
| 688 | " <value2>26</value2>" |
| 689 | " </list2>" |
| 690 | " <list2>" |
| 691 | " <name2>n23</name2>" |
| 692 | " <value2>26</value2>" |
| 693 | " </list2>" |
| 694 | " </list>" |
| 695 | "</df>"; |
| 696 | xml2 = |
| 697 | "<df xmlns=\"urn:libyang:tests:defaults\">" |
| 698 | " <list>" |
| 699 | " <name>n0</name>" |
| 700 | " <value>30</value>" |
| 701 | " <list2>" |
| 702 | " <name2>n23</name2>" |
| 703 | " <value2>26</value2>" |
| 704 | " </list2>" |
| 705 | " </list>" |
| 706 | "</df>"; |
| 707 | |
| 708 | CHECK_PARSE_LYD(xml1, data1); |
| 709 | CHECK_PARSE_LYD(xml2, data2); |
| 710 | CHECK_PARSE_LYD_DIFF(data1, data2, diff); |
| 711 | |
| 712 | CHECK_LYD_STRING(diff, |
| 713 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 714 | " <list yang:operation=\"delete\">\n" |
| 715 | " <name>n1</name>\n" |
| 716 | " <value>25</value>\n" |
| 717 | " <list2>\n" |
| 718 | " <name2>n22</name2>\n" |
| 719 | " <value2>26</value2>\n" |
| 720 | " </list2>\n" |
| 721 | " </list>\n" |
| 722 | " <list yang:operation=\"delete\">\n" |
| 723 | " <name>n2</name>\n" |
| 724 | " <value>25</value>\n" |
| 725 | " <list2>\n" |
| 726 | " <name2>n22</name2>\n" |
| 727 | " <value2>26</value2>\n" |
| 728 | " </list2>\n" |
| 729 | " </list>\n" |
| 730 | " <list yang:operation=\"delete\">\n" |
| 731 | " <name>n3</name>\n" |
| 732 | " <value>25</value>\n" |
| 733 | " <list2>\n" |
| 734 | " <name2>n22</name2>\n" |
| 735 | " <value2>26</value2>\n" |
| 736 | " </list2>\n" |
| 737 | " </list>\n" |
| 738 | " <list yang:operation=\"delete\">\n" |
| 739 | " <name>n4</name>\n" |
| 740 | " <value>25</value>\n" |
| 741 | " <list2>\n" |
| 742 | " <name2>n22</name2>\n" |
| 743 | " <value2>26</value2>\n" |
| 744 | " </list2>\n" |
| 745 | " </list>\n" |
| 746 | " <list yang:operation=\"none\">\n" |
| 747 | " <name>n0</name>\n" |
| 748 | " <value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"26\">30</value>\n" |
| 749 | " <list2 yang:operation=\"delete\">\n" |
| 750 | " <name2>n22</name2>\n" |
| 751 | " <value2>26</value2>\n" |
| 752 | " </list2>\n" |
| 753 | " </list>\n" |
| 754 | "</df>\n"); |
| 755 | |
| 756 | lyd_free_all(data1); |
| 757 | lyd_free_all(data2); |
| 758 | lyd_free_all(diff); |
| 759 | } |
| 760 | |
| 761 | static void |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 762 | test_userord_llist(void **state) |
| 763 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 764 | (void) state; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 765 | const char *xml1 = |
| 766 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 767 | " <llist>1</llist>\n" |
| 768 | " <llist>2</llist>\n" |
| 769 | " <llist>3</llist>\n" |
| 770 | " <llist>4</llist>\n" |
| 771 | " <llist>5</llist>\n" |
| 772 | "</df>\n"; |
| 773 | const char *xml2 = |
| 774 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 775 | " <llist>1</llist>\n" |
| 776 | " <llist>4</llist>\n" |
| 777 | " <llist>3</llist>\n" |
| 778 | " <llist>2</llist>\n" |
| 779 | " <llist>5</llist>\n" |
| 780 | "</df>\n"; |
| 781 | const char *xml3 = |
| 782 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 783 | " <llist>5</llist>\n" |
| 784 | " <llist>4</llist>\n" |
| 785 | " <llist>3</llist>\n" |
| 786 | " <llist>2</llist>\n" |
| 787 | "</df>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 788 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 789 | const char *out_diff_1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 790 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 791 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>\n" |
| 792 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 793 | "</df>\n"; |
| 794 | const char *out_diff_2 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 795 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 796 | " <llist yang:operation=\"delete\" yang:orig-value=\"\">1</llist>\n" |
| 797 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\">5</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 798 | "</df>\n"; |
| 799 | const char *out_merge = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 800 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 801 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>\n" |
| 802 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>\n" |
| 803 | " <llist yang:orig-value=\"\" yang:operation=\"delete\">1</llist>\n" |
| 804 | " <llist yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\" yang:operation=\"replace\">5</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 805 | "</df>\n"; |
| 806 | |
| 807 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | static void |
| 811 | test_userord_llist2(void **state) |
| 812 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 813 | (void) state; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 814 | const char *xml1 = |
| 815 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 816 | " <llist>1</llist>\n" |
| 817 | " <list><name>a</name><value>1</value></list>\n" |
| 818 | " <llist>2</llist>\n" |
| 819 | " <llist>3</llist>\n" |
| 820 | " <llist>4</llist>\n" |
| 821 | "</df>\n"; |
| 822 | const char *xml2 = |
| 823 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 824 | " <llist>1</llist>\n" |
| 825 | " <list><name>a</name><value>1</value></list>\n" |
| 826 | " <llist>2</llist>\n" |
| 827 | " <llist>4</llist>\n" |
| 828 | " <llist>3</llist>\n" |
| 829 | "</df>\n"; |
| 830 | const char *xml3 = |
| 831 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 832 | " <llist>4</llist>\n" |
| 833 | " <llist>1</llist>\n" |
| 834 | " <list><name>a</name><value>1</value></list>\n" |
| 835 | " <llist>3</llist>\n" |
| 836 | "</df>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 837 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 838 | const char *out_diff_1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 839 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 840 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"2\">4</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 841 | "</df>\n"; |
| 842 | const char *out_diff_2 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 843 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 844 | " <llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>\n" |
| 845 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">4</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 846 | "</df>\n"; |
| 847 | const char *out_merge = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 848 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 849 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">4</llist>\n" |
| 850 | " <llist yang:orig-value=\"1\" yang:operation=\"delete\">2</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 851 | "</df>\n"; |
| 852 | |
| 853 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | static void |
| 857 | test_userord_mix(void **state) |
| 858 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 859 | (void) state; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 860 | const char *xml1 = |
| 861 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 862 | " <llist>1</llist>\n" |
| 863 | " <llist>2</llist>\n" |
| 864 | " <llist>3</llist>\n" |
| 865 | "</df>\n"; |
| 866 | const char *xml2 = |
| 867 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 868 | " <llist>3</llist>\n" |
| 869 | " <llist>1</llist>\n" |
| 870 | "</df>\n"; |
| 871 | const char *xml3 = |
| 872 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 873 | " <llist>1</llist>\n" |
| 874 | " <llist>4</llist>\n" |
| 875 | " <llist>3</llist>\n" |
| 876 | "</df>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 877 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 878 | const char *out_diff_1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 879 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 880 | " <llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>\n" |
| 881 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 882 | "</df>\n"; |
| 883 | const char *out_diff_2 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 884 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 885 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">1</llist>\n" |
| 886 | " <llist yang:operation=\"create\" yang:value=\"1\">4</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 887 | "</df>\n"; |
| 888 | const char *out_merge = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 889 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 890 | " <llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>\n" |
| 891 | " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>\n" |
| 892 | " <llist yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\" yang:operation=\"replace\">1</llist>\n" |
| 893 | " <llist yang:value=\"1\" yang:operation=\"create\">4</llist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 894 | "</df>\n"; |
| 895 | |
| 896 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | static void |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 900 | test_userord_list(void **state) |
| 901 | { |
| 902 | (void) state; |
| 903 | const char *xml1 = |
| 904 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 905 | " <ul>\n" |
| 906 | " <l1>a</l1>\n" |
| 907 | " <l2>1</l2>\n" |
| 908 | " </ul>\n" |
| 909 | " <ul>\n" |
| 910 | " <l1>b</l1>\n" |
| 911 | " <l2>2</l2>\n" |
| 912 | " </ul>\n" |
| 913 | " <ul>\n" |
| 914 | " <l1>c</l1>\n" |
| 915 | " <l2>3</l2>\n" |
| 916 | " </ul>\n" |
| 917 | "</df>\n"; |
| 918 | const char *xml2 = |
| 919 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 920 | " <ul>\n" |
| 921 | " <l1>a</l1>\n" |
| 922 | " <l2>11</l2>\n" |
| 923 | " </ul>\n" |
| 924 | " <ul>\n" |
| 925 | " <l1>c</l1>\n" |
| 926 | " <l2>3</l2>\n" |
| 927 | " </ul>\n" |
| 928 | "</df>\n"; |
| 929 | const char *xml3 = |
| 930 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 931 | " <ul>\n" |
| 932 | " <l1>c</l1>\n" |
| 933 | " <l2>33</l2>\n" |
| 934 | " </ul>\n" |
| 935 | " <ul>\n" |
| 936 | " <l1>b</l1>\n" |
| 937 | " <l2>2</l2>\n" |
| 938 | " </ul>\n" |
| 939 | "</df>\n"; |
| 940 | |
| 941 | const char *out_diff_1 = |
| 942 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 943 | " <ul>\n" |
| 944 | " <l1>a</l1>\n" |
| 945 | " <l2 yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\">11</l2>\n" |
| 946 | " </ul>\n" |
| 947 | " <ul yang:operation=\"delete\" yang:orig-key=\"[l1='a']\">\n" |
| 948 | " <l1>b</l1>\n" |
| 949 | " <l2>2</l2>\n" |
| 950 | " </ul>\n" |
| 951 | "</df>\n"; |
| 952 | const char *out_diff_2 = |
| 953 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 954 | " <ul yang:operation=\"delete\" yang:orig-key=\"\">\n" |
| 955 | " <l1>a</l1>\n" |
| 956 | " <l2>11</l2>\n" |
| 957 | " </ul>\n" |
| 958 | " <ul yang:operation=\"none\">\n" |
| 959 | " <l1>c</l1>\n" |
| 960 | " <l2 yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\">33</l2>\n" |
| 961 | " </ul>\n" |
| 962 | " <ul yang:operation=\"create\" yang:key=\"[l1='c']\">\n" |
| 963 | " <l1>b</l1>\n" |
| 964 | " <l2>2</l2>\n" |
| 965 | " </ul>\n" |
| 966 | "</df>\n"; |
| 967 | const char *out_merge = |
| 968 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 969 | " <ul yang:operation=\"delete\">\n" |
| 970 | " <l1>a</l1>\n" |
| 971 | " <l2 yang:operation=\"delete\">1</l2>\n" |
| 972 | " </ul>\n" |
| 973 | " <ul yang:orig-key=\"[l1='a']\" yang:operation=\"replace\" yang:key=\"[l1='c']\">\n" |
| 974 | " <l1>b</l1>\n" |
| 975 | " </ul>\n" |
| 976 | " <ul yang:operation=\"none\">\n" |
| 977 | " <l1>c</l1>\n" |
| 978 | " <l2 yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\">33</l2>\n" |
| 979 | " </ul>\n" |
| 980 | "</df>\n"; |
| 981 | |
| 982 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
| 983 | } |
| 984 | |
| 985 | static void |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 986 | test_userord_list2(void **state) |
| 987 | { |
| 988 | (void) state; |
| 989 | const char *xml1 = |
| 990 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 991 | " <ul>\n" |
| 992 | " <l1>d</l1>\n" |
| 993 | " <l2>4</l2>\n" |
| 994 | " </ul>\n" |
| 995 | "</df>\n"; |
| 996 | const char *xml2 = |
| 997 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 998 | " <ul>\n" |
| 999 | " <l1>c</l1>\n" |
| 1000 | " <l2>3</l2>\n" |
| 1001 | " </ul>\n" |
| 1002 | " <ul>\n" |
| 1003 | " <l1>d</l1>\n" |
| 1004 | " <l2>4</l2>\n" |
| 1005 | " </ul>\n" |
| 1006 | "</df>\n"; |
| 1007 | const char *xml3 = |
| 1008 | "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1009 | " <ul>\n" |
| 1010 | " <l1>a</l1>\n" |
| 1011 | " <l2>1</l2>\n" |
| 1012 | " </ul>\n" |
| 1013 | " <ul>\n" |
| 1014 | " <l1>b</l1>\n" |
| 1015 | " <l2>2</l2>\n" |
| 1016 | " </ul>\n" |
| 1017 | " <ul>\n" |
| 1018 | " <l1>c</l1>\n" |
| 1019 | " <l2>3</l2>\n" |
| 1020 | " </ul>\n" |
| 1021 | " <ul>\n" |
| 1022 | " <l1>d</l1>\n" |
| 1023 | " <l2>4</l2>\n" |
| 1024 | " </ul>\n" |
| 1025 | "</df>\n"; |
| 1026 | |
| 1027 | const char *out_diff_1 = |
| 1028 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1029 | " <ul yang:operation=\"create\" yang:key=\"\">\n" |
| 1030 | " <l1>c</l1>\n" |
| 1031 | " <l2>3</l2>\n" |
| 1032 | " </ul>\n" |
| 1033 | "</df>\n"; |
| 1034 | const char *out_diff_2 = |
| 1035 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1036 | " <ul yang:operation=\"create\" yang:key=\"\">\n" |
| 1037 | " <l1>a</l1>\n" |
| 1038 | " <l2>1</l2>\n" |
| 1039 | " </ul>\n" |
| 1040 | " <ul yang:operation=\"create\" yang:key=\"[l1='a']\">\n" |
| 1041 | " <l1>b</l1>\n" |
| 1042 | " <l2>2</l2>\n" |
| 1043 | " </ul>\n" |
| 1044 | "</df>\n"; |
| 1045 | const char *out_merge = |
| 1046 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1047 | " <ul yang:operation=\"create\" yang:key=\"\">\n" |
| 1048 | " <l1>c</l1>\n" |
| 1049 | " <l2>3</l2>\n" |
| 1050 | " </ul>\n" |
| 1051 | " <ul yang:key=\"\" yang:operation=\"create\">\n" |
| 1052 | " <l1>a</l1>\n" |
| 1053 | " <l2>1</l2>\n" |
| 1054 | " </ul>\n" |
| 1055 | " <ul yang:key=\"[l1='a']\" yang:operation=\"create\">\n" |
| 1056 | " <l1>b</l1>\n" |
| 1057 | " <l2>2</l2>\n" |
| 1058 | " </ul>\n" |
| 1059 | "</df>\n"; |
| 1060 | |
| 1061 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
| 1062 | } |
| 1063 | |
| 1064 | static void |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 1065 | test_keyless_list(void **state) |
| 1066 | { |
| 1067 | (void) state; |
| 1068 | const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1069 | " <kl>\n" |
| 1070 | " <l1>a</l1>\n" |
| 1071 | " <l2>1</l2>\n" |
| 1072 | " </kl>\n" |
| 1073 | " <kl>\n" |
| 1074 | " <l1>b</l1>\n" |
| 1075 | " <l2>2</l2>\n" |
| 1076 | " </kl>\n" |
| 1077 | " <kl>\n" |
| 1078 | " <l1>c</l1>\n" |
| 1079 | " <l2>3</l2>\n" |
| 1080 | " </kl>\n" |
| 1081 | "</df>\n"; |
| 1082 | const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1083 | " <kl>\n" |
| 1084 | " <l1>b</l1>\n" |
| 1085 | " <l2>2</l2>\n" |
| 1086 | " </kl>\n" |
| 1087 | " <kl>\n" |
| 1088 | " <l1>a</l1>\n" |
| 1089 | " <l2>1</l2>\n" |
| 1090 | " </kl>\n" |
| 1091 | " <kl>\n" |
| 1092 | " <l1>a</l1>\n" |
| 1093 | " <l2>1</l2>\n" |
| 1094 | " </kl>\n" |
| 1095 | "</df>\n"; |
| 1096 | const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1097 | " <kl>\n" |
| 1098 | " <l1>c</l1>\n" |
| 1099 | " </kl>\n" |
| 1100 | " <kl>\n" |
| 1101 | " <l2>4</l2>\n" |
| 1102 | " </kl>\n" |
| 1103 | " <kl>\n" |
| 1104 | " <l1>e</l1>\n" |
| 1105 | " <l2>5</l2>\n" |
| 1106 | " </kl>\n" |
| 1107 | " <kl>\n" |
| 1108 | " <l1>f</l1>\n" |
| 1109 | " <l2>6</l2>\n" |
| 1110 | " </kl>\n" |
| 1111 | "</df>\n"; |
| 1112 | |
| 1113 | const char *out_diff_1 = |
| 1114 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1115 | " <kl yang:operation=\"delete\" yang:orig-position=\"2\">\n" |
| 1116 | " <l1>c</l1>\n" |
| 1117 | " <l2>3</l2>\n" |
| 1118 | " </kl>\n" |
| 1119 | " <kl yang:operation=\"replace\" yang:position=\"\" yang:orig-position=\"1\">\n" |
| 1120 | " <l1>b</l1>\n" |
| 1121 | " <l2>2</l2>\n" |
| 1122 | " </kl>\n" |
| 1123 | " <kl yang:operation=\"create\" yang:position=\"2\">\n" |
| 1124 | " <l1>a</l1>\n" |
| 1125 | " <l2>1</l2>\n" |
| 1126 | " </kl>\n" |
| 1127 | "</df>\n"; |
| 1128 | const char *out_diff_2 = |
| 1129 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1130 | " <kl yang:operation=\"delete\" yang:orig-position=\"\">\n" |
| 1131 | " <l1>b</l1>\n" |
| 1132 | " <l2>2</l2>\n" |
| 1133 | " </kl>\n" |
| 1134 | " <kl yang:operation=\"delete\" yang:orig-position=\"\">\n" |
| 1135 | " <l1>a</l1>\n" |
| 1136 | " <l2>1</l2>\n" |
| 1137 | " </kl>\n" |
| 1138 | " <kl yang:operation=\"delete\" yang:orig-position=\"\">\n" |
| 1139 | " <l1>a</l1>\n" |
| 1140 | " <l2>1</l2>\n" |
| 1141 | " </kl>\n" |
| 1142 | " <kl yang:operation=\"create\" yang:position=\"\">\n" |
| 1143 | " <l1>c</l1>\n" |
| 1144 | " </kl>\n" |
| 1145 | " <kl yang:operation=\"create\" yang:position=\"1\">\n" |
| 1146 | " <l2>4</l2>\n" |
| 1147 | " </kl>\n" |
| 1148 | " <kl yang:operation=\"create\" yang:position=\"2\">\n" |
| 1149 | " <l1>e</l1>\n" |
| 1150 | " <l2>5</l2>\n" |
| 1151 | " </kl>\n" |
| 1152 | " <kl yang:operation=\"create\" yang:position=\"3\">\n" |
| 1153 | " <l1>f</l1>\n" |
| 1154 | " <l2>6</l2>\n" |
| 1155 | " </kl>\n" |
| 1156 | "</df>\n"; |
| 1157 | const char *out_merge = |
| 1158 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1159 | " <kl yang:operation=\"delete\" yang:orig-position=\"2\">\n" |
| 1160 | " <l1>c</l1>\n" |
| 1161 | " <l2>3</l2>\n" |
| 1162 | " </kl>\n" |
| 1163 | " <kl yang:orig-position=\"1\" yang:operation=\"delete\">\n" |
| 1164 | " <l1>b</l1>\n" |
| 1165 | " <l2>2</l2>\n" |
| 1166 | " </kl>\n" |
| 1167 | " <kl yang:orig-position=\"\" yang:operation=\"delete\">\n" |
| 1168 | " <l1>a</l1>\n" |
| 1169 | " <l2>1</l2>\n" |
| 1170 | " </kl>\n" |
| 1171 | " <kl yang:position=\"\" yang:operation=\"create\">\n" |
| 1172 | " <l1>c</l1>\n" |
| 1173 | " </kl>\n" |
| 1174 | " <kl yang:position=\"1\" yang:operation=\"create\">\n" |
| 1175 | " <l2>4</l2>\n" |
| 1176 | " </kl>\n" |
| 1177 | " <kl yang:position=\"2\" yang:operation=\"create\">\n" |
| 1178 | " <l1>e</l1>\n" |
| 1179 | " <l2>5</l2>\n" |
| 1180 | " </kl>\n" |
| 1181 | " <kl yang:position=\"3\" yang:operation=\"create\">\n" |
| 1182 | " <l1>f</l1>\n" |
| 1183 | " <l2>6</l2>\n" |
| 1184 | " </kl>\n" |
| 1185 | "</df>\n"; |
| 1186 | |
| 1187 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
| 1188 | } |
| 1189 | |
| 1190 | static void |
| 1191 | test_state_llist(void **state) |
| 1192 | { |
| 1193 | (void) state; |
| 1194 | const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1195 | " <kll>a</kll>\n" |
| 1196 | " <kll>b</kll>\n" |
| 1197 | " <kll>c</kll>\n" |
| 1198 | "</df>\n"; |
| 1199 | const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1200 | " <kll>b</kll>\n" |
| 1201 | " <kll>c</kll>\n" |
| 1202 | " <kll>a</kll>\n" |
| 1203 | " <kll>a</kll>\n" |
| 1204 | " <kll>a</kll>\n" |
| 1205 | "</df>\n"; |
| 1206 | const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1207 | " <kll>a</kll>\n" |
| 1208 | " <kll>d</kll>\n" |
| 1209 | " <kll>a</kll>\n" |
| 1210 | "</df>\n"; |
| 1211 | |
| 1212 | const char *out_diff_1 = |
| 1213 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1214 | " <kll yang:operation=\"replace\" yang:orig-default=\"false\" yang:position=\"\" yang:orig-position=\"1\">b</kll>\n" |
| 1215 | " <kll yang:operation=\"replace\" yang:orig-default=\"false\" yang:position=\"1\" yang:orig-position=\"2\">c</kll>\n" |
| 1216 | " <kll yang:operation=\"create\" yang:position=\"3\">a</kll>\n" |
| 1217 | " <kll yang:operation=\"create\" yang:position=\"4\">a</kll>\n" |
| 1218 | "</df>\n"; |
| 1219 | const char *out_diff_2 = |
| 1220 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1221 | " <kll yang:operation=\"delete\" yang:orig-position=\"\">b</kll>\n" |
| 1222 | " <kll yang:operation=\"delete\" yang:orig-position=\"\">c</kll>\n" |
| 1223 | " <kll yang:operation=\"delete\" yang:orig-position=\"2\">a</kll>\n" |
| 1224 | " <kll yang:operation=\"create\" yang:position=\"1\">d</kll>\n" |
| 1225 | "</df>\n"; |
| 1226 | const char *out_merge = |
| 1227 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1228 | " <kll yang:orig-default=\"false\" yang:orig-position=\"1\" yang:operation=\"delete\">b</kll>\n" |
| 1229 | " <kll yang:orig-default=\"false\" yang:orig-position=\"2\" yang:operation=\"delete\">c</kll>\n" |
| 1230 | " <kll yang:operation=\"create\" yang:position=\"4\">a</kll>\n" |
| 1231 | " <kll yang:position=\"1\" yang:operation=\"create\">d</kll>\n" |
| 1232 | "</df>\n"; |
| 1233 | |
| 1234 | TEST_DIFF_3(xml1, xml2, xml3, out_diff_1, out_diff_2, out_merge); |
| 1235 | } |
| 1236 | |
| 1237 | static void |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1238 | test_wd(void **state) |
| 1239 | { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1240 | (void) state; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1241 | const struct lys_module *mod; |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 1242 | const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1243 | " <foo>41</foo>\n" |
| 1244 | " <dllist>4</dllist>\n" |
| 1245 | "</df>\n"; |
| 1246 | const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">\n" |
| 1247 | " <foo>42</foo>\n" |
| 1248 | " <dllist>4</dllist>\n" |
| 1249 | " <dllist>1</dllist>\n" |
| 1250 | "</df>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1251 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1252 | mod = ly_ctx_get_module_implemented(UTEST_LYCTX, "defaults"); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1253 | assert_non_null(mod); |
| 1254 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1255 | struct lyd_node *model_1 = NULL; |
| 1256 | |
| 1257 | assert_int_equal(lyd_validate_module(&model_1, mod, 0, NULL), LY_SUCCESS); |
| 1258 | assert_ptr_not_equal(model_1, NULL); |
| 1259 | |
| 1260 | struct lyd_node *model_2; |
| 1261 | struct lyd_node *model_3; |
| 1262 | |
| 1263 | CHECK_PARSE_LYD_PARAM(xml2, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_SUCCESS, model_2); |
| 1264 | CHECK_PARSE_LYD_PARAM(xml3, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_SUCCESS, model_3); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1265 | |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1266 | /* diff1 */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1267 | struct lyd_node *diff1 = NULL; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1268 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1269 | assert_int_equal(lyd_diff_siblings(model_1, model_2, LYD_DIFF_DEFAULTS, &diff1), LY_SUCCESS); |
| 1270 | assert_non_null(diff1); |
| 1271 | |
| 1272 | const char *diff1_out_1 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 1273 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1274 | " <foo yang:operation=\"replace\" yang:orig-default=\"true\" yang:orig-value=\"42\">41</foo>\n" |
| 1275 | " <dllist yang:operation=\"delete\">1</dllist>\n" |
| 1276 | " <dllist yang:operation=\"delete\">2</dllist>\n" |
| 1277 | " <dllist yang:operation=\"delete\">3</dllist>\n" |
| 1278 | " <dllist yang:operation=\"create\">4</dllist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1279 | "</df>\n"; |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1280 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1281 | CHECK_LYD_STRING_PARAM(diff1, diff1_out_1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL); |
| 1282 | assert_int_equal(lyd_diff_apply_all(&model_1, diff1), LY_SUCCESS); |
| 1283 | CHECK_LYD(model_1, model_2); |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1284 | |
| 1285 | /* diff2 */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1286 | struct lyd_node *diff2; |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1287 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1288 | assert_int_equal(lyd_diff_siblings(model_2, model_3, LYD_DIFF_DEFAULTS, &diff2), LY_SUCCESS); |
| 1289 | assert_non_null(diff2); |
| 1290 | CHECK_LYD_STRING(diff2, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 1291 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1292 | " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"41\">42</foo>\n" |
| 1293 | " <dllist yang:operation=\"create\">1</dllist>\n" |
| 1294 | "</df>\n"); |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1295 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1296 | assert_int_equal(lyd_diff_apply_all(&model_2, diff2), LY_SUCCESS); |
| 1297 | CHECK_LYD(model_2, model_3); |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1298 | |
| 1299 | /* merge */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1300 | assert_int_equal(lyd_diff_merge_all(&diff1, diff2, 0), LY_SUCCESS); |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1301 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1302 | const char *diff1_out_2 = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 1303 | "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n" |
| 1304 | " <foo yang:orig-default=\"true\" yang:operation=\"none\">42</foo>\n" |
| 1305 | " <dllist yang:operation=\"none\" yang:orig-default=\"true\">1</dllist>\n" |
| 1306 | " <dllist yang:operation=\"delete\">2</dllist>\n" |
| 1307 | " <dllist yang:operation=\"delete\">3</dllist>\n" |
| 1308 | " <dllist yang:operation=\"create\">4</dllist>\n" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1309 | "</df>\n"; |
| 1310 | |
| 1311 | CHECK_LYD_STRING_PARAM(diff1, diff1_out_2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL); |
| 1312 | |
| 1313 | lyd_free_all(model_1); |
| 1314 | lyd_free_all(model_2); |
| 1315 | lyd_free_all(model_3); |
| 1316 | lyd_free_all(diff1); |
| 1317 | lyd_free_all(diff2); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1318 | } |
| 1319 | |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 1320 | int |
| 1321 | main(void) |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1322 | { |
| 1323 | const struct CMUnitTest tests[] = { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1324 | UTEST(test_invalid, setup), |
| 1325 | UTEST(test_same, setup), |
| 1326 | UTEST(test_empty1, setup), |
| 1327 | UTEST(test_empty2, setup), |
| 1328 | UTEST(test_empty_nested, setup), |
Michal Vasko | 17d0c5c | 2021-11-01 11:31:11 +0100 | [diff] [blame] | 1329 | UTEST(test_delete_merge, setup), |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1330 | UTEST(test_leaf, setup), |
| 1331 | UTEST(test_list, setup), |
Michal Vasko | 58d89e9 | 2023-05-23 09:56:19 +0200 | [diff] [blame^] | 1332 | UTEST(test_nested_list, setup), |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1333 | UTEST(test_userord_llist, setup), |
| 1334 | UTEST(test_userord_llist2, setup), |
| 1335 | UTEST(test_userord_mix, setup), |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 1336 | UTEST(test_userord_list, setup), |
Michal Vasko | 5da938a | 2022-03-01 09:19:02 +0100 | [diff] [blame] | 1337 | UTEST(test_userord_list2, setup), |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 1338 | UTEST(test_keyless_list, setup), |
| 1339 | UTEST(test_state_llist, setup), |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1340 | UTEST(test_wd, setup), |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1341 | }; |
| 1342 | |
| 1343 | return cmocka_run_group_tests(tests, NULL, NULL); |
| 1344 | } |