Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 1 | /** |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 2 | * @file test_tree_schema.c |
| 3 | * @author: Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief unit tests for functions from tress_data.c |
| 5 | * |
| 6 | * Copyright (c) 2018-2019 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 14 | #define _UTEST_MAIN_ |
| 15 | #include "utests.h" |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 16 | |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 17 | #include "common.h" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 18 | #include "libyang.h" |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 19 | #include "path.h" |
| 20 | #include "xpath.h" |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 21 | |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 22 | static int |
| 23 | setup(void **state) |
| 24 | { |
aPiecek | 2425220 | 2021-03-30 12:23:32 +0200 | [diff] [blame] | 25 | const char *schema1 = "module a {namespace urn:tests:a;prefix a;yang-version 1.1;" |
| 26 | "revision 2014-05-08;" |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 27 | "leaf bar {type string;}" |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 28 | "list l1 { key \"a b\"; leaf a {type string;} leaf b {type string;} leaf c {type string;}}" |
| 29 | "leaf foo { type string;}" |
| 30 | "leaf-list ll { type string;}" |
| 31 | "container c {leaf-list x {type string;}}" |
| 32 | "anydata any {config false;}" |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 33 | "list l2 {config false;" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 34 | " container c{leaf x {type string;} leaf-list d {type string;}}" |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 35 | "}}"; |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 36 | |
aPiecek | 2425220 | 2021-03-30 12:23:32 +0200 | [diff] [blame] | 37 | const char *schema2 = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 38 | "revision 2014-05-08;" |
| 39 | "list l2 {config false;" |
| 40 | " container c{leaf x {type string;}}}" |
| 41 | "anydata any {config false;}" |
| 42 | "}"; |
| 43 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 44 | UTEST_SETUP; |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 45 | |
aPiecek | 2425220 | 2021-03-30 12:23:32 +0200 | [diff] [blame] | 46 | UTEST_ADD_MODULE(schema1, LYS_IN_YANG, NULL, NULL); |
| 47 | UTEST_ADD_MODULE(schema2, LYS_IN_YANG, NULL, NULL); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 52 | #define CHECK_PARSE_LYD(INPUT, PARSE_OPTION, VALIDATE_OPTION, TREE) \ |
| 53 | CHECK_PARSE_LYD_PARAM(INPUT, LYD_XML, PARSE_OPTION, VALIDATE_OPTION, LY_SUCCESS, TREE) |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 54 | |
aPiecek | 2425220 | 2021-03-30 12:23:32 +0200 | [diff] [blame] | 55 | #define CHECK_PARSE_LYD_PARAM_CTX(CTX, INPUT, PARSE_OPTION, OUT_NODE) \ |
| 56 | assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(CTX, INPUT, LYD_XML, PARSE_OPTION, LYD_VALIDATE_PRESENT, &OUT_NODE)); \ |
| 57 | assert_non_null(OUT_NODE); |
| 58 | |
| 59 | #define RECREATE_CTX_WITH_MODULE(CTX, MODULE) \ |
| 60 | ly_ctx_destroy(CTX, NULL); \ |
| 61 | assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &CTX)); \ |
| 62 | assert_int_equal(LY_SUCCESS, ly_in_new_memory(MODULE, &_UC->in)); \ |
| 63 | assert_int_equal(LY_SUCCESS, lys_parse(CTX, _UC->in, LYS_IN_YANG, NULL, NULL)); \ |
| 64 | ly_in_free(_UC->in, 0); |
| 65 | |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 66 | static void |
| 67 | test_compare(void **state) |
| 68 | { |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 69 | struct lyd_node *tree1, *tree2; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 70 | const char *data1; |
| 71 | const char *data2; |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 72 | |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 73 | assert_int_equal(LY_SUCCESS, lyd_compare_single(NULL, NULL, 0)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 74 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 75 | data1 = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>"; |
| 76 | data2 = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>y</c></l1>"; |
| 77 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
| 78 | CHECK_PARSE_LYD(data2, 0, LYD_VALIDATE_PRESENT, tree2); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 79 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, 0)); |
| 80 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 81 | assert_int_equal(LY_ENOT, lyd_compare_single(((struct lyd_node_inner *)tree1)->child, tree2, 0)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 82 | lyd_free_all(tree1); |
| 83 | lyd_free_all(tree2); |
| 84 | |
| 85 | data1 = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>"; |
| 86 | data2 = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 87 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
| 88 | CHECK_PARSE_LYD(data2, 0, LYD_VALIDATE_PRESENT, tree2); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 89 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1->next, tree2->next, 0)); |
| 90 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next->next, tree2->next, 0)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 91 | lyd_free_all(tree1); |
| 92 | lyd_free_all(tree2); |
| 93 | |
| 94 | data1 = "<ll xmlns=\"urn:tests:a\">a</ll><ll xmlns=\"urn:tests:a\">b</ll>"; |
| 95 | data2 = "<ll xmlns=\"urn:tests:a\">b</ll>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 96 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
| 97 | CHECK_PARSE_LYD(data2, 0, LYD_VALIDATE_PRESENT, tree2); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 98 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, 0)); |
| 99 | assert_int_equal(LY_ENOT, lyd_compare_single(NULL, tree2, 0)); |
| 100 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, NULL, 0)); |
| 101 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, tree2, 0)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 102 | lyd_free_all(tree1); |
| 103 | lyd_free_all(tree2); |
| 104 | |
| 105 | data1 = "<c xmlns=\"urn:tests:a\"><x>x</x></c>"; |
| 106 | data2 = "<c xmlns=\"urn:tests:a\"><x>y</x></c>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 107 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
| 108 | CHECK_PARSE_LYD(data2, 0, LYD_VALIDATE_PRESENT, tree2); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 109 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, 0)); |
| 110 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 111 | lyd_free_all(tree1); |
| 112 | lyd_free_all(tree2); |
| 113 | |
| 114 | data1 = "<c xmlns=\"urn:tests:a\"><x>x</x></c>"; |
| 115 | data2 = "<c xmlns=\"urn:tests:a\"><x>x</x><x>y</x></c>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 116 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
| 117 | CHECK_PARSE_LYD(data2, 0, LYD_VALIDATE_PRESENT, tree2); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 118 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, 0)); |
| 119 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 120 | lyd_free_all(tree1); |
| 121 | lyd_free_all(tree2); |
| 122 | |
| 123 | data1 = "<any xmlns=\"urn:tests:a\"><x>x</x></any>"; |
| 124 | data2 = "<any xmlns=\"urn:tests:a\"><x>x</x><x>y</x></any>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 125 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
| 126 | CHECK_PARSE_LYD(data2, 0, LYD_VALIDATE_PRESENT, tree2); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 127 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1->next, tree2->next, 0)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 128 | lyd_free_all(tree1); |
| 129 | data1 = "<any xmlns=\"urn:tests:a\"><x>x</x><x>y</x></any>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 130 | CHECK_PARSE_LYD(data1, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 131 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, 0)); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 132 | lyd_free_all(tree1); |
| 133 | lyd_free_all(tree2); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 134 | } |
| 135 | |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 136 | static void |
aPiecek | 2425220 | 2021-03-30 12:23:32 +0200 | [diff] [blame] | 137 | test_compare_diff_ctx(void **state) |
| 138 | { |
| 139 | struct lyd_node *tree1, *tree2; |
| 140 | const char *data1, *data2; |
| 141 | struct ly_ctx *ctx2 = NULL; |
| 142 | const char *module; |
| 143 | |
| 144 | /* create second context with the same schema */ |
| 145 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 146 | "revision 2014-05-08;" |
| 147 | "list l2 {config false;" |
| 148 | " container c{leaf x {type string;}}" |
| 149 | "}}"; |
| 150 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 151 | data1 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 152 | data2 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 153 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, 0, tree1); |
| 154 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, 0, tree2); |
| 155 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
| 156 | lyd_free_all(tree1); |
| 157 | lyd_free_all(tree2); |
| 158 | |
| 159 | /* recreate second context with schema that has a different name */ |
| 160 | module = "module c {namespace urn:tests:c;prefix c;yang-version 1.1;" |
| 161 | "revision 2014-05-08;" |
| 162 | "list l2 {config false;" |
| 163 | " container c{leaf x {type string;}}" |
| 164 | "}}"; |
| 165 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 166 | data1 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 167 | data2 = "<l2 xmlns=\"urn:tests:c\"><c><x>b</x></c></l2>"; |
| 168 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, 0, tree1); |
| 169 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, 0, tree2); |
| 170 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, 0)); |
| 171 | lyd_free_all(tree1); |
| 172 | lyd_free_all(tree2); |
| 173 | |
| 174 | /* recreate second context with schema that has a different revision */ |
| 175 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 176 | "revision 2015-05-08;" |
| 177 | "list l2 {config false;" |
| 178 | " container c{leaf x {type string;}}" |
| 179 | "}}"; |
| 180 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 181 | data1 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 182 | data2 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 183 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, 0, tree1); |
| 184 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, 0, tree2); |
| 185 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, 0)); |
| 186 | lyd_free_all(tree1); |
| 187 | lyd_free_all(tree2); |
| 188 | |
| 189 | /* recreate second context with schema that has no revision */ |
| 190 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 191 | "list l2 {config false;" |
| 192 | " container c{leaf x {type string;}}" |
| 193 | "}}"; |
| 194 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 195 | data1 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 196 | data2 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 197 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, 0, tree1); |
| 198 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, 0, tree2); |
| 199 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, 0)); |
| 200 | lyd_free_all(tree1); |
| 201 | lyd_free_all(tree2); |
| 202 | |
| 203 | /* recreate second context with schema that has a different parent nodetype */ |
| 204 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 205 | "revision 2014-05-08;" |
| 206 | "container l2 {config false;" |
| 207 | " container c{leaf x {type string;}}" |
| 208 | "}}"; |
| 209 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 210 | data1 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 211 | data2 = "<l2 xmlns=\"urn:tests:b\"><c><x>b</x></c></l2>"; |
| 212 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, 0, tree1); |
| 213 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, 0, tree2); |
| 214 | assert_int_equal(LY_ENOT, lyd_compare_single(lyd_child(lyd_child(tree1)), lyd_child(lyd_child(tree2)), 0)); |
| 215 | lyd_free_all(tree1); |
| 216 | lyd_free_all(tree2); |
| 217 | |
| 218 | /* recreate second context with the same opaq data nodes */ |
| 219 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 220 | "revision 2014-05-08;" |
| 221 | "anydata any {config false;}" |
| 222 | "}"; |
| 223 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 224 | data1 = "<any xmlns=\"urn:tests:b\" xmlns:aa=\"urn:tests:b\"><x>aa:x</x></any>"; |
| 225 | data2 = "<any xmlns=\"urn:tests:b\" xmlns:bb=\"urn:tests:b\"><x>bb:x</x></any>"; |
| 226 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, LYD_PARSE_ONLY, tree1); |
| 227 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, LYD_PARSE_ONLY, tree2); |
| 228 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, 0)); |
| 229 | lyd_free_all(tree1); |
| 230 | lyd_free_all(tree2); |
| 231 | |
| 232 | /* recreate second context with the different opaq data node value */ |
| 233 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 234 | "revision 2014-05-08;" |
| 235 | "anydata any {config false;}" |
| 236 | "}"; |
| 237 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 238 | data1 = "<any xmlns=\"urn:tests:b\" xmlns:aa=\"urn:tests:b\"><x>aa:x</x></any>"; |
| 239 | data2 = "<any xmlns=\"urn:tests:b\" xmlns:bb=\"urn:tests:b\"><x>bb:y</x></any>"; |
| 240 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, LYD_PARSE_ONLY, tree1); |
| 241 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, LYD_PARSE_ONLY, tree2); |
| 242 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, 0)); |
| 243 | lyd_free_all(tree1); |
| 244 | lyd_free_all(tree2); |
| 245 | |
| 246 | /* recreate second context with the wrong prefix in opaq data node value */ |
| 247 | module = "module b {namespace urn:tests:b;prefix b;yang-version 1.1;" |
| 248 | "revision 2014-05-08;" |
| 249 | "anydata any {config false;}" |
| 250 | "}"; |
| 251 | RECREATE_CTX_WITH_MODULE(ctx2, module); |
| 252 | data1 = "<any xmlns=\"urn:tests:b\" xmlns:aa=\"urn:tests:b\"><x>aa:x</x></any>"; |
| 253 | data2 = "<any xmlns=\"urn:tests:b\" xmlns:bb=\"urn:tests:b\"><x>cc:x</x></any>"; |
| 254 | CHECK_PARSE_LYD_PARAM_CTX(UTEST_LYCTX, data1, LYD_PARSE_ONLY, tree1); |
| 255 | CHECK_PARSE_LYD_PARAM_CTX(ctx2, data2, LYD_PARSE_ONLY, tree2); |
| 256 | assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, 0)); |
| 257 | lyd_free_all(tree1); |
| 258 | lyd_free_all(tree2); |
| 259 | |
| 260 | /* clean up */ |
| 261 | ly_ctx_destroy(ctx2, NULL); |
| 262 | _UC->in = NULL; |
| 263 | } |
| 264 | |
| 265 | static void |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 266 | test_dup(void **state) |
| 267 | { |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 268 | struct lyd_node *tree1, *tree2; |
| 269 | const char *result; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 270 | const char *data; |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 271 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 272 | data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>"; |
| 273 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 274 | assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, LYD_DUP_RECURSIVE, &tree2)); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 275 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 276 | lyd_free_all(tree1); |
| 277 | lyd_free_all(tree2); |
| 278 | |
| 279 | data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>"; |
| 280 | result = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b></l1>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 281 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 282 | assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, 0, &tree2)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 283 | lyd_free_all(tree1); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 284 | CHECK_PARSE_LYD(result, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 285 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 286 | lyd_free_all(tree1); |
| 287 | lyd_free_all(tree2); |
| 288 | |
| 289 | data = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>"; |
| 290 | result = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 291 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 292 | assert_int_equal(LY_SUCCESS, lyd_dup_siblings(tree1, NULL, LYD_DUP_RECURSIVE, &tree2)); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 293 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, tree2->next, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 294 | lyd_free_all(tree2); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 295 | assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1->next, NULL, LYD_DUP_RECURSIVE, &tree2)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 296 | lyd_free_all(tree1); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 297 | CHECK_PARSE_LYD(result, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 298 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 299 | lyd_free_all(tree2); |
| 300 | |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 301 | assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1->next, NULL, 0, &tree2)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 302 | lyd_free_all(tree1); |
| 303 | result = "<l2 xmlns=\"urn:tests:a\"/>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 304 | CHECK_PARSE_LYD_PARAM(result, LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree1); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 305 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 306 | lyd_free_all(tree1); |
| 307 | lyd_free_all(tree2); |
| 308 | |
| 309 | data = "<any xmlns=\"urn:tests:a\"><c><a>a</a></c></any>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 310 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 311 | assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1, NULL, 0, &tree2)); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 312 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 313 | lyd_free_all(tree1); |
| 314 | lyd_free_all(tree2); |
| 315 | |
| 316 | data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 317 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 318 | assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner *)((struct lyd_node_inner *)tree1->next)->child)->child, NULL, |
| 319 | LYD_DUP_WITH_PARENTS, &tree2)); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 320 | int unsigned flag = LYS_CONFIG_R | LYS_SET_ENUM; |
| 321 | |
| 322 | CHECK_LYSC_NODE(tree2->schema, NULL, 0, flag, 1, "x", 1, LYS_LEAF, 1, 0, NULL, 0); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 323 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, (struct lyd_node *)tree2->parent->parent, |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 324 | LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 325 | lyd_free_all(tree1); |
| 326 | lyd_free_all(tree2); |
| 327 | |
| 328 | data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 329 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 330 | assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner *)tree1)->child->prev, NULL, |
| 331 | LYD_DUP_WITH_PARENTS, &tree2)); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 332 | flag = LYS_CONFIG_W | LYS_SET_ENUM; |
| 333 | CHECK_LYSC_NODE(tree2->schema, NULL, 0, flag, 1, "c", 0, LYS_LEAF, 1, 0, NULL, 0); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 334 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, (struct lyd_node *)tree2->parent, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 335 | lyd_free_all(tree1); |
| 336 | lyd_free_all(tree2); |
| 337 | |
| 338 | data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 339 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 340 | assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1->next, NULL, 0, &tree2)); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 341 | assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner *)((struct lyd_node_inner *)tree1->next)->child)->child, |
| 342 | (struct lyd_node_inner *)tree2, LYD_DUP_WITH_PARENTS, NULL)); |
Michal Vasko | 2612319 | 2020-11-09 21:02:34 +0100 | [diff] [blame] | 343 | assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, tree2, LYD_COMPARE_FULL_RECURSION)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 344 | lyd_free_all(tree1); |
| 345 | lyd_free_all(tree2); |
| 346 | |
| 347 | /* invalid */ |
| 348 | data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 349 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 350 | assert_int_equal(LY_EINVAL, lyd_dup_single(((struct lyd_node_inner *)tree1)->child->prev, |
| 351 | (struct lyd_node_inner *)tree1->next, LYD_DUP_WITH_PARENTS, NULL)); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 352 | lyd_free_all(tree1); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 353 | } |
| 354 | |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 355 | static void |
| 356 | test_target(void **state) |
| 357 | { |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 358 | const struct lyd_node_term *term; |
| 359 | struct lyd_node *tree; |
| 360 | struct lyxp_expr *exp; |
| 361 | struct ly_path *path; |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 362 | const char *path_str = "/a:l2[2]/c/d[3]"; |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 363 | const char *data = |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 364 | "<l2 xmlns=\"urn:tests:a\"><c>" |
| 365 | " <d>a</d>" |
| 366 | " </c></l2>" |
| 367 | "<l2 xmlns=\"urn:tests:a\"><c>" |
| 368 | " <d>a</d>" |
| 369 | " <d>b</d>" |
| 370 | " <d>b</d>" |
| 371 | " <d>c</d>" |
| 372 | "</c></l2>" |
| 373 | "<l2 xmlns=\"urn:tests:a\"><c>" |
| 374 | "</c></l2>"; |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 375 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 376 | CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree); |
| 377 | assert_int_equal(LY_SUCCESS, ly_path_parse(UTEST_LYCTX, NULL, path_str, strlen(path_str), LY_PATH_BEGIN_EITHER, LY_PATH_LREF_FALSE, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 378 | LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp)); |
Radek Krejci | d5d3743 | 2021-03-12 13:46:40 +0100 | [diff] [blame] | 379 | assert_int_equal(LY_SUCCESS, ly_path_compile(UTEST_LYCTX, NULL, NULL, NULL, exp, LY_PATH_LREF_FALSE, LY_PATH_OPER_INPUT, |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 380 | LY_PATH_TARGET_SINGLE, LY_PREF_JSON, NULL, NULL, &path)); |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 381 | term = lyd_target(path, tree); |
| 382 | |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 383 | const int unsigned flag = LYS_CONFIG_R | LYS_SET_ENUM | LYS_ORDBY_SYSTEM; |
| 384 | |
| 385 | CHECK_LYSC_NODE(term->schema, NULL, 0, flag, 1, "d", 0, LYS_LEAFLIST, 1, 0, NULL, 0); |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 386 | assert_string_equal(LYD_CANON_VALUE(term), "b"); |
| 387 | assert_string_equal(LYD_CANON_VALUE(term->prev), "b"); |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 388 | |
| 389 | lyd_free_all(tree); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 390 | ly_path_free(UTEST_LYCTX, path); |
| 391 | lyxp_expr_free(UTEST_LYCTX, exp); |
Michal Vasko | 38c2ba7 | 2020-07-27 14:46:59 +0200 | [diff] [blame] | 392 | } |
| 393 | |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 394 | static void |
| 395 | test_list_pos(void **state) |
| 396 | { |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 397 | const char *data; |
| 398 | struct lyd_node *tree; |
| 399 | |
| 400 | data = "<bar xmlns=\"urn:tests:a\">test</bar>" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 401 | "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b></l1>" |
| 402 | "<l1 xmlns=\"urn:tests:a\"><a>two</a><b>two</b></l1>" |
| 403 | "<foo xmlns=\"urn:tests:a\">test</foo>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 404 | assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 405 | assert_int_equal(0, lyd_list_pos(tree)); |
| 406 | assert_int_equal(1, lyd_list_pos(tree->next)); |
| 407 | assert_int_equal(2, lyd_list_pos(tree->next->next)); |
| 408 | assert_int_equal(0, lyd_list_pos(tree->next->next->next)); |
| 409 | lyd_free_all(tree); |
| 410 | |
| 411 | data = "<ll xmlns=\"urn:tests:a\">one</ll>" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 412 | "<ll xmlns=\"urn:tests:a\">two</ll>" |
| 413 | "<ll xmlns=\"urn:tests:a\">three</ll>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 414 | assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 415 | assert_int_equal(1, lyd_list_pos(tree)); |
| 416 | assert_int_equal(2, lyd_list_pos(tree->next)); |
| 417 | assert_int_equal(3, lyd_list_pos(tree->next->next)); |
| 418 | lyd_free_all(tree); |
| 419 | |
| 420 | data = "<ll xmlns=\"urn:tests:a\">one</ll>" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 421 | "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b></l1>" |
| 422 | "<ll xmlns=\"urn:tests:a\">two</ll>" |
| 423 | "<l1 xmlns=\"urn:tests:a\"><a>two</a><b>two</b></l1>" |
| 424 | "<ll xmlns=\"urn:tests:a\">three</ll>" |
| 425 | "<l1 xmlns=\"urn:tests:a\"><a>three</a><b>three</b></l1>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 426 | assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 427 | assert_string_equal("l1", tree->schema->name); |
| 428 | assert_int_equal(1, lyd_list_pos(tree)); |
| 429 | assert_int_equal(2, lyd_list_pos(tree->next)); |
| 430 | assert_int_equal(3, lyd_list_pos(tree->next->next)); |
| 431 | assert_string_equal("ll", tree->next->next->next->schema->name); |
| 432 | assert_int_equal(1, lyd_list_pos(tree->next->next->next)); |
| 433 | assert_int_equal(2, lyd_list_pos(tree->next->next->next->next)); |
| 434 | assert_int_equal(3, lyd_list_pos(tree->next->next->next->next->next)); |
| 435 | lyd_free_all(tree); |
Radek Krejci | ca98914 | 2020-11-05 11:32:22 +0100 | [diff] [blame] | 436 | } |
| 437 | |
Radek Krejci | 4233f9b | 2020-11-05 12:38:35 +0100 | [diff] [blame] | 438 | static void |
| 439 | test_first_sibling(void **state) |
| 440 | { |
Radek Krejci | 4233f9b | 2020-11-05 12:38:35 +0100 | [diff] [blame] | 441 | const char *data; |
| 442 | struct lyd_node *tree; |
| 443 | struct lyd_node_inner *parent; |
| 444 | |
| 445 | data = "<bar xmlns=\"urn:tests:a\">test</bar>" |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 446 | "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b><c>one</c></l1>" |
| 447 | "<foo xmlns=\"urn:tests:a\">test</foo>"; |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 448 | assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); |
Radek Krejci | 4233f9b | 2020-11-05 12:38:35 +0100 | [diff] [blame] | 449 | assert_ptr_equal(tree, lyd_first_sibling(tree->next)); |
| 450 | assert_ptr_equal(tree, lyd_first_sibling(tree)); |
| 451 | assert_ptr_equal(tree, lyd_first_sibling(tree->prev)); |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 452 | parent = (struct lyd_node_inner *)tree->next; |
Radek Krejci | 4233f9b | 2020-11-05 12:38:35 +0100 | [diff] [blame] | 453 | assert_int_equal(LYS_LIST, parent->schema->nodetype); |
| 454 | assert_ptr_equal(parent->child, lyd_first_sibling(parent->child->next)); |
| 455 | assert_ptr_equal(parent->child, lyd_first_sibling(parent->child)); |
| 456 | assert_ptr_equal(parent->child, lyd_first_sibling(parent->child->prev)); |
| 457 | lyd_free_all(tree); |
Radek Krejci | 4233f9b | 2020-11-05 12:38:35 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 460 | int |
| 461 | main(void) |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 462 | { |
| 463 | const struct CMUnitTest tests[] = { |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 464 | UTEST(test_compare, setup), |
aPiecek | 2425220 | 2021-03-30 12:23:32 +0200 | [diff] [blame] | 465 | UTEST(test_compare_diff_ctx, setup), |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 466 | UTEST(test_dup, setup), |
| 467 | UTEST(test_target, setup), |
| 468 | UTEST(test_list_pos, setup), |
| 469 | UTEST(test_first_sibling, setup), |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 470 | }; |
| 471 | |
| 472 | return cmocka_run_group_tests(tests, NULL, NULL); |
| 473 | } |