Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file utests.h |
| 3 | * @author Radek Iša <isa@cesnet.cz> |
| 4 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 5 | * @brief this file contains macros for simplification test writing |
| 6 | * |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 7 | * Copyright (c) 2021 CESNET, z.s.p.o. |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 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 | */ |
| 15 | |
| 16 | #ifndef _UTESTS_H_ |
| 17 | #define _UTESTS_H_ |
| 18 | |
| 19 | #define _POSIX_C_SOURCE 200809L /* strdup */ |
| 20 | |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 21 | #include <setjmp.h> |
| 22 | #include <stdarg.h> |
| 23 | #include <stddef.h> |
| 24 | |
| 25 | #include <cmocka.h> |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 26 | |
| 27 | #include <string.h> |
| 28 | |
| 29 | #include "libyang.h" |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 30 | #include "plugins_types.h" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 31 | #include "tests/config.h" |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 32 | #include "tree_schema_internal.h" |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * TESTS OVERVIEW |
| 36 | * |
| 37 | * To include utest's environment, just include "utests.h" in the test's source |
| 38 | * code. In case it is the main source code for a cmocka test group (there is a |
| 39 | * main() function), define _UTEST_MAIN_ before including this header. |
| 40 | * |
| 41 | * TESTS VARIABLES |
| 42 | * |
| 43 | * Checking macros use internal storage to store various variables necessary |
| 44 | * during the checking. It is possible to access these variables using the |
| 45 | * following macros: |
| 46 | * |
| 47 | * UTEST_LYCTX - libyang context |
| 48 | * UTEST_IN - input handler |
| 49 | * UTEST_OUT - output handler |
| 50 | * |
| 51 | * All these variables are cleaned with test's teardown. |
| 52 | * |
| 53 | * TESTS SETUP |
| 54 | * |
| 55 | * CMocka's CMUnitTest list definition macros (cmoka_unit_test*()) are replaced |
| 56 | * by UTEST macro with possibility to specify own setup and teardown functions: |
| 57 | * |
| 58 | * UTEST(test_func) - only implicit setup and teardown functions are used |
| 59 | * UTEST(test_func, setup) - implicit teardown but own setup |
| 60 | * UTEST(test_func, setup, teardown) - both setup and teardown are test-specific |
| 61 | * |
| 62 | * Note that the tests environment always provide (and need) internal setup and |
| 63 | * teardown functions. In case the test-specific setup or teardown are used, they |
| 64 | * are supposed to include UTEST_SETUP at the setup beginning and UTEST_TEARDOWN |
| 65 | * at the teardown end. |
| 66 | * |
| 67 | * Libyang context is part of the prepared environment. To add a schema into the |
| 68 | * context (despite it is in the test-specific setup or in test function itself), |
| 69 | * use UTEST_ADD_MODULE macro. |
| 70 | * |
| 71 | * LOGGING |
| 72 | * |
| 73 | * There are 2 macros to check content of the log from the previously called |
| 74 | * libyang function. CHECK_LOG macro test only the last error message and path |
| 75 | * stored directly via logging callback. CHECK_LOG_CTX gets error message and |
| 76 | * path from the libyang context (in case the function does not store the error |
| 77 | * information into the libyang context, the message cannot be checked this way). |
| 78 | * libyang is set to store multiple error information, so multiple couples of |
| 79 | * error message and path can be provided to be checked (the first couple |
| 80 | * corresponds to the latest error). The macro also cleanups the errors list, so |
| 81 | * it is fine to check that there is no error after succeeding successful |
| 82 | * function call. |
| 83 | */ |
| 84 | |
| 85 | /** |
| 86 | * @brief Test's context to provide common storage for various variables. |
| 87 | */ |
| 88 | struct utest_context { |
| 89 | struct ly_ctx *ctx; /**< libyang context */ |
| 90 | |
| 91 | char *err_msg; /**< Directly logged error message */ |
| 92 | char *err_path; /**< Directly logged error path */ |
| 93 | |
| 94 | struct ly_in *in; /**< Input handler */ |
| 95 | struct ly_out *out; /**< Outpu handler */ |
| 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * @brief Shortcut to access utest_context. |
| 100 | */ |
| 101 | #define _UC ((struct utest_context *)*state) |
| 102 | |
| 103 | /** |
| 104 | * @brief libyang context provider. |
| 105 | */ |
| 106 | #define UTEST_LYCTX (_UC->ctx) |
| 107 | |
| 108 | /** |
| 109 | * @brief Context's input handler provider |
| 110 | */ |
| 111 | #define UTEST_IN (_UC->in) |
| 112 | |
| 113 | /** |
| 114 | * @brief Context's input handler provider |
| 115 | */ |
| 116 | #define UTEST_OUT (_UC->out) |
| 117 | |
| 118 | /** |
| 119 | * @brief Parse (and validate) data from the input handler as a YANG data tree. |
| 120 | * |
| 121 | * @param[in] INPUT The input data in the specified @p format to parse (and validate) |
| 122 | * @param[in] INPUT_FORMAT Format of the input data to be parsed. Can be 0 to try to detect format from the input handler. |
| 123 | * @param[in] PARSE_OPTIONS Options for parser, see @ref dataparseroptions. |
| 124 | * @param[in] VALIDATE_OPTIONS Options for the validation phase, see @ref datavalidationoptions. |
| 125 | * @param[in] OUT_STATUS expected return status |
| 126 | * @param[out] OUT_NODE Resulting data tree built from the input data. Note that NULL can be a valid result as a representation of an empty YANG data tree. |
| 127 | * The returned data are expected to be freed using LYD_TREE_DESTROY(). |
| 128 | */ |
| 129 | #define CHECK_PARSE_LYD_PARAM(INPUT, INPUT_FORMAT, PARSE_OPTIONS, VALIDATE_OPTIONS, OUT_STATUS, OUT_NODE) \ |
| 130 | assert_int_equal(OUT_STATUS, lyd_parse_data_mem(_UC->ctx, INPUT, INPUT_FORMAT, PARSE_OPTIONS, VALIDATE_OPTIONS, &OUT_NODE)); \ |
| 131 | if (OUT_STATUS == LY_SUCCESS) { \ |
| 132 | assert_non_null(OUT_NODE); \ |
| 133 | } else { \ |
| 134 | assert_null(OUT_NODE); \ |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @brief Check if lyd_node and his subnodes have correct values. Print lyd_node and his sunodes int o string in json or xml format. |
| 139 | * @param[in] NODE pointer to lyd_node |
| 140 | * @param[in] TEXT expected output string in json or xml format. |
| 141 | * @param[in] FORMAT format of input text. LYD_JSON, LYD_XML |
| 142 | * @param[in] PARAM options [Data printer flags](@ref dataprinterflags). |
| 143 | */ |
| 144 | #define CHECK_LYD_STRING_PARAM(NODE, TEXT, FORMAT, PARAM) \ |
| 145 | { \ |
| 146 | char *test; \ |
| 147 | lyd_print_mem(&test, NODE, FORMAT, PARAM); \ |
| 148 | assert_string_equal(test, TEXT); \ |
| 149 | free(test); \ |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * @brief Compare two lyd_node structure. Macro print lyd_node structure into string and then compare string. Print function use these two parameters. LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK; |
| 154 | * @param[in] NODE_1 pointer to lyd_node |
| 155 | * @param[in] NODE_2 pointer to lyd_node |
| 156 | */ |
| 157 | #define CHECK_LYD(NODE_1, NODE_2) \ |
| 158 | { \ |
| 159 | char *test_1; \ |
| 160 | char *test_2; \ |
| 161 | lyd_print_mem(&test_1, NODE_1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK); \ |
| 162 | lyd_print_mem(&test_2, NODE_2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK); \ |
| 163 | assert_string_equal(test_1, test_2); \ |
| 164 | free(test_1); \ |
| 165 | free(test_2); \ |
| 166 | } |
| 167 | |
| 168 | /* |
| 169 | * SUPPORT MACROS |
| 170 | */ |
| 171 | |
| 172 | /** |
| 173 | * @brief Internal macro witch assert that two given string are equal or are both null. |
| 174 | * |
| 175 | * @param[in] STRING string to check |
| 176 | * @param[in] TEXT string to compare |
| 177 | */ |
| 178 | #define CHECK_STRING(STRING, TEXT)\ |
| 179 | if (TEXT == NULL) { \ |
| 180 | assert_null(STRING); \ |
| 181 | } else { \ |
| 182 | assert_non_null(STRING); \ |
| 183 | assert_string_equal(STRING, TEXT); \ |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * @brief Internal macro witch assert that pointer is null when flag is 0. |
| 188 | * |
| 189 | * @param[in] POINTER pointer to check |
| 190 | * @param[in] FLAG 0 -> pointer is NULL, 1 -> pointer is not null |
| 191 | */ |
| 192 | #define CHECK_POINTER(POINTER, FLAG) \ |
| 193 | assert_true(FLAG == 0 ? POINTER == NULL : POINTER != NULL) |
| 194 | |
| 195 | /** |
| 196 | * @brief Internal macro check size of [sized array](@ref sizedarrays)'s |
| 197 | * |
| 198 | * @param[in] ARRAY pointer to [sized array](@ref sizedarrays) |
| 199 | * @param[in] SIZE expected [sized array](@ref sizedarrays) size of array |
| 200 | */ |
| 201 | #define CHECK_ARRAY(ARRAY, SIZE) \ |
| 202 | assert_true((SIZE == 0) ? \ |
| 203 | (ARRAY == NULL) : \ |
| 204 | (ARRAY != NULL && SIZE == LY_ARRAY_COUNT(ARRAY))); |
| 205 | |
| 206 | /* |
| 207 | * LIBYANG NODE CHECKING |
| 208 | */ |
| 209 | |
| 210 | /** |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 211 | * @brief check compileted type |
| 212 | * @param[in] NODE pointer to lysc_type value |
| 213 | * @param[in] TYPE expected type [LY_DATA_TYPE](@ref LY_DATA_TYPE) |
| 214 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 215 | */ |
| 216 | #define CHECK_LYSC_TYPE(NODE, TYPE, EXTS) \ |
| 217 | assert_non_null(NODE); \ |
| 218 | assert_int_equal((NODE)->basetype, TYPE); \ |
| 219 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 220 | assert_ptr_equal((NODE)->plugin, &(ly_builtin_type_plugins[TYPE])) |
| 221 | |
| 222 | /* @brief check compileted numeric type |
| 223 | * @param[in] NODE pointer to lysc_type_num value |
| 224 | * @param[in] TYPE expected type [LY_DATA_TYPE](@ref LY_DATA_TYPE) |
| 225 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 226 | * @warning only integer types INT, UINT, NUM |
| 227 | */ |
| 228 | #define CHECK_LYSC_TYPE_NUM(NODE, TYPE, EXTS, RANGE) \ |
| 229 | CHECK_LYSC_TYPE(NODE, TYPE, EXTS);\ |
| 230 | CHECK_POINTER((NODE)->range, RANGE) |
| 231 | |
| 232 | /* @brief check compiled string type |
| 233 | * @param[in] NODE pointer to lysc_type_num value |
| 234 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 235 | * @param[in] LENGTH 0 -> node dosnt have length limitation, 1 -> node have length limitation |
| 236 | * @param[in] PATTERNS expected number of patterns [sized array](@ref sizedarrays) |
| 237 | * @warning only integer types INT, UINT, NUM |
| 238 | */ |
| 239 | #define CHECK_LYSC_TYPE_STR(NODE, EXTS, LENGTH, PATTERNS) \ |
| 240 | CHECK_LYSC_TYPE(NODE, LY_TYPE_STRING, EXTS); \ |
| 241 | CHECK_POINTER((NODE)->length, LENGTH); \ |
| 242 | CHECK_ARRAY((NODE)->patterns, PATTERNS) |
| 243 | |
Radek Iša | ded3105 | 2021-03-10 13:22:53 +0100 | [diff] [blame] | 244 | /* @brief check compiled bits type |
| 245 | * @param[in] NODE pointer to lysc_type_num value |
| 246 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 247 | * @param[in] BITS expected number of bits |
| 248 | * @warning only integer types INT, UINT, NUM |
| 249 | */ |
| 250 | #define CHECK_LYSC_TYPE_BITS(NODE, EXTS, BITS) \ |
| 251 | CHECK_LYSC_TYPE(NODE, LY_TYPE_BITS, EXTS); \ |
| 252 | CHECK_ARRAY((NODE)->bits, BITS) |
| 253 | |
Radek Iša | ded3105 | 2021-03-10 13:22:53 +0100 | [diff] [blame] | 254 | #define CHECK_LYSC_TYPE_BITENUM_ITEM(NODE, POSITION, DSC, EXTS, FLAGS, NAME, REF)\ |
| 255 | assert_non_null(NODE); \ |
| 256 | assert_int_equal((NODE)->position, POSITION); \ |
| 257 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 258 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 259 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 260 | CHECK_STRING((NODE)->name, NAME); \ |
| 261 | CHECK_STRING((NODE)->ref, REF) \ |
| 262 | |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 263 | /* @brief check range |
| 264 | * @param[in] NODE pointer to lysc_range value |
| 265 | * @param[in] DSC expected descriptin (string) |
| 266 | * @param[in] EAPPTAG expected string reprezenting error-app-tag value |
| 267 | * @param[in] EMSG expected string reprezenting error message |
| 268 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 269 | * @param[in] PARTS expected [sized array](@ref sizedarrays) number of rang limitations |
| 270 | * @param[in] REF expected reference |
| 271 | */ |
| 272 | #define CHECK_LYSC_RANGE(NODE, DSC, EAPPTAG, EMSG, EXTS, PARTS, REF) \ |
| 273 | assert_non_null(NODE); \ |
| 274 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 275 | CHECK_STRING((NODE)->eapptag, EAPPTAG); \ |
| 276 | CHECK_STRING((NODE)->emsg, EMSG); \ |
| 277 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 278 | CHECK_ARRAY((NODE)->parts, PARTS); \ |
| 279 | CHECK_STRING((NODE)->ref, REF) |
| 280 | |
| 281 | /* @brief check pattern |
| 282 | * @param[in] NODE pointer to lysc_pattern value |
| 283 | * @param[in] DSC expected descriptin (string) |
| 284 | * @param[in] EAPPTAG expected string reprezenting error-app-tag value |
| 285 | * @param[in] EMSG expected string reprezenting error message |
| 286 | * @param[in] EEXPR expected string reprezenting original, not compiled, regular expression |
| 287 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 288 | * @param[in] INVERTED if regular expression is inverted. |
| 289 | * @param[in] REF expected reference |
| 290 | */ |
| 291 | #define CHECK_LYSC_PATTERN(NODE, DSC, EAPPTAG, EMSG, EXPR, EXTS, INVERTED, REF) \ |
| 292 | assert_non_null(NODE); \ |
| 293 | assert_non_null((NODE)->code); \ |
| 294 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 295 | CHECK_STRING((NODE)->eapptag, EAPPTAG); \ |
| 296 | CHECK_STRING((NODE)->emsg, EMSG); \ |
| 297 | CHECK_STRING((NODE)->expr, EXPR); \ |
| 298 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 299 | assert_int_equal((NODE)->inverted, INVERTED); \ |
| 300 | CHECK_STRING((NODE)->ref, REF) |
| 301 | |
| 302 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 303 | * @brief assert that lysp_action_inout structure members are correct |
| 304 | * @param[in] NODE pointer to lysp_action_inout variable |
| 305 | * @param[in] DATA 0 -> check if pointer to data is NULL, 1 -> check if pointer to data is not null |
| 306 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extens list |
| 307 | * @param[in] GROUPINGS expected [sized array](@ref sizedarrays) size of grouping list |
| 308 | * @param[in] MUSTS expected [sized array](@ref sizedarrays) size of must restriction list |
| 309 | * @param[in] NODETYPE node type. LYS_INPUT or LYS_OUTPUT |
| 310 | * @param[in] PARENT 0 -> check if node is root, 1 -> check if node is not root |
| 311 | * @param[in] TYPEDEFS expected [sized array](@ref sizedarrays) size of typedefs list |
| 312 | */ |
| 313 | #define CHECK_LYSP_ACTION_INOUT(NODE, DATA, EXTS, GROUPINGS, MUSTS, NODETYPE, PARENT, TYPEDEFS) \ |
| 314 | assert_non_null(NODE); \ |
Radek Krejci | 01180ac | 2021-01-27 08:48:22 +0100 | [diff] [blame] | 315 | CHECK_POINTER((NODE)->child, DATA); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 316 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 317 | CHECK_POINTER((NODE)->groupings, GROUPINGS); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 318 | CHECK_ARRAY((NODE)->musts, MUSTS); \ |
| 319 | assert_int_equal((NODE)->nodetype, NODETYPE); \ |
| 320 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 321 | CHECK_ARRAY((NODE)->typedefs, TYPEDEFS); |
| 322 | |
| 323 | /** |
| 324 | * @brief assert that lysp_action structure members are correct |
| 325 | * @param[in] NODE pointer to lysp_action variable |
| 326 | * @param[in] DSC expected description |
| 327 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of extension list |
| 328 | * @param[in] FLAGS expected [schema node flags](@ref snodeflags) |
| 329 | * @param[in] GROUPINGS expected [sized array](@ref sizedarrays) size of grouping list |
| 330 | * @param[in] IFFEATURES expected [sized array](@ref sizedarrays) size of if-feature expressions list |
| 331 | * @param[in] INPUT_* ::LYSP_ACTION_INOUT_CHECK |
| 332 | * @param[in] NAME expected name |
| 333 | * @param[in] NODETYPE node type. LYS_RPC or LYS_ACTION |
| 334 | * @param[in] OUTPUT_* ::LYSP_ACTION_INOUT_CHECK |
| 335 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 336 | * @param[in] REF expected reference |
| 337 | * @param[in] TYPEDEFS expected [sized array](@ref sizedarrays) size of list of typedefs |
| 338 | */ |
| 339 | #define CHECK_LYSP_ACTION(NODE, DSC, EXTS, FLAGS, GROUPINGS, IFFEATURES, \ |
| 340 | INPUT_DATA, INPUT_EXTS, INPUT_GROUPINGS, INPUT_MUSTS, \ |
| 341 | INPUT_PARENT, INPUT_TYPEDEFS, \ |
| 342 | NAME, NODETYPE, \ |
| 343 | OUTPUT_DATA, OUTPUT_EXTS, OUTPUT_GROUPINGS, OUTPUT_MUSTS, \ |
| 344 | OUTPUT_PARENT, OUTPUT_TYPEDEFS, \ |
| 345 | PARENT, REF, TYPEDEFS) \ |
| 346 | assert_non_null(NODE); \ |
| 347 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 348 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 349 | assert_int_equal((NODE)->flags, FLAGS); \ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 350 | CHECK_POINTER((NODE)->groupings, GROUPINGS); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 351 | CHECK_ARRAY((NODE)->iffeatures, IFFEATURES); \ |
| 352 | CHECK_LYSP_ACTION_INOUT(&((NODE)->input), INPUT_DATA, INPUT_EXTS, INPUT_GROUPINGS, \ |
| 353 | INPUT_MUSTS, LYS_INPUT, INPUT_PARENT, INPUT_TYPEDEFS); \ |
| 354 | assert_string_equal((NODE)->name, NAME); \ |
| 355 | assert_int_equal((NODE)->nodetype, NODETYPE); \ |
| 356 | CHECK_LYSP_ACTION_INOUT(&((NODE)->output), OUTPUT_DATA, OUTPUT_EXTS, OUTPUT_GROUPINGS, \ |
| 357 | OUTPUT_MUSTS, LYS_OUTPUT, OUTPUT_PARENT, OUTPUT_TYPEDEFS); \ |
| 358 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 359 | CHECK_STRING((NODE)->ref, REF); \ |
| 360 | CHECK_ARRAY((NODE)->typedefs, TYPEDEFS) \ |
| 361 | |
| 362 | /** |
| 363 | * @brief assert that lysp_when structure members are correct |
| 364 | * @param[in] NODE pointer to lysp_when variable |
| 365 | * @param[in] COND expected string specifid condition |
| 366 | * @param[in] DSC expected string description statement |
| 367 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of extension array |
| 368 | * @param[in] REF expected string reference |
| 369 | */ |
| 370 | #define CHECK_LYSP_WHEN(NODE, COND, DSC, EXTS, REF) \ |
| 371 | assert_non_null(NODE); \ |
| 372 | assert_string_equal((NODE)->cond, COND); \ |
| 373 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 374 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 375 | if (REF == NULL) { \ |
| 376 | assert_null((NODE)->ref); \ |
| 377 | } else { \ |
| 378 | assert_non_null((NODE)->ref); \ |
| 379 | assert_string_equal((NODE)->ref, REF); \ |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * @brief assert that lysp_restr structure members are correct |
| 384 | * @param[in] NODE pointer to lysp_restr variable |
| 385 | * @param[in] ARG_STR expected string. The restriction expression/value |
| 386 | * @param[in] DSC expected descrition |
| 387 | * @param[in] EAPPTAG expected string reprezenting error-app-tag value |
| 388 | * @param[in] EMSG expected string reprezenting error message |
| 389 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of extension array |
| 390 | * @param[in] REF expected reference |
| 391 | */ |
| 392 | |
| 393 | #define CHECK_LYSP_RESTR(NODE, ARG_STR, DSC, EAPPTAG, EMSG, EXTS, REF) \ |
| 394 | assert_non_null(NODE); \ |
| 395 | assert_non_null((NODE)->arg.mod); \ |
| 396 | assert_string_equal((NODE)->arg.str, ARG_STR); \ |
| 397 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 398 | CHECK_STRING((NODE)->eapptag, EAPPTAG); \ |
| 399 | CHECK_STRING((NODE)->emsg, EMSG); \ |
| 400 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 401 | CHECK_STRING((NODE)->ref, REF); |
| 402 | |
| 403 | /** |
| 404 | * @brief assert that lysp_import structure members are correct |
| 405 | * @param[in] NODE pointer to lysp_import variable |
| 406 | * @param[in] DSC expected description or NULL |
| 407 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of extensions |
| 408 | * @param[in] NAME expected name of imported module |
| 409 | * @param[in] PREFIX expected prefix for the data from the imported schema |
| 410 | * @param[in] REF expected reference |
| 411 | * @prame[in] REV expected reprezenting date in format "11-10-2020" |
| 412 | */ |
| 413 | #define CHECK_LYSP_IMPORT(NODE, DSC, EXTS, NAME, PREFIX, REF, REV) \ |
| 414 | assert_non_null(NODE); \ |
| 415 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 416 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 417 | /*assert_non_null((NODE)->module); // ?? it is mandatory but in some test it doesnt work */ \ |
| 418 | assert_string_equal((NODE)->name, NAME); \ |
| 419 | assert_string_equal((NODE)->prefix, PREFIX); \ |
| 420 | CHECK_STRING((NODE)->ref, REF); \ |
| 421 | CHECK_STRING((NODE)->rev, REV); \ |
| 422 | |
| 423 | /** |
| 424 | * @brief assert that lysp_ext structure members are correct |
| 425 | * @param[in] NODE pointer to lysp_ext_instance variable |
Radek Krejci | 9f87b0c | 2021-03-05 14:45:26 +0100 | [diff] [blame] | 426 | * @param[in] ARGNAME expected argument name |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 427 | * @param[in] COMPILED 0 -> compiled data dosnt exists, 1 -> compiled data exists |
| 428 | * @param[in] DSC expected string reprezent description |
| 429 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of extension instances |
| 430 | * @param[in] FLAGS expected LYS_STATUS_* and LYS_YINELEM_* values (@ref snodeflags) |
| 431 | * @param[in] NAME expected name |
| 432 | * @param[in] REF expected ref |
| 433 | */ |
Radek Krejci | 9f87b0c | 2021-03-05 14:45:26 +0100 | [diff] [blame] | 434 | #define CHECK_LYSP_EXT(NODE, ARGNAME, COMPILED, DSC, EXTS, FLAGS, NAME, REF) \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 435 | assert_non_null(NODE); \ |
Radek Krejci | 9f87b0c | 2021-03-05 14:45:26 +0100 | [diff] [blame] | 436 | CHECK_STRING((NODE)->argname, ARGNAME); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 437 | CHECK_POINTER((NODE)->compiled, COMPILED); \ |
| 438 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 439 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 440 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 441 | assert_string_equal((NODE)->name, NAME); \ |
| 442 | CHECK_STRING((NODE)->ref, REF); |
| 443 | |
| 444 | /** |
| 445 | * @brief assert that lysp_ext_instance structure members are correct |
| 446 | * @param[in] NODE pointer to lysp_ext_instance variable |
| 447 | * @param[in] ARGUMENT expected optional value of the extension's argument |
| 448 | * @param[in] CHILD 0 -> node doesnt have child, 1 -> node have children |
Radek Krejci | ab43086 | 2021-03-02 20:13:40 +0100 | [diff] [blame] | 449 | * @param[in] PARENT_STMT expected value identifying placement of the extension instance |
| 450 | * @param[in] PARENT_STMT_INDEX expected indentifi index |
Michal Vasko | fc2cd07 | 2021-02-24 13:17:17 +0100 | [diff] [blame] | 451 | * @param[in] FORMAT expected format |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 452 | */ |
Radek Krejci | 85ac831 | 2021-03-03 20:21:33 +0100 | [diff] [blame] | 453 | #define CHECK_LYSP_EXT_INSTANCE(NODE, ARGUMENT, CHILD, PARENT_STMT, PARENT_STMT_INDEX, NAME, FORMAT) \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 454 | assert_non_null(NODE); \ |
| 455 | CHECK_STRING((NODE)->argument, ARGUMENT); \ |
| 456 | CHECK_POINTER((NODE)->child, CHILD); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 457 | /*assert_int_equal((NODE)->flags, LYS_INTERNAL);*/ \ |
Radek Krejci | ab43086 | 2021-03-02 20:13:40 +0100 | [diff] [blame] | 458 | assert_int_equal((NODE)->parent_stmt, PARENT_STMT); \ |
| 459 | assert_int_equal((NODE)->parent_stmt_index, PARENT_STMT_INDEX); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 460 | assert_string_equal((NODE)->name, NAME); \ |
Michal Vasko | fc2cd07 | 2021-02-24 13:17:17 +0100 | [diff] [blame] | 461 | assert_int_equal((NODE)->format, FORMAT); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 462 | |
| 463 | /** |
| 464 | * @brief assert that lysp_stmt structure members are correct |
| 465 | * @param[in] NODE pointer to lysp_stmt variable |
| 466 | * @param[in] ARG expected statemet argumet |
| 467 | * @param[in] CHILD 0 -> node doesnt have child, 1 -> node have children |
| 468 | * @param[in] FLAGS expected statement flags, can be set to LYS_YIN_ATTR |
| 469 | * @param[in] KW expected numeric respresentation of the stmt value |
| 470 | * @param[in] NEXT 0 -> pointer is NULL, 1 -> pointer is not null |
| 471 | * @param[in] STMS expected identifier of the statement |
| 472 | */ |
| 473 | #define CHECK_LYSP_STMT(NODE, ARG, CHILD, FLAGS, KW, NEXT, STMT) \ |
| 474 | assert_non_null(NODE); \ |
| 475 | CHECK_STRING((NODE)->arg, ARG); \ |
| 476 | CHECK_POINTER((NODE)->child, CHILD); \ |
| 477 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 478 | assert_int_equal((NODE)->kw, KW); \ |
| 479 | CHECK_POINTER((NODE)->next, NEXT); \ |
| 480 | assert_string_equal((NODE)->stmt, STMT); \ |
| 481 | |
| 482 | /** |
| 483 | * @brief assert that lysp_type_enum structure members are correct |
| 484 | * @param[in] NODE pointer to lysp_type_enum variable |
| 485 | * @param[in] DSC expected description |
| 486 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 487 | * @param[in] FLAGS only LYS_STATUS_ and LYS_SET_VALUE values are allowed |
| 488 | * @param[in] IFFEATURES expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 489 | * @param[in] NAME expected name |
| 490 | * @param[in] REF expected reference statement |
| 491 | * @param[in] VALUE expected enum's value or bit's position |
| 492 | */ |
| 493 | #define CHECK_LYSP_TYPE_ENUM(NODE, DSC, EXTS, FLAGS, IFFEATURES, NAME, REF, VALUE) \ |
| 494 | assert_non_null(NODE); \ |
| 495 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 496 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 497 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 498 | CHECK_ARRAY((NODE)->iffeatures, IFFEATURES); \ |
| 499 | CHECK_STRING((NODE)->name, NAME); \ |
| 500 | CHECK_STRING((NODE)->ref, REF); \ |
| 501 | assert_int_equal(VALUE, (NODE)->value); |
| 502 | |
| 503 | /** |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 504 | * @brief assert that lysp_type_enum structure members are correct |
| 505 | * @param[in] NODE pointer to lysp_type variable |
| 506 | * @param[in] BASES expected [sized array](@ref sizedarrays) size of list of indentifiers |
| 507 | * @param[in] BITS expected [sized array](@ref sizedarrays) size of list of bits |
| 508 | * @param[in] COMPILED 0 -> pointer to compiled type is null, 1 -> pointer to compilet type is valid |
| 509 | * @param[in] ENUMS expected [sized array](@ref sizedarrays) size of list of enums-stmts |
| 510 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of extension instances |
| 511 | * @param[in] FLAGS expected flags |
| 512 | * @param[in] FRACTION_DIGITS expected number of fraction digits decimal64 |
| 513 | * @param[in] LENGTH expected 0 -> there isnt any restriction on length, 1 -> type is restricted on length (string, binary) |
| 514 | * @param[in] NAME expected name of type |
| 515 | * @param[in] PATH 0 -> no pointer to parsed path, 1 -> pointer to parsed path is valid |
| 516 | * @param[in] PATTERNS expected [sized array](@ref sizedarrays) size of list of patterns for string |
| 517 | * @param[in] PMOD expected submodule where type is defined 0 -> pointer is null, 1 -> pointer is not null |
| 518 | * @param[in] RANGE expected [sized array](@ref sizedarrays) size of list of range restriction |
| 519 | * @param[in] REQUIRE_INSTANCE expected require instance flag |
| 520 | * @param[in] TYPES expected [sized array](@ref sizedarrays) size of list of sub-types |
| 521 | */ |
| 522 | #define CHECK_LYSP_TYPE(NODE, BASES, BITS, COMPILED, ENUMS, EXTS, FLAGS, FRACTIONS_DIGITS, \ |
| 523 | LENGTH, NAME, PATH, PATTERNS, PMOD, RANGE, REQUIRE_INSTANCE, TYPES) \ |
| 524 | assert_non_null(NODE);\ |
| 525 | CHECK_ARRAY((NODE)->bases, BASES); \ |
| 526 | CHECK_ARRAY((NODE)->bits, BITS); \ |
| 527 | CHECK_POINTER((NODE)->compiled, COMPILED); \ |
| 528 | CHECK_ARRAY((NODE)->enums, ENUMS); \ |
| 529 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 530 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 531 | assert_int_equal((NODE)->fraction_digits, FRACTIONS_DIGITS); \ |
| 532 | CHECK_POINTER((NODE)->length, LENGTH); \ |
| 533 | CHECK_STRING((NODE)->name, NAME); \ |
| 534 | CHECK_POINTER((NODE)->path, PATH); \ |
| 535 | CHECK_ARRAY((NODE)->patterns, PATTERNS); \ |
| 536 | CHECK_POINTER((NODE)->pmod, PMOD); \ |
| 537 | CHECK_POINTER((NODE)->range, RANGE); \ |
| 538 | assert_int_equal((NODE)->require_instance, REQUIRE_INSTANCE); \ |
| 539 | CHECK_ARRAY((NODE)->types , TYPES) |
| 540 | |
| 541 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 542 | * @brief assert that lysp_node structure members are correct |
| 543 | * @param[in] NODE pointer to lysp_node variable |
| 544 | * @param[in] DSC expected description statement |
| 545 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 546 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 547 | * @param[in] IFFEATURES expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 548 | * @param[in] NAME expected name |
| 549 | * @param[in] NEXT 0 pointer is null, 1 pointer is not null |
| 550 | * @param[in] NODETYPE node type LYS_UNKNOWN, LYS_CONTAINER, LYS_CHOICE, LYS_LEAF, LYS_LEAFLIST, |
| 551 | * LYS_LIST, LYS_ANYXML, LYS_ANYDATA, LYS_CASE, LYS_RPC, LYS_ACTION, LYS_NOTIF, |
| 552 | * LYS_USES, LYS_INPUT, LYS_OUTPUT, LYS_GROUPING, LYS_AUGMENT |
| 553 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 554 | * @param[in] REF expected reference statement |
| 555 | * @param[in] WHEN 0-> pointer is null, 1 -> pointer is not null |
| 556 | */ |
| 557 | #define CHECK_LYSP_NODE(NODE, DSC, EXTS, FLAGS, IFFEATURES, NAME, NEXT, NODETYPE, PARENT, REF, WHEN) \ |
| 558 | assert_non_null(NODE); \ |
| 559 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 560 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 561 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 562 | CHECK_ARRAY((NODE)->iffeatures, IFFEATURES); \ |
| 563 | CHECK_STRING((NODE)->name, NAME); \ |
| 564 | CHECK_POINTER((NODE)->next, NEXT); \ |
| 565 | assert_int_equal((NODE)->nodetype, NODETYPE); \ |
| 566 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 567 | CHECK_STRING((NODE)->ref, REF); \ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 568 | CHECK_POINTER(lysp_node_when((struct lysp_node *)NODE), WHEN); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 569 | |
| 570 | /** |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 571 | * @brief assert that lysp_node structure members are correct |
| 572 | * @param[in] NODE pointer to lysp_node variable |
| 573 | * @param[in] DSC expected description statement |
| 574 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 575 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 576 | * @param[in] IFFEATURES expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 577 | * @param[in] NAME expected name |
| 578 | * @param[in] NEXT 0 pointer is null, 1 pointer is not null |
| 579 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 580 | * @param[in] REF expected reference statement |
| 581 | * @param[in] WHEN 0-> pointer is null, 1 -> pointer is not null |
| 582 | * @param[in] MUSTS expected [sized array](@ref sizedarrays) size of list of must restriction |
| 583 | * @param[in] UNITS expected string reprezenting units |
| 584 | * @param[in] DFLT 0-> node dosn't have default value. 1 -> node have default value |
| 585 | */ |
| 586 | #define CHECK_LYSP_NODE_LEAF(NODE, DSC, EXTS, FLAGS, IFFEATURES, NAME, NEXT, \ |
| 587 | PARENT, REF, WHEN, MUSTS, UNITS, DFLT) \ |
| 588 | CHECK_LYSP_NODE(NODE, DSC, EXTS, FLAGS, IFFEATURES, NAME, NEXT, LYS_LEAF, PARENT, REF, WHEN); \ |
| 589 | CHECK_ARRAY((NODE)->musts, MUSTS); \ |
| 590 | CHECK_STRING((NODE)->units, UNITS); \ |
| 591 | CHECK_STRING((NODE)->dflt.str, DFLT); |
| 592 | |
| 593 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 594 | * @brief assert that lysc_notif structure members are correct |
| 595 | * @param[in] NODE pointer to lysp_notif variable |
| 596 | * @param[in] DATA 0 pointer is null, 1 pointer is not null |
| 597 | * @param[in] DSC expected description |
| 598 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 599 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 600 | * @param[in] MODULE 0 pointer is null, 1 pointer is not null |
| 601 | * @param[in] MUSTS expected [sized array](@ref sizedarrays) size of list of must restriction |
| 602 | * @param[in] NAME expected name |
| 603 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 604 | * @param[in] PRIV 0-> pointer is null, 1-> pointer is not null |
| 605 | * @param[in] REF expected reference |
| 606 | * @param[in] WHEN expected [sized array](@ref sizedarrays) size of list of pointers to when statements |
| 607 | */ |
| 608 | #define CHECK_LYSC_NOTIF(NODE, DATA, DSC, EXTS, FLAGS, MODULE, MUSTS, NAME, PARENT, PRIV, REF, WHEN) \ |
| 609 | assert_non_null(NODE); \ |
Radek Krejci | 01180ac | 2021-01-27 08:48:22 +0100 | [diff] [blame] | 610 | CHECK_POINTER((NODE)->child, DATA); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 611 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 612 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 613 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 614 | CHECK_POINTER((NODE)->module, MODULE); \ |
| 615 | CHECK_ARRAY((NODE)->musts, MUSTS); \ |
| 616 | assert_string_equal((NODE)->name, NAME); \ |
| 617 | assert_int_equal((NODE)->nodetype, LYS_NOTIF); \ |
| 618 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 619 | CHECK_POINTER((NODE)->priv, PRIV); \ |
| 620 | CHECK_STRING((NODE)->ref, REF); \ |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 621 | CHECK_ARRAY(lysc_node_when((const struct lysc_node *)NODE), WHEN); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 622 | |
| 623 | /** |
| 624 | * @brief assert that lysc_action_inout structure members are correct |
| 625 | * @param[in] NODE pointer to lysp_notif variable |
| 626 | * @param[in] DATA 0 pointer is null, 1 pointer is not null |
| 627 | * @param[in] MUST expected [sized array](@ref sizedarrays) size of list of must restrictions |
| 628 | * @param[in] NODETYPE LYS_INPUT or LYS_OUTPUT |
| 629 | */ |
| 630 | #define CHECK_LYSC_ACTION_INOUT(NODE, DATA, MUST, NODETYPE) \ |
| 631 | assert_non_null(NODE); \ |
Radek Krejci | 01180ac | 2021-01-27 08:48:22 +0100 | [diff] [blame] | 632 | CHECK_POINTER((NODE)->child, DATA); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 633 | CHECK_ARRAY((NODE)->musts, MUST); \ |
| 634 | assert_int_equal((NODE)->nodetype, NODETYPE); |
| 635 | |
| 636 | /** |
| 637 | * @brief assert that lysc_action structure members are correct |
| 638 | * @param[in] NODE pointer to lysp_action variable |
| 639 | * @param[in] DSC string description statement |
| 640 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 641 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 642 | * @param[in] INPUT_DATA 0 pointer is null, 1 pointer is not null |
| 643 | * @param[in] INPUT_MUST expected [sized array](@ref sizedarrays) size of input list of must restrictions |
| 644 | * @param[in] INPUT_EXTS expected [sized array](@ref sizedarrays) size of the input extension instances of input |
| 645 | * @param[in] MODULE 0 pointer is null, 1 pointer is not null |
| 646 | * @param[in] NAME expected name |
| 647 | * @param[in] NODETYPE LYS_RPC, LYS_ACTION |
| 648 | * @param[in] OUTPUT_DATA 0 pointer is null, 1 pointer is not null |
| 649 | * @param[in] OUTPUT_MUST expected [sized array](@ref sizedarrays) size of output list of must restrictions |
| 650 | * @param[in] OUTPUT_EXTS expected [sized array](@ref sizedarrays) size of the output extension instances of input |
| 651 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 652 | * @param[in] PRIV 0-> pointer is null, 1-> pointer is not null |
| 653 | * @param[in] REF expected reference |
| 654 | * @param[in] WHEN expected [sized array](@ref sizedarrays) size of list of pointers to when statements |
| 655 | */ |
| 656 | #define CHECK_LYSC_ACTION(NODE, DSC, EXTS, FLAGS, INPUT_DATA, INPUT_MUST, INPUT_EXTS, MODULE, NAME, NODETYPE, \ |
| 657 | OUTPUT_DATA, OUTPUT_MUST, OUTPUT_EXTS, PARENT, PRIV, REF, WHEN) \ |
| 658 | assert_non_null(NODE); \ |
| 659 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 660 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 661 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 662 | CHECK_LYSC_ACTION_INOUT(&(NODE)->input, INPUT_DATA, INPUT_MUST, LYS_INPUT); \ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 663 | CHECK_ARRAY((NODE)->input.exts, INPUT_EXTS); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 664 | CHECK_POINTER((NODE)->module, MODULE); \ |
| 665 | assert_string_equal((NODE)->name, NAME); \ |
| 666 | assert_int_equal((NODE)->nodetype, NODETYPE); \ |
| 667 | CHECK_LYSC_ACTION_INOUT(&(NODE)->output, OUTPUT_DATA, OUTPUT_MUST, LYS_OUTPUT); \ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 668 | CHECK_ARRAY((NODE)->output.exts, OUTPUT_EXTS); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 669 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 670 | CHECK_POINTER((NODE)->priv, PRIV); \ |
| 671 | CHECK_STRING((NODE)->ref, REF); \ |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 672 | CHECK_ARRAY(lysc_node_when((const struct lysc_node *)NODE), WHEN); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 673 | |
| 674 | /** |
| 675 | * @brief assert that lysc_node structure members are correct |
| 676 | * @param[in] NODE pointer to lysc_node variable |
| 677 | * @param[in] DSC expected description |
| 678 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 679 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 680 | * @param[in] MODULE 0 pointer is null, 1 pointer is not null |
| 681 | * @param[in] NAME expected name |
| 682 | * @param[in] NEXT 0 pointer is null, 1 pointer is not null |
| 683 | * @param[in] NODETYPE type of the node LYS_UNKNOWN, LYS_CONTAINER, LYS_CHOICE, LYS_LEAF, |
| 684 | * LYS_LEAFLIST, LYS_LIST, LYS_ANYXML, LYS_ANYDATA, LYS_CASE, LYS_RPC, |
| 685 | * LYS_ACTION, LYS_NOTIF, LYS_USES, LYS_INPUT, LYS_OUTPUT, LYS_GROUPING, |
| 686 | * LYS_AUGMENT |
| 687 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 688 | * @param[in] PRIV 0-> pointer is null, 1-> pointer is not null |
| 689 | * @param[in] REF expected reference |
| 690 | * @param[in] WHEN expected [sized array](@ref sizedarrays) size of list of pointers to when statements |
| 691 | */ |
| 692 | #define CHECK_LYSC_NODE(NODE, DSC, EXTS, FLAGS, MODULE, NAME, NEXT, NODETYPE, PARENT, PRIV, REF, WHEN) \ |
| 693 | assert_non_null(NODE); \ |
| 694 | CHECK_STRING((NODE)->dsc, DSC); \ |
| 695 | CHECK_ARRAY((NODE)->exts, EXTS); \ |
| 696 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 697 | CHECK_POINTER((NODE)->module, MODULE); \ |
| 698 | assert_string_equal((NODE)->name, NAME); \ |
| 699 | CHECK_POINTER((NODE)->next, NEXT); \ |
| 700 | assert_int_equal((NODE)->nodetype, NODETYPE); \ |
| 701 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 702 | assert_non_null((NODE)->prev); \ |
| 703 | CHECK_POINTER((NODE)->priv, PRIV); \ |
| 704 | CHECK_STRING((NODE)->ref, REF); \ |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 705 | CHECK_ARRAY(lysc_node_when((const struct lysc_node *)NODE), WHEN); |
| 706 | |
| 707 | /** |
| 708 | * @brief assert that lysc_node_leaf structure members are correct |
| 709 | * @param[in] NODE pointer to lysc_node variable |
| 710 | * @param[in] DSC expected description |
| 711 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 712 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 713 | * @param[in] MODULE 0 pointer is null, 1 pointer is not null |
| 714 | * @param[in] NAME expected name |
| 715 | * @param[in] NEXT 0 pointer is null, 1 pointer is not null |
| 716 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 717 | * @param[in] PRIV 0-> pointer is null, 1-> pointer is not null |
| 718 | * @param[in] REF expected reference |
Radek Iša | a76902f | 2021-03-29 08:52:51 +0200 | [diff] [blame^] | 719 | * @param[in] ACTIONS 1 if is set pointer to structure lysc_node_action other 0 |
| 720 | * @param[in] CHILD 1 if is set pointer to child other 0 |
| 721 | * @param[in] MAX possible maximum elements in list |
| 722 | * @param[in] MIN possible minimum elements in list |
| 723 | * @param[in] MUSTS [sized array](@ref sizedarrays) number of must node elements in array |
| 724 | * @param[in] NOTIFS 1 if is set pointer to any notifs node |
| 725 | * @param[in] UNIQUES [sized array](@ref sizedarrays) number of unique nodes element in array |
| 726 | * @param[in] WHEN [sized array](@ref sizedarrays) size of when node array |
| 727 | */ |
| 728 | #define CHECK_LYSC_NODE_LIST(NODE, DSC, EXTS, FLAGS, MODULE, NAME, NEXT, \ |
| 729 | PARENT, PRIV, REF, ACTIONS, CHILD, MAX, MIN, MUSTS, NOTIFS, UNIQUES, WHEN) \ |
| 730 | CHECK_LYSC_NODE(NODE, DSC, EXTS, FLAGS, MODULE, NAME, NEXT, LYS_LIST, PARENT, PRIV, REF, WHEN); \ |
| 731 | CHECK_POINTER((NODE)->actions, ACTIONS); \ |
| 732 | CHECK_POINTER((NODE)->child, CHILD); \ |
| 733 | assert_int_equal((NODE)->max, MAX); \ |
| 734 | assert_int_equal((NODE)->min, MIN); \ |
| 735 | CHECK_ARRAY((NODE)->musts, MUSTS); \ |
| 736 | CHECK_POINTER((NODE)->notifs, NOTIFS); \ |
| 737 | CHECK_ARRAY((NODE)->uniques, UNIQUES); \ |
| 738 | CHECK_ARRAY(lysc_node_when((const struct lysc_node *)NODE), WHEN) |
| 739 | |
| 740 | /** |
| 741 | * @brief assert that lysc_node_leaf structure members are correct |
| 742 | * @param[in] NODE pointer to lysc_node variable |
| 743 | * @param[in] DSC expected description |
| 744 | * @param[in] EXTS expected [sized array](@ref sizedarrays) size of list of the extension instances |
| 745 | * @param[in] FLAGS [schema node flags](@ref snodeflags) |
| 746 | * @param[in] MODULE 0 pointer is null, 1 pointer is not null |
| 747 | * @param[in] NAME expected name |
| 748 | * @param[in] NEXT 0 pointer is null, 1 pointer is not null |
| 749 | * @param[in] PARENT 0-> check if node is root, 1-> check if node is not root |
| 750 | * @param[in] PRIV 0-> pointer is null, 1-> pointer is not null |
| 751 | * @param[in] REF expected reference |
| 752 | * @param[in] WHEN expected [sized array](@ref sizedarrays) size of list of pointers to when statements |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 753 | * @param[in] MUSTS expected [sized array](@ref sizedarrays) size of list of must restriction |
| 754 | * @param[in] UNITS expected string reprezenting units |
| 755 | * @param[in] DFLT 0-> node dosn't have default value. 1 -> node have default value |
| 756 | */ |
| 757 | #define CHECK_LYSC_NODE_LEAF(NODE, DSC, EXTS, FLAGS, MODULE, NAME, NEXT, \ |
| 758 | PARENT, PRIV, REF, WHEN, MUSTS, UNITS, DFLT) \ |
| 759 | CHECK_LYSC_NODE(NODE, DSC, EXTS, FLAGS, MODULE, NAME, NEXT, LYS_LEAF, PARENT, PRIV, REF, WHEN); \ |
| 760 | CHECK_ARRAY((NODE)->musts, MUSTS); \ |
| 761 | assert_non_null((NODE)->type); \ |
| 762 | CHECK_STRING((NODE)->units, UNITS); \ |
| 763 | CHECK_POINTER((NODE)->dflt, DFLT); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 764 | |
| 765 | /** |
| 766 | * @brief assert that lyd_meta structure members are correct |
| 767 | * @param[in] NODE pointer to lyd_meta variable |
| 768 | * @param[in] ANNOTATION 0 pointer is null, 1 pointer is not null |
| 769 | * @param[in] NAME expected name |
| 770 | * @param[in] NEXT 0 pointer is null, 1 pointer is not null |
| 771 | * @param[in] TYPE_VAL value type. EMPTY, UNION, BITS, INST, ENUM, INT8, INT16, UINT8, STRING, LEAFREF, DEC64, BINARY, BOOL, IDENT |
| 772 | * part of text reprezenting LY_DATA_TYPE. |
| 773 | * @param[in] ... ::CHECK_LYD_VALUE |
| 774 | */ |
| 775 | #define CHECK_LYD_META(NODE, ANNOTATION, NAME, NEXT, PARENT, TYPE_VAL, ...) \ |
| 776 | assert_non_null(NODE); \ |
| 777 | CHECK_POINTER((NODE)->annotation, ANNOTATION); \ |
| 778 | assert_string_equal((NODE)->name, NAME); \ |
| 779 | CHECK_POINTER((NODE)->next, NEXT); \ |
| 780 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 781 | CHECK_LYD_VALUE((NODE)->value, TYPE_VAL, ##__VA_ARGS__); |
| 782 | |
| 783 | /** |
| 784 | * @brief assert that lyd_node_term structure members are correct |
| 785 | * @param[in] NODE pointer to lyd_node_term variable |
| 786 | * @param[in] FLAGS expected [data node flags](@ref dnodeflags) |
| 787 | * @param[in] META 0 -> meta is not prezent, 1 -> meta is prezent |
| 788 | * @param[in] NEXT 0 -> next node is not prezent, 1 -> next node is prezent |
| 789 | * @param[in] TYPE_VAL value type. EMPTY, UNION, BITS, INST, ENUM, INT8, INT16, UINT8, STRING, LEAFREF, DEC64, BINARY, BOOL, IDENT |
| 790 | * part of text reprezenting LY_DATA_TYPE. |
| 791 | * @param[in] ... ::CHECK_LYD_VALUE |
| 792 | */ |
| 793 | #define CHECK_LYD_NODE_TERM(NODE, FLAGS, META, NEXT, PARENT, SCHEMA, VALUE_TYPE, ...) \ |
| 794 | assert_non_null(NODE); \ |
| 795 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 796 | CHECK_POINTER((NODE)->meta, META); \ |
| 797 | CHECK_POINTER((NODE)->next, NEXT); \ |
| 798 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 799 | assert_non_null((NODE)->prev); \ |
| 800 | CHECK_POINTER((NODE)->schema, SCHEMA); \ |
| 801 | CHECK_LYD_VALUE((NODE)->value, VALUE_TYPE, ##__VA_ARGS__); |
| 802 | |
| 803 | /** |
| 804 | * @brief assert that lyd_node_any structure members are correct |
| 805 | * @param[in] NODE pointer to lyd_node_term variable |
| 806 | * @param[in] FLAGS expected [data node flags](@ref dnodeflags) |
| 807 | * @param[in] META 0 meta isnt present , 1 meta is present |
| 808 | * @param[in] PARENT 0 it is root node , 1 node have parent |
| 809 | * @param[in] VALUE_TYPE value type ::lyd_node_any.value |
| 810 | */ |
| 811 | #define CHECK_LYD_NODE_ANY(NODE, FLAGS, META, PARENT, VALUE_TYPE) \ |
| 812 | assert_non_null(NODE); \ |
| 813 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 814 | CHECK_POINTER((NODE)->meta, META); \ |
| 815 | CHECK_POINTER((NODE)->meta, PARENT); \ |
| 816 | assert_non_null((NODE)->prev); \ |
| 817 | assert_non_null((NODE)->schema); \ |
| 818 | assert_int_equal((NODE)->value_type, VALUE_TYPE); |
| 819 | |
| 820 | /** |
| 821 | * @brief assert that lyd_node_opaq structure members are correct |
| 822 | * @param[in] NODE pointer to lyd_node_opaq variable |
| 823 | * @param[in] ATTR 0 if pointer is null ,1 if pointer is not null |
| 824 | * @param[in] CHILD 0 if pointer is null ,1 if pointer is not null |
| 825 | * @param[in] FORMAT LY_PREF_XML or LY_PREF_JSON |
| 826 | * @param[in] VAL_PREFS 0 if pointer is null ,1 if pointer is not null |
| 827 | * @param[in] NAME expected name |
| 828 | * @param[in] value expected orignal value |
| 829 | */ |
| 830 | #define CHECK_LYD_NODE_OPAQ(NODE, ATTR, CHILD, FORMAT, NAME, NEXT, PARENT, PREFIX, VAL_PREFS, VALUE) \ |
| 831 | assert_non_null(NODE); \ |
| 832 | CHECK_POINTER((NODE)->attr, ATTR); \ |
| 833 | CHECK_POINTER((NODE)->child, CHILD); \ |
| 834 | assert_ptr_equal((NODE)->ctx, UTEST_LYCTX); \ |
| 835 | assert_int_equal((NODE)->flags, 0); \ |
| 836 | assert_true((NODE)->format == FORMAT); \ |
| 837 | assert_int_equal((NODE)->hash, 0); \ |
| 838 | assert_string_equal((NODE)->name.name, NAME); \ |
| 839 | assert_non_null((NODE)->prev); \ |
| 840 | assert_null((NODE)->schema); \ |
| 841 | CHECK_POINTER((NODE)->val_prefix_data, VAL_PREFS); \ |
| 842 | assert_string_equal((NODE)->value, VALUE); |
| 843 | |
| 844 | /** |
Radek Iša | a76902f | 2021-03-29 08:52:51 +0200 | [diff] [blame^] | 845 | * @brief assert that lyd_node_opaq structure members are correct |
| 846 | * @param[in] NODE pointer to lyd_node_opaq variable |
| 847 | * @param[in] CHILD 1 if node has children other 0 |
| 848 | * @param[in] HILD_HT 1 if node has children hash table other 0 |
| 849 | * @param[in] META 1 if node has metadata other 0 |
| 850 | * @param[in] FLAGS expected flag |
| 851 | * @param[in] NEXT 1 if next node is present other 0 |
| 852 | * @param[in] PARENT 1 if node has parent other 0 |
| 853 | * @param[in] PRIV 1 if node has private data other 0 |
| 854 | * @param[in] SCHEMA 1 if node has schema other 0 |
| 855 | */ |
| 856 | #define CHECK_LYD_NODE_INNER(NODE, CHILD, CHILD_HT, META, FLAGS, NEXT, PARENT, PRIV, SCHEMA) \ |
| 857 | assert_non_null(NODE); \ |
| 858 | CHECK_POINTER((NODE)->child, CHILD); \ |
| 859 | CHECK_POINTER((NODE)->children_ht, CHILD_HT); \ |
| 860 | CHECK_POINTER((NODE)->meta, META); \ |
| 861 | assert_int_equal((NODE)->flags, FLAGS); \ |
| 862 | CHECK_POINTER((NODE)->parent, PARENT); \ |
| 863 | assert_non_null((NODE)->prev); \ |
| 864 | CHECK_POINTER((NODE)->next, NEXT); \ |
| 865 | CHECK_POINTER((NODE)->priv, PRIV); \ |
| 866 | CHECK_POINTER((NODE)->schema, SCHEMA) |
| 867 | |
| 868 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 869 | * @brief assert that lyd_value structure members are correct |
| 870 | * @param[in] NODE lyd_value |
| 871 | * @param[in] TYPE_VAL value type. EMPTY, UNION, BITS, INST, ENUM, INT8, INT16, UINT8, STRING, LEAFREF, DEC64, BINARY, BOOL, IDENT |
| 872 | * part of text reprezenting LY_DATA_TYPE. |
| 873 | * @param[in] ... Unspecified parameters. Type and numbers of parameters are specified |
| 874 | * by type of value. These parameters are passed to macro |
| 875 | * CHECK_LYD_VALUE_ ## TYPE_VAL. |
| 876 | */ |
| 877 | #define CHECK_LYD_VALUE(NODE, TYPE_VAL, ...) \ |
| 878 | CHECK_LYD_VALUE_ ## TYPE_VAL (NODE, ##__VA_ARGS__); |
| 879 | |
| 880 | /* |
| 881 | * LYD VALUES CHECKING SPECIALIZATION |
| 882 | */ |
| 883 | |
| 884 | /** |
| 885 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type EMPTY |
| 886 | * Example CHECK_LYD_VALUE(node->value, EMPTY, ""); |
| 887 | * @param[in] NODE lyd_value variable |
| 888 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 889 | */ |
| 890 | #define CHECK_LYD_VALUE_EMPTY(NODE, CANNONICAL_VAL) \ |
| 891 | assert_non_null((NODE).canonical); \ |
| 892 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 893 | assert_non_null((NODE).realtype); \ |
| 894 | assert_int_equal((NODE).realtype->basetype, LY_TYPE_EMPTY); |
| 895 | |
| 896 | /** |
| 897 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type UNION |
| 898 | * Example CHECK_LYD_VALUE(node->value, UNION, "12", INT8, "12", 12); |
| 899 | * @warning type of subvalue cannot be UNION. Example of calling |
| 900 | * @param[in] NODE lyd_value variable |
| 901 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 902 | * @param[in] TYPE_VAL value type. EMPTY, UNION, BITS, INST, ENUM, INT8, INT16, UINT8, STRING, LEAFREF, DEC64, BINARY, BOOL, IDENT |
| 903 | * @param[in] ... Unspecified parameters. Type and numbers of parameters are specified |
| 904 | * by type of value. These parameters are passed to macro |
| 905 | * CHECK_LYD_VALUE_ ## TYPE_VAL. |
| 906 | */ |
| 907 | #define CHECK_LYD_VALUE_UNION(NODE, CANNONICAL_VAL, TYPE_VAL, ...) \ |
| 908 | assert_non_null((NODE).canonical); \ |
| 909 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 910 | assert_non_null((NODE).realtype); \ |
| 911 | assert_int_equal(LY_TYPE_UNION, (NODE).realtype->basetype); \ |
| 912 | assert_non_null((NODE).subvalue); \ |
| 913 | assert_non_null((NODE).subvalue->prefix_data); \ |
| 914 | CHECK_LYD_VALUE_ ## TYPE_VAL ((NODE).subvalue->value, ## __VA_ARGS__) |
| 915 | |
| 916 | /** |
| 917 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type BITS |
| 918 | * Example arr[] = {"a", "b"}; CHECK_LYD_VALUE(node->value, BITS, "a b", arr); |
| 919 | * @param[in] NODE lyd_value variable |
| 920 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 921 | * @param[in] VALUE expected array of bits names |
| 922 | */ |
Radek Iša | ded3105 | 2021-03-10 13:22:53 +0100 | [diff] [blame] | 923 | #define CHECK_LYD_VALUE_BITS(NODE, CANNONICAL_VAL, ...) \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 924 | assert_non_null((NODE).canonical); \ |
| 925 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 926 | assert_non_null((NODE).realtype); \ |
| 927 | assert_int_equal(LY_TYPE_BITS, (NODE).realtype->basetype); \ |
| 928 | { \ |
Radek Iša | ded3105 | 2021-03-10 13:22:53 +0100 | [diff] [blame] | 929 | const char *arr[] = { __VA_ARGS__ }; \ |
| 930 | LY_ARRAY_COUNT_TYPE arr_size = sizeof(arr) / sizeof(arr[0]); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 931 | assert_int_equal(arr_size, LY_ARRAY_COUNT((NODE).bits_items)); \ |
| 932 | for (LY_ARRAY_COUNT_TYPE it = 0; it < arr_size; it++) { \ |
Radek Iša | ded3105 | 2021-03-10 13:22:53 +0100 | [diff] [blame] | 933 | assert_string_equal(arr[it], (NODE).bits_items[it]->name); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 934 | } \ |
| 935 | } |
| 936 | |
| 937 | /** |
| 938 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type INST |
| 939 | * @param[in] NODE lyd_value variable |
| 940 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 941 | * @param[in] VALUE expected array of enum ly_path_pred_type |
| 942 | * @brief Example enum arr[] = {0x0, 0x1}; CHECK_LYD_VALUE(node->value, INST, "test/d", arr); |
| 943 | */ |
| 944 | #define CHECK_LYD_VALUE_INST(NODE, CANNONICAL_VAL, VALUE) \ |
| 945 | assert_non_null((NODE).canonical); \ |
| 946 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 947 | assert_non_null((NODE).realtype); \ |
| 948 | assert_int_equal(LY_TYPE_INST, (NODE).realtype->basetype); \ |
| 949 | { \ |
Michal Vasko | 79135ae | 2020-12-16 10:08:35 +0100 | [diff] [blame] | 950 | LY_ARRAY_COUNT_TYPE arr_size = sizeof(VALUE) / sizeof(VALUE[0]); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 951 | assert_int_equal(arr_size, LY_ARRAY_COUNT((NODE).target)); \ |
| 952 | for (LY_ARRAY_COUNT_TYPE it = 0; it < arr_size; it++) { \ |
| 953 | assert_int_equal(VALUE[it], (NODE).target[it].pred_type); \ |
| 954 | } \ |
| 955 | } |
| 956 | |
| 957 | /** |
| 958 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type ENUM. |
| 959 | * Example CHECK_LYD_VALUE(node->value, ENUM, "item_name", "item_name"); |
| 960 | * @param[in] NODE lyd_value variable |
| 961 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 962 | * @param[in] VALUE expected enum item name |
| 963 | */ |
| 964 | #define CHECK_LYD_VALUE_ENUM(NODE, CANNONICAL_VAL, VALUE) \ |
| 965 | assert_non_null((NODE).canonical); \ |
| 966 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 967 | assert_non_null((NODE).realtype); \ |
| 968 | assert_int_equal(LY_TYPE_ENUM, (NODE).realtype->basetype); \ |
| 969 | assert_string_equal(VALUE, (NODE).enum_item->name); |
| 970 | |
| 971 | /** |
| 972 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type INT8 |
| 973 | * Example CHECK_LYD_VALUE(node->value, INT8, "12", 12); |
| 974 | * @param[in] NODE lyd_value variable |
| 975 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 976 | * @param[in] VALUE expected inteager value (-128 to 127). |
| 977 | */ |
| 978 | #define CHECK_LYD_VALUE_INT8(NODE, CANNONICAL_VAL, VALUE) \ |
| 979 | assert_non_null((NODE).canonical); \ |
| 980 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 981 | assert_non_null((NODE).realtype); \ |
| 982 | assert_int_equal(LY_TYPE_INT8, (NODE).realtype->basetype); \ |
| 983 | assert_int_equal(VALUE, (NODE).int8); |
| 984 | |
| 985 | /** |
| 986 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type INT16 |
| 987 | * Example CHECK_LYD_VALUE(node->value, INT8, "12", 12); |
| 988 | * @param[in] NODE lyd_value variable |
| 989 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 990 | * @param[in] VALUE expected inteager value. |
| 991 | */ |
| 992 | #define CHECK_LYD_VALUE_INT16(NODE, CANNONICAL_VAL, VALUE) \ |
| 993 | assert_non_null((NODE).canonical); \ |
| 994 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 995 | assert_non_null((NODE).realtype); \ |
| 996 | assert_int_equal(LY_TYPE_INT16, (NODE).realtype->basetype); \ |
| 997 | assert_int_equal(VALUE, (NODE).int16); |
| 998 | |
| 999 | /** |
| 1000 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type UINT8. |
| 1001 | * Example CHECK_LYD_VALUE(node->value, UINT8, "12", 12); |
| 1002 | * @param[in] NODE lyd_value variable |
| 1003 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1004 | * @param[in] VALUE expected inteager (0 to 255). |
| 1005 | */ |
| 1006 | #define CHECK_LYD_VALUE_UINT8(NODE, CANNONICAL_VAL, VALUE) \ |
| 1007 | assert_non_null((NODE).canonical); \ |
| 1008 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1009 | assert_non_null((NODE).realtype); \ |
| 1010 | assert_int_equal(LY_TYPE_UINT8, (NODE).realtype->basetype); \ |
| 1011 | assert_int_equal(VALUE, (NODE).uint8); |
| 1012 | |
| 1013 | /** |
Radek Iša | a76902f | 2021-03-29 08:52:51 +0200 | [diff] [blame^] | 1014 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type UINT32. |
| 1015 | * Example CHECK_LYD_VALUE(node->value, UINT32, "12", 12); |
| 1016 | * @param[in] NODE lyd_value variable |
| 1017 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1018 | * @param[in] VALUE expected inteager (0 to MAX_UINT32). |
| 1019 | */ |
| 1020 | #define CHECK_LYD_VALUE_UINT32(NODE, CANNONICAL_VAL, VALUE) \ |
| 1021 | assert_non_null((NODE).canonical); \ |
| 1022 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1023 | assert_non_null((NODE).realtype); \ |
| 1024 | assert_int_equal(LY_TYPE_UINT32, (NODE).realtype->basetype); \ |
| 1025 | assert_int_equal(VALUE, (NODE).uint32); |
| 1026 | |
| 1027 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1028 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type STRING. |
| 1029 | * Example CHECK_LYD_VALUE(node->value, STRING, "text"); |
| 1030 | * @param[in] NODE lyd_value variable |
| 1031 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1032 | */ |
| 1033 | #define CHECK_LYD_VALUE_STRING(NODE, CANNONICAL_VAL) \ |
| 1034 | assert_non_null((NODE).canonical); \ |
| 1035 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1036 | assert_non_null((NODE).realtype); \ |
| 1037 | assert_int_equal(LY_TYPE_STRING, (NODE).realtype->basetype); |
| 1038 | |
| 1039 | /** |
| 1040 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type LEAFREF |
| 1041 | * @brief Example CHECK_LYD_VALUE(node->value, LEAFREF, ""); |
| 1042 | * @param[in] NODE lyd_value variable |
| 1043 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1044 | */ |
| 1045 | #define CHECK_LYD_VALUE_LEAFREF(NODE, CANNONICAL_VAL) \ |
| 1046 | assert_non_null((NODE).canonical); \ |
| 1047 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1048 | assert_non_null((NODE).realtype); \ |
| 1049 | assert_int_equal(LY_TYPE_LEAFREF, (NODE).realtype->basetype); \ |
| 1050 | assert_non_null((NODE).ptr) |
| 1051 | |
| 1052 | /** |
| 1053 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type DEC64 |
| 1054 | * Example CHECK_LYD_VALUE(node->value, DEC64, "125", 125); |
| 1055 | * @param[in] NODE lyd_value variable |
| 1056 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1057 | * @param[in] VALUE expected value 64bit inteager |
| 1058 | */ |
| 1059 | #define CHECK_LYD_VALUE_DEC64(NODE, CANNONICAL_VAL, VALUE) \ |
| 1060 | assert_non_null((NODE).canonical); \ |
| 1061 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1062 | assert_non_null((NODE).realtype); \ |
| 1063 | assert_int_equal(LY_TYPE_DEC64, (NODE).realtype->basetype); \ |
| 1064 | assert_int_equal(VALUE, (NODE).dec64); |
| 1065 | |
| 1066 | /** |
| 1067 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type BINARY. |
| 1068 | * Example CHECK_LYD_VALUE(node->value, BINARY, "aGVs\nbG8="); |
| 1069 | * @param[in] NODE lyd_value variable |
| 1070 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1071 | */ |
| 1072 | #define CHECK_LYD_VALUE_BINARY(NODE, CANNONICAL_VAL) \ |
| 1073 | assert_non_null((NODE).canonical); \ |
| 1074 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1075 | assert_non_null((NODE).realtype); \ |
| 1076 | assert_int_equal(LY_TYPE_BINARY, (NODE).realtype->basetype); |
| 1077 | |
| 1078 | /** |
| 1079 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type BOOL. |
| 1080 | * Example CHECK_LYD_VALUE(node->value, BOOL, "true", 1); |
| 1081 | * @param[in] NODE lyd_value variable |
| 1082 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1083 | * @param[in] VALUE expected boolean value 0,1 |
| 1084 | */ |
| 1085 | #define CHECK_LYD_VALUE_BOOL(NODE, CANNONICAL_VAL, VALUE) \ |
| 1086 | assert_non_null((NODE).canonical); \ |
| 1087 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1088 | assert_non_null((NODE).realtype); \ |
| 1089 | assert_int_equal(LY_TYPE_BOOL, (NODE).realtype->basetype); \ |
| 1090 | assert_int_equal(VALUE, (NODE).boolean); |
| 1091 | |
| 1092 | /** |
| 1093 | * @brief Internal macro. Assert that lyd_value structure members are correct. Lyd value is type IDENT. |
| 1094 | * Example CHECK_LYD_VALUE(node->value, IDENT, "types:gigabit-ethernet", "gigabit-ethernet"); |
| 1095 | * @param[in] NODE lyd_value variable |
| 1096 | * @param[in] CANNONICAL_VAL expected cannonical value |
| 1097 | * @param[in] VALUE expected ident name |
| 1098 | */ |
| 1099 | #define CHECK_LYD_VALUE_IDENT(NODE, CANNONICAL_VAL, VALUE) \ |
| 1100 | assert_non_null((NODE).canonical); \ |
| 1101 | assert_string_equal((NODE).canonical, CANNONICAL_VAL); \ |
| 1102 | assert_non_null((NODE).realtype); \ |
| 1103 | assert_int_equal(LY_TYPE_IDENT, (NODE).realtype->basetype); \ |
| 1104 | assert_string_equal(VALUE, (NODE).ident->name); |
| 1105 | |
| 1106 | /** |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 1107 | * @brief Macro testing parser when parsing incorrect module; |
| 1108 | * @param[in] DATA String storing the schema module representation. |
| 1109 | * @param[in] FORMAT Schema format of the @p DATA |
| 1110 | * @param[in] FEATURES Array of module's features to enable |
| 1111 | * @param[in] RET_VAL ly_in_new_memory return error value |
| 1112 | */ |
| 1113 | #define UTEST_INVALID_MODULE(DATA, FORMAT, FEATURES, RET_VAL) \ |
| 1114 | { \ |
| 1115 | const struct lys_module *mod; \ |
| 1116 | assert_int_equal(LY_SUCCESS, ly_in_new_memory(DATA, &_UC->in)); \ |
| 1117 | assert_int_equal(RET_VAL, lys_parse(_UC->ctx, _UC->in, FORMAT, FEATURES, &mod)); \ |
| 1118 | assert_null(mod); \ |
| 1119 | } \ |
| 1120 | ly_in_free(_UC->in, 0); \ |
| 1121 | _UC->in = NULL; \ |
| 1122 | |
| 1123 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1124 | * @brief Add module (from a string) into the used libyang context. |
| 1125 | * @param[in] DATA String storing the schema module representation. |
| 1126 | * @param[in] FORMAT Schema format of the @p DATA |
| 1127 | * @param[in] FEATURES Array of module's features to enable |
| 1128 | * @param[out] MOD Optional parameter as a pointer to variable to store the resulting module. |
| 1129 | */ |
| 1130 | #define UTEST_ADD_MODULE(DATA, FORMAT, FEATURES, MOD) \ |
| 1131 | assert_int_equal(LY_SUCCESS, ly_in_new_memory(DATA, &_UC->in)); \ |
| 1132 | assert_int_equal(LY_SUCCESS, lys_parse(_UC->ctx, _UC->in, FORMAT, FEATURES, MOD)); \ |
| 1133 | ly_in_free(_UC->in, 0); \ |
| 1134 | _UC->in = NULL |
| 1135 | |
| 1136 | /** |
| 1137 | * @brief Internal macro to compare error info record with the expected error message and path. |
| 1138 | * If NULL is provided as MSG, no error info record (NULL) is expected. |
| 1139 | * @param[in] ERR Error information record from libyang context. |
| 1140 | * @param[in] MSG Expected error message. |
| 1141 | * @param[in] PATH Expected error path. |
| 1142 | * |
| 1143 | */ |
| 1144 | #define _CHECK_LOG_CTX(ERR, MSG, PATH) \ |
| 1145 | if (!MSG) { \ |
| 1146 | assert_null(ERR); \ |
| 1147 | } else { \ |
| 1148 | assert_non_null(ERR); \ |
| 1149 | CHECK_STRING((ERR)->msg, MSG); \ |
| 1150 | CHECK_STRING((ERR)->path, PATH); \ |
| 1151 | } |
| 1152 | |
| 1153 | /**` |
| 1154 | * @brief Internal macro to check the last libyang's context error. |
| 1155 | */ |
| 1156 | #define _CHECK_LOG_CTX1(MSG, PATH) \ |
| 1157 | _CHECK_LOG_CTX(ly_err_last(_UC->ctx), MSG, PATH) |
| 1158 | |
| 1159 | /** |
| 1160 | * @brief Internal macro to check the last two libyang's context error. |
| 1161 | */ |
| 1162 | #define _CHECK_LOG_CTX2(MSG1, PATH1, MSG2, PATH2) \ |
| 1163 | _CHECK_LOG_CTX(ly_err_last(_UC->ctx), MSG1, PATH1); \ |
| 1164 | _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev, MSG2, PATH2) |
| 1165 | |
| 1166 | /** |
| 1167 | * @brief Internal macro to check the last three libyang's context error. |
| 1168 | */ |
| 1169 | #define _CHECK_LOG_CTX3(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3) \ |
| 1170 | _CHECK_LOG_CTX2(MSG1, PATH1, MSG2, PATH2); \ |
| 1171 | _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev, MSG3, PATH3) |
| 1172 | |
| 1173 | /** |
Radek Krejci | fe6ec26 | 2021-01-20 10:28:28 +0100 | [diff] [blame] | 1174 | * @brief Internal macro to check the last three libyang's context error. |
| 1175 | */ |
| 1176 | #define _CHECK_LOG_CTX4(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4) \ |
| 1177 | _CHECK_LOG_CTX3(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3); \ |
| 1178 | _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev, MSG4, PATH4) |
| 1179 | |
| 1180 | /** |
| 1181 | * @brief Internal macro to check the last three libyang's context error. |
| 1182 | */ |
| 1183 | #define _CHECK_LOG_CTX5(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5) \ |
| 1184 | _CHECK_LOG_CTX4(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4); \ |
| 1185 | _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev->prev, MSG5, PATH5) |
| 1186 | |
| 1187 | /** |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1188 | * @brief Internal helper macro to select _CHECK_LOG_CTX* macro according to the provided parameters. |
| 1189 | */ |
Radek Krejci | fe6ec26 | 2021-01-20 10:28:28 +0100 | [diff] [blame] | 1190 | #define _GET_CHECK_LOG_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, NAME, ...) NAME |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1191 | |
| 1192 | /** |
| 1193 | * @brief Check expected error(s) in libyang context. |
| 1194 | * |
| 1195 | * Macro has variadic parameters expected to be provided in pairs of error message and error path starting |
| 1196 | * from the latest error. Current limit is checking at most 3 last errors. After checking, macro cleans up |
| 1197 | * all the errors from the libyang context. |
| 1198 | * |
| 1199 | * @param[in] MSG Expected error message. |
| 1200 | * @param[in] PATH Expected error path. |
| 1201 | */ |
| 1202 | #define CHECK_LOG_CTX(...) \ |
Radek Krejci | fe6ec26 | 2021-01-20 10:28:28 +0100 | [diff] [blame] | 1203 | _GET_CHECK_LOG_MACRO(__VA_ARGS__, _CHECK_LOG_CTX5, _INVAL, _CHECK_LOG_CTX4, _INVAL, \ |
| 1204 | _CHECK_LOG_CTX3, _INVAL, _CHECK_LOG_CTX2, _INVAL, _CHECK_LOG_CTX1)(__VA_ARGS__); \ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1205 | ly_err_clean(_UC->ctx, NULL) |
| 1206 | |
| 1207 | /** |
| 1208 | * @brief Clean up the logging callback's storage. |
| 1209 | */ |
| 1210 | #define UTEST_LOG_CLEAN \ |
| 1211 | free(_UC->err_msg); \ |
| 1212 | free(_UC->err_path); \ |
| 1213 | _UC->err_msg = NULL; \ |
| 1214 | _UC->err_path = NULL; |
| 1215 | |
| 1216 | /** |
| 1217 | * @brief Check expected error directly logged via logging callback. |
| 1218 | * Useful mainly for messages logged by functions without access to libyang context. |
| 1219 | * @param[in] MSG Expected error message. |
| 1220 | * @param[in] PATH Expected error path. |
| 1221 | */ |
| 1222 | #define CHECK_LOG(MSG, PATH) \ |
| 1223 | CHECK_STRING(_UC->err_msg, MSG); \ |
| 1224 | CHECK_STRING(_UC->err_path, PATH); \ |
| 1225 | UTEST_LOG_CLEAN |
| 1226 | |
| 1227 | #ifdef _UTEST_MAIN_ |
| 1228 | /* |
| 1229 | * Functions inlined into each C source file including this header with _UTEST_MAIN_ defined |
| 1230 | */ |
| 1231 | |
| 1232 | /** |
| 1233 | * @brief Global variable holding the tests context to simplify access to it. |
| 1234 | */ |
| 1235 | struct utest_context *current_utest_context; |
| 1236 | |
| 1237 | /* set to 0 to printing error messages to stderr instead of checking them in code */ |
| 1238 | #define ENABLE_LOGGER_CHECKING 1 |
| 1239 | |
| 1240 | /** |
| 1241 | * @brief Logging callback for libyang. |
| 1242 | */ |
| 1243 | static void |
| 1244 | _utest_logger(LY_LOG_LEVEL level, const char *msg, const char *path) |
| 1245 | { |
| 1246 | (void) level; /* unused */ |
| 1247 | |
| 1248 | if (ENABLE_LOGGER_CHECKING == 0) { |
Radek Iša | a9ff2b8 | 2021-01-13 21:44:13 +0100 | [diff] [blame] | 1249 | printf("\tERROR:\n\t\tMESSAGE: %s\n\t\tPATH: %s\n\t\tLEVEL: %i\n", msg, path, level); |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 1250 | } else { |
| 1251 | free(current_utest_context->err_msg); |
| 1252 | current_utest_context->err_msg = msg ? strdup(msg) : NULL; |
| 1253 | free(current_utest_context->err_path); |
| 1254 | current_utest_context->err_path = path ? strdup(path) : NULL; |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | /** |
| 1259 | * @brief Generic utest's setup |
| 1260 | */ |
| 1261 | static int |
| 1262 | utest_setup(void **state) |
| 1263 | { |
| 1264 | /* setup the logger */ |
| 1265 | ly_set_log_clb(_utest_logger, 1); |
| 1266 | ly_log_options(LY_LOLOG | LY_LOSTORE); |
| 1267 | |
| 1268 | current_utest_context = calloc(1, sizeof *current_utest_context); |
| 1269 | assert_non_null(current_utest_context); |
| 1270 | *state = current_utest_context; |
| 1271 | |
| 1272 | /* libyang context */ |
| 1273 | assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, ¤t_utest_context->ctx)); |
| 1274 | |
| 1275 | return 0; |
| 1276 | } |
| 1277 | |
| 1278 | /** |
| 1279 | * @brief macro to include generic utest's setup into the test-specific setup. |
| 1280 | * |
| 1281 | * Place at the beginning of the test-specific setup |
| 1282 | */ |
| 1283 | #define UTEST_SETUP \ |
| 1284 | assert_int_equal(0, utest_setup(state)) |
| 1285 | |
| 1286 | /** |
| 1287 | * @brief Generic utest's teardown |
| 1288 | */ |
| 1289 | static int |
| 1290 | utest_teardown(void **state) |
| 1291 | { |
| 1292 | *state = NULL; |
| 1293 | |
| 1294 | /* libyang context */ |
| 1295 | ly_ctx_destroy(current_utest_context->ctx, NULL); |
| 1296 | |
| 1297 | /* utest context */ |
| 1298 | ly_in_free(current_utest_context->in, 0); |
| 1299 | free(current_utest_context->err_msg); |
| 1300 | free(current_utest_context->err_path); |
| 1301 | free(current_utest_context); |
| 1302 | current_utest_context = NULL; |
| 1303 | |
| 1304 | return 0; |
| 1305 | } |
| 1306 | |
| 1307 | /** |
| 1308 | * @brief macro to include generic utest's teardown into the test-specific teardown. |
| 1309 | * |
| 1310 | * Place at the end of the test-specific teardown |
| 1311 | */ |
| 1312 | #define UTEST_TEARDOWN \ |
| 1313 | assert_int_equal(0, utest_teardown(state)) |
| 1314 | |
| 1315 | /** |
| 1316 | * @brief Internal macro for utest setup with test-specific setup and teardown |
| 1317 | */ |
| 1318 | #define _UTEST_SETUP_TEARDOWN(FUNC, SETUP, TEARDOWN) \ |
| 1319 | cmocka_unit_test_setup_teardown(FUNC, SETUP, TEARDOWN) |
| 1320 | |
| 1321 | /** |
| 1322 | * @brief Internal macro for utest setup with test-specific setup and generic teardown |
| 1323 | */ |
| 1324 | #define _UTEST_SETUP(FUNC, SETUP) \ |
| 1325 | cmocka_unit_test_setup_teardown(FUNC, SETUP, utest_teardown) |
| 1326 | |
| 1327 | /** |
| 1328 | * @brief Internal macro for utest setup with generic setup and teardown |
| 1329 | */ |
| 1330 | #define _UTEST(FUNC) \ |
| 1331 | cmocka_unit_test_setup_teardown(FUNC, utest_setup, utest_teardown) |
| 1332 | |
| 1333 | /** |
| 1334 | * @brief Internal helper macro to select _UTEST* macro according to the provided parameters. |
| 1335 | */ |
| 1336 | #define _GET_UTEST_MACRO(_1, _2, _3, NAME, ...) NAME |
| 1337 | |
| 1338 | /** |
| 1339 | * @brief Macro to specify test function using utest environment. Macro has variadic parameters |
| 1340 | * to provide test-specific setup/teardown functions: |
| 1341 | * |
| 1342 | * UTEST(test_func) - only implicit setup and teardown functions are used |
| 1343 | * UTEST(test_func, setup) - implicit teardown but own setup |
| 1344 | * UTEST(test_func, setup, teardown) - both setup and teardown are test-specific |
| 1345 | */ |
| 1346 | #define UTEST(...) \ |
| 1347 | _GET_UTEST_MACRO(__VA_ARGS__, _UTEST_SETUP_TEARDOWN, _UTEST_SETUP, _UTEST)(__VA_ARGS__) |
| 1348 | |
| 1349 | #else /* _UTEST_MAIN_ */ |
| 1350 | |
| 1351 | extern struct utest_context *current_utest_context; |
| 1352 | |
| 1353 | #endif /* _UTEST_MAIN_ */ |
| 1354 | |
| 1355 | #endif /* _UTESTS_H_ */ |