Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * @file xml.c |
| 3 | * @author: Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief unit tests for functions from xml.c |
| 5 | * |
| 6 | * Copyright (c) 2018 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 | */ |
| 14 | |
Radek Krejci | 2d7a47b | 2019-05-16 13:34:10 +0200 | [diff] [blame] | 15 | #define _DEFAULT_SOURCE |
| 16 | #define _GNU_SOURCE |
| 17 | |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 18 | #include <stdarg.h> |
| 19 | #include <stddef.h> |
| 20 | #include <setjmp.h> |
| 21 | #include <cmocka.h> |
| 22 | |
Radek Krejci | 2d7a47b | 2019-05-16 13:34:10 +0200 | [diff] [blame] | 23 | #include <stdlib.h> |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 24 | #include <stdio.h> |
| 25 | #include <string.h> |
| 26 | |
Radek Krejci | 2d7a47b | 2019-05-16 13:34:10 +0200 | [diff] [blame] | 27 | #include "../../src/xml.h" |
| 28 | |
| 29 | LY_ERR lyxml_ns_add(struct lyxml_context *context, const char *prefix, size_t prefix_len, char *uri); |
| 30 | LY_ERR lyxml_ns_rm(struct lyxml_context *context); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 31 | |
| 32 | #define BUFSIZE 1024 |
| 33 | char logbuf[BUFSIZE] = {0}; |
| 34 | |
| 35 | /* set to 0 to printing error messages to stderr instead of checking them in code */ |
| 36 | #define ENABLE_LOGGER_CHECKING 1 |
| 37 | |
| 38 | static void |
| 39 | logger(LY_LOG_LEVEL level, const char *msg, const char *path) |
| 40 | { |
| 41 | (void) level; /* unused */ |
| 42 | |
| 43 | if (path) { |
| 44 | snprintf(logbuf, BUFSIZE - 1, "%s %s", msg, path); |
| 45 | } else { |
| 46 | strncpy(logbuf, msg, BUFSIZE - 1); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | static int |
| 51 | logger_setup(void **state) |
| 52 | { |
| 53 | (void) state; /* unused */ |
| 54 | #if ENABLE_LOGGER_CHECKING |
| 55 | ly_set_log_clb(logger, 1); |
| 56 | #endif |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | void |
| 61 | logbuf_clean(void) |
| 62 | { |
| 63 | logbuf[0] = '\0'; |
| 64 | } |
| 65 | |
| 66 | #if ENABLE_LOGGER_CHECKING |
| 67 | # define logbuf_assert(str) assert_string_equal(logbuf, str) |
| 68 | #else |
| 69 | # define logbuf_assert(str) |
| 70 | #endif |
| 71 | |
| 72 | static void |
| 73 | test_element(void **state) |
| 74 | { |
| 75 | (void) state; /* unused */ |
| 76 | |
| 77 | size_t name_len, prefix_len; |
Radek Krejci | 28e8cb5 | 2019-03-08 11:31:31 +0100 | [diff] [blame] | 78 | size_t buf_len, len; |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 79 | const char *name, *prefix; |
Radek Krejci | 28e8cb5 | 2019-03-08 11:31:31 +0100 | [diff] [blame] | 80 | char *buf = NULL, *out = NULL; |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 81 | const char *str, *p; |
Radek Krejci | 28e8cb5 | 2019-03-08 11:31:31 +0100 | [diff] [blame] | 82 | int dynamic; |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 83 | |
| 84 | struct lyxml_context ctx; |
| 85 | memset(&ctx, 0, sizeof ctx); |
| 86 | ctx.line = 1; |
| 87 | |
| 88 | /* empty */ |
| 89 | str = ""; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 90 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 91 | assert_null(name); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 92 | assert_int_equal(LYXML_END, ctx.status); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 93 | assert_true(str[0] == '\0'); |
| 94 | |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 95 | /* end element */ |
| 96 | str = "</element>"; |
| 97 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | 3fbc987 | 2019-04-16 16:50:01 +0200 | [diff] [blame] | 98 | logbuf_assert("Opening and closing elements tag missmatch (\"element\"). Line number 1."); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 99 | |
| 100 | |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 101 | /* no element */ |
| 102 | logbuf_clean(); |
| 103 | str = p = "no data present"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 104 | assert_int_equal(LY_EINVAL, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 105 | assert_null(name); |
| 106 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 107 | logbuf_assert(""); |
| 108 | |
| 109 | /* not supported DOCTYPE */ |
| 110 | str = p = "<!DOCTYPE greeting SYSTEM \"hello.dtd\"><greeting/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 111 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 112 | assert_null(name); |
| 113 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 114 | logbuf_assert("Document Type Declaration not supported. Line number 1."); |
| 115 | |
Radek Krejci | c5c31bb | 2019-04-08 14:40:52 +0200 | [diff] [blame] | 116 | /* invalid XML */ |
| 117 | str = p = "<!NONSENCE/>"; |
| 118 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
| 119 | assert_null(name); |
| 120 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 121 | logbuf_assert("Unknown XML section \"<!NONSENCE/>\". Line number 1."); |
| 122 | |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 123 | /* unqualified element */ |
| 124 | str = " < element/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 125 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 126 | assert_null(prefix); |
| 127 | assert_false(strncmp("element", name, name_len)); |
| 128 | assert_int_equal(7, name_len); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 129 | assert_int_equal(LYXML_ELEMENT, ctx.status); |
| 130 | assert_string_equal("", str); |
Radek Krejci | 28e8cb5 | 2019-03-08 11:31:31 +0100 | [diff] [blame] | 131 | assert_int_equal(0, ctx.elements.count); |
| 132 | |
| 133 | str = " < element attr=\'x\'/>"; |
| 134 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
| 135 | assert_int_equal(LYXML_ATTRIBUTE, ctx.status); |
| 136 | assert_string_equal("attr=\'x\'/>", str); |
| 137 | assert_int_equal(1, ctx.elements.count); |
| 138 | assert_int_equal(LY_SUCCESS, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
| 139 | assert_int_equal(LYXML_ATTR_CONTENT, ctx.status); |
| 140 | assert_string_equal("\'x\'/>", str); |
| 141 | assert_int_equal(1, ctx.elements.count); |
| 142 | assert_int_equal(LY_SUCCESS, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 143 | assert_int_equal(LYXML_ELEMENT, ctx.status); |
| 144 | assert_string_equal("", str); |
| 145 | assert_int_equal(0, ctx.elements.count); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 146 | |
Radek Krejci | fb7c658 | 2018-09-21 16:12:45 +0200 | [diff] [blame] | 147 | str = "<?xml version=\"1.0\"?> <!-- comment --> <![CDATA[<greeting>Hello, world!</greeting>]]> <?TEST xxx?> <element/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 148 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 149 | assert_null(prefix); |
| 150 | assert_false(strncmp("element", name, name_len)); |
| 151 | assert_int_equal(7, name_len); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 152 | assert_int_equal(LYXML_ELEMENT, ctx.status); |
| 153 | assert_string_equal("", str); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 154 | |
| 155 | str = "<element xmlns=\"urn\"></element>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 156 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 157 | assert_null(prefix); |
| 158 | assert_false(strncmp("element", name, name_len)); |
| 159 | assert_int_equal(7, name_len); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 160 | assert_int_equal(LYXML_ATTRIBUTE, ctx.status); |
| 161 | assert_string_equal("xmlns=\"urn\"></element>", str); |
| 162 | /* cleean context by getting closing tag */ |
| 163 | str += 12; |
| 164 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 165 | |
| 166 | /* qualified element */ |
| 167 | str = " < yin:element/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 168 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 169 | assert_false(strncmp("yin", prefix, prefix_len)); |
| 170 | assert_false(strncmp("element", name, name_len)); |
| 171 | assert_int_equal(3, prefix_len); |
| 172 | assert_int_equal(7, name_len); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 173 | assert_int_equal(LYXML_ELEMENT, ctx.status); |
| 174 | assert_string_equal("", str); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 175 | |
| 176 | str = "<yin:element xmlns=\"urn\"></element>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 177 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 178 | assert_false(strncmp("yin", prefix, prefix_len)); |
| 179 | assert_false(strncmp("element", name, name_len)); |
| 180 | assert_int_equal(3, prefix_len); |
| 181 | assert_int_equal(7, name_len); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 182 | assert_int_equal(LYXML_ATTRIBUTE, ctx.status); |
| 183 | assert_string_equal("xmlns=\"urn\"></element>", str); |
| 184 | /* cleean context by getting closing tag */ |
| 185 | str += 12; |
| 186 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | 3fbc987 | 2019-04-16 16:50:01 +0200 | [diff] [blame] | 187 | logbuf_assert("Opening and closing elements tag missmatch (\"element\"). Line number 1."); |
Radek Krejci | a93621b | 2018-10-18 11:13:38 +0200 | [diff] [blame] | 188 | str = "</yin:element/>"; |
| 189 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
| 190 | logbuf_assert("Unexpected data \"/>\" in closing element tag. Line number 1."); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 191 | lyxml_context_clear(&ctx); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 192 | |
| 193 | /* UTF8 characters */ |
| 194 | str = "<𠜎€𠜎Øn:𠜎€𠜎Øn/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 195 | assert_int_equal(LY_SUCCESS, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 196 | assert_false(strncmp("𠜎€𠜎Øn", prefix, prefix_len)); |
| 197 | assert_false(strncmp("𠜎€𠜎Øn", name, name_len)); |
| 198 | assert_int_equal(14, prefix_len); |
| 199 | assert_int_equal(14, name_len); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 200 | assert_int_equal(LYXML_ELEMENT, ctx.status); |
| 201 | assert_string_equal("", str); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 202 | |
| 203 | /* invalid UTF-8 character */ |
| 204 | str = "<¢:element>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 205 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 206 | logbuf_assert("Identifier \"¢:element>\" starts with invalid character. Line number 1."); |
| 207 | str = "<yin:c⁐element>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 208 | assert_int_equal(LY_EVALID, lyxml_get_element(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 209 | logbuf_assert("Invalid character sequence \"⁐element>\", expected whitespace or element tag termination ('>' or '/>'. Line number 1."); |
| 210 | } |
| 211 | |
| 212 | static void |
| 213 | test_attribute(void **state) |
| 214 | { |
| 215 | (void) state; /* unused */ |
| 216 | |
| 217 | size_t name_len, prefix_len; |
| 218 | const char *name, *prefix; |
| 219 | const char *str, *p; |
| 220 | |
| 221 | struct lyxml_context ctx; |
| 222 | memset(&ctx, 0, sizeof ctx); |
| 223 | ctx.line = 1; |
| 224 | |
| 225 | /* empty - without element tag termination */ |
| 226 | str = ""; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 227 | assert_int_equal(LY_EINVAL, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 228 | |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 229 | /* not an attribute */ |
| 230 | str = p = "unknown/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 231 | assert_int_equal(LY_EVALID, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 232 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 233 | logbuf_assert("Invalid character sequence \"/>\", expected whitespace or '='. Line number 1."); |
| 234 | str = p = "unknown />"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 235 | assert_int_equal(LY_EVALID, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 236 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 237 | logbuf_assert("Invalid character sequence \"/>\", expected '='. Line number 1."); |
| 238 | str = p = "xxx=/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 239 | assert_int_equal(LY_EVALID, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 240 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 241 | logbuf_assert("Invalid character sequence \"/>\", expected either single or double quotation mark. Line number 1."); |
| 242 | str = p = "xxx\n = yyy/>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 243 | assert_int_equal(LY_EVALID, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 244 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 245 | logbuf_assert("Invalid character sequence \"yyy/>\", expected either single or double quotation mark. Line number 2."); |
| 246 | |
| 247 | /* valid attribute */ |
| 248 | str = "xmlns=\"urn\">"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 249 | assert_int_equal(LY_SUCCESS, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 250 | assert_null(name); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 251 | assert_null(prefix); |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 252 | assert_int_equal(0, name_len); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 253 | assert_int_equal(0, prefix_len); |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 254 | assert_int_equal(1, ctx.ns.count); |
| 255 | assert_string_equal("", str); |
| 256 | assert_int_equal(LYXML_ELEM_CONTENT, ctx.status); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 257 | |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 258 | str = "xmlns:nc\n = \'urn\'>"; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 259 | assert_int_equal(LY_SUCCESS, lyxml_get_attribute(&ctx, &str, &prefix, &prefix_len, &name, &name_len)); |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 260 | assert_null(name); |
| 261 | assert_null(prefix); |
| 262 | assert_int_equal(0, name_len); |
| 263 | assert_int_equal(0, prefix_len); |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 264 | assert_int_equal(3, ctx.line); |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 265 | assert_int_equal(2, ctx.ns.count); |
| 266 | assert_string_equal("", str); |
| 267 | assert_int_equal(LYXML_ELEM_CONTENT, ctx.status); |
Radek Krejci | 28e8cb5 | 2019-03-08 11:31:31 +0100 | [diff] [blame] | 268 | |
Radek Krejci | 4916573 | 2019-05-15 16:41:58 +0200 | [diff] [blame] | 269 | lyxml_context_clear(&ctx); |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 270 | } |
| 271 | |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 272 | static void |
| 273 | test_text(void **state) |
| 274 | { |
| 275 | (void) state; /* unused */ |
| 276 | |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 277 | size_t buf_len, len; |
| 278 | int dynamic; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 279 | const char *str, *p; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 280 | char *buf = NULL, *out = NULL; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 281 | |
| 282 | struct lyxml_context ctx; |
| 283 | memset(&ctx, 0, sizeof ctx); |
| 284 | ctx.line = 1; |
| 285 | |
| 286 | /* empty attribute value */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 287 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 288 | str = "\"\""; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 289 | assert_int_equal(LY_SUCCESS, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 290 | assert_null(buf); |
| 291 | assert_ptr_equal(&str[-1], out); |
| 292 | assert_int_equal(0, dynamic); |
| 293 | assert_int_equal(0, len); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 294 | assert_true(str[0] == '\0'); /* everything eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 295 | assert_int_equal(LYXML_ATTRIBUTE, ctx.status); |
| 296 | |
| 297 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 298 | str = "\'\'"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 299 | assert_int_equal(LY_SUCCESS, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 300 | assert_null(buf); |
| 301 | assert_ptr_equal(&str[-1], out); |
| 302 | assert_int_equal(0, dynamic); |
| 303 | assert_int_equal(0, len); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 304 | assert_true(str[0] == '\0'); /* everything eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 305 | assert_int_equal(LYXML_ATTRIBUTE, ctx.status); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 306 | |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 307 | /* empty element content - only formating before defining child */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 308 | ctx.status = LYXML_ELEM_CONTENT; |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 309 | str = "\n <"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 310 | assert_int_equal(LY_EINVAL, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 311 | assert_null(buf); |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 312 | assert_string_equal("<", str); |
| 313 | |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 314 | /* empty element content is invalid - missing content terminating character < */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 315 | ctx.status = LYXML_ELEM_CONTENT; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 316 | str = ""; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 317 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 318 | assert_null(buf); |
Radek Krejci | 0a1d0d4 | 2019-05-16 15:14:51 +0200 | [diff] [blame] | 319 | logbuf_assert("Unexpected end-of-input. Line number 2."); |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 320 | |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 321 | ctx.status = LYXML_ELEM_CONTENT; |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 322 | str = p = "xxx"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 323 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 324 | assert_null(buf); |
Radek Krejci | 0a1d0d4 | 2019-05-16 15:14:51 +0200 | [diff] [blame] | 325 | logbuf_assert("Unexpected end-of-input. Line number 2."); |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 326 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 327 | |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 328 | /* valid strings */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 329 | ctx.status = LYXML_ELEM_CONTENT; |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 330 | str = "€𠜎Øn \n<&"'> ROK<"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 331 | assert_int_equal(LY_SUCCESS, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 332 | assert_int_not_equal(0, dynamic); |
| 333 | assert_non_null(buf); |
| 334 | assert_ptr_equal(out, buf); |
| 335 | assert_int_equal(22, buf_len); |
| 336 | assert_int_equal(21, len); |
| 337 | assert_string_equal("€𠜎Øn \n<&\"\'> ROK", buf); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 338 | assert_string_equal("<", str); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 339 | assert_int_equal(LYXML_ELEMENT, ctx.status); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 340 | |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 341 | /* test using n-bytes UTF8 hexadecimal code points */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 342 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 343 | str = "\'$¢€𐍈\'"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 344 | assert_int_equal(LY_SUCCESS, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
| 345 | assert_int_not_equal(0, dynamic); |
| 346 | assert_non_null(buf); |
| 347 | assert_ptr_equal(out, buf); |
Radek Krejci | d5f2b5f | 2018-10-11 10:54:36 +0200 | [diff] [blame] | 348 | assert_int_equal(22, buf_len); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 349 | assert_int_equal(10, len); |
| 350 | assert_string_equal("$¢€𐍈", buf); |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 351 | assert_int_equal(LYXML_ATTRIBUTE, ctx.status); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 352 | |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 353 | free(buf); |
| 354 | buf = NULL; |
| 355 | |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 356 | /* invalid characters in string */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 357 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 358 | str = p = "\'R\'"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 359 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 360 | logbuf_assert("Invalid character sequence \"'\", expected ;. Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 361 | assert_null(buf); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 362 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 363 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 364 | str = p = "\"R\""; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 365 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 366 | logbuf_assert("Invalid character sequence \"\"\", expected ;. Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 367 | assert_null(buf); |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 368 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 369 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 370 | str = p = "\"&nonsence;\""; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 371 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 372 | logbuf_assert("Entity reference \"&nonsence;\" not supported, only predefined references allowed. Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 373 | assert_null(buf); |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 374 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 375 | ctx.status = LYXML_ELEM_CONTENT; |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 376 | str = p = "&#o122;"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 377 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 378 | logbuf_assert("Invalid character reference \"&#o122;\". Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 379 | assert_null(buf); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 380 | assert_ptr_equal(p, str); /* input data not eaten */ |
| 381 | |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 382 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 383 | str = p = "\'\'"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 384 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 385 | logbuf_assert("Invalid character reference \"\'\" (0x00000006). Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 386 | assert_null(buf); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 387 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 388 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 389 | str = p = "\'\'"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 390 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 391 | logbuf_assert("Invalid character reference \"\'\" (0x0000fdd0). Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 392 | assert_null(buf); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 393 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | b189064 | 2018-10-03 14:05:40 +0200 | [diff] [blame] | 394 | ctx.status = LYXML_ATTR_CONTENT; |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 395 | str = p = "\'\'"; |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 396 | assert_int_equal(LY_EVALID, lyxml_get_string(&ctx, &str, &buf, &buf_len, &out, &len, &dynamic)); |
Radek Krejci | 117d208 | 2018-09-26 10:05:14 +0200 | [diff] [blame] | 397 | logbuf_assert("Invalid character reference \"\'\" (0x0000ffff). Line number 3."); |
Radek Krejci | d70d107 | 2018-10-09 14:20:47 +0200 | [diff] [blame] | 398 | assert_null(buf); |
Radek Krejci | ed6c6ad | 2018-09-26 09:10:18 +0200 | [diff] [blame] | 399 | assert_ptr_equal(p, str); /* input data not eaten */ |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 400 | } |
| 401 | |
Radek Krejci | 4b74d5e | 2018-09-26 14:30:55 +0200 | [diff] [blame] | 402 | static void |
| 403 | test_ns(void **state) |
| 404 | { |
| 405 | (void) state; /* unused */ |
| 406 | |
Radek Krejci | 4b74d5e | 2018-09-26 14:30:55 +0200 | [diff] [blame] | 407 | const struct lyxml_ns *ns; |
| 408 | |
| 409 | struct lyxml_context ctx; |
| 410 | memset(&ctx, 0, sizeof ctx); |
| 411 | ctx.line = 1; |
| 412 | |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 413 | /* simulate adding open element1 into context */ |
| 414 | ctx.elements.count++; |
| 415 | /* processing namespace definitions */ |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 416 | assert_int_equal(LY_SUCCESS, lyxml_ns_add(&ctx, NULL, 0, strdup("urn:default"))); |
| 417 | assert_int_equal(LY_SUCCESS, lyxml_ns_add(&ctx, "nc", 2, strdup("urn:nc1"))); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 418 | /* simulate adding open element2 into context */ |
| 419 | ctx.elements.count++; |
| 420 | /* processing namespace definitions */ |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 421 | assert_int_equal(LY_SUCCESS, lyxml_ns_add(&ctx, "nc", 2, strdup("urn:nc2"))); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 422 | assert_int_equal(3, ctx.ns.count); |
| 423 | assert_int_not_equal(0, ctx.ns.size); |
Radek Krejci | 4b74d5e | 2018-09-26 14:30:55 +0200 | [diff] [blame] | 424 | |
| 425 | ns = lyxml_ns_get(&ctx, NULL, 0); |
| 426 | assert_non_null(ns); |
| 427 | assert_null(ns->prefix); |
| 428 | assert_string_equal("urn:default", ns->uri); |
| 429 | |
| 430 | ns = lyxml_ns_get(&ctx, "nc", 2); |
| 431 | assert_non_null(ns); |
| 432 | assert_string_equal("nc", ns->prefix); |
| 433 | assert_string_equal("urn:nc2", ns->uri); |
| 434 | |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 435 | /* simulate closing element2 */ |
| 436 | ctx.elements.count--; |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 437 | assert_int_equal(LY_SUCCESS, lyxml_ns_rm(&ctx)); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 438 | assert_int_equal(2, ctx.ns.count); |
Radek Krejci | 4b74d5e | 2018-09-26 14:30:55 +0200 | [diff] [blame] | 439 | |
| 440 | ns = lyxml_ns_get(&ctx, "nc", 2); |
| 441 | assert_non_null(ns); |
| 442 | assert_string_equal("nc", ns->prefix); |
| 443 | assert_string_equal("urn:nc1", ns->uri); |
| 444 | |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 445 | /* simulate closing element1 */ |
| 446 | ctx.elements.count--; |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 447 | assert_int_equal(LY_SUCCESS, lyxml_ns_rm(&ctx)); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 448 | assert_int_equal(0, ctx.ns.count); |
Radek Krejci | 4b74d5e | 2018-09-26 14:30:55 +0200 | [diff] [blame] | 449 | |
| 450 | assert_null(lyxml_ns_get(&ctx, "nc", 2)); |
| 451 | assert_null(lyxml_ns_get(&ctx, NULL, 0)); |
| 452 | } |
| 453 | |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 454 | static void |
| 455 | test_ns2(void **state) |
| 456 | { |
| 457 | (void) state; /* unused */ |
| 458 | |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 459 | struct lyxml_context ctx; |
| 460 | memset(&ctx, 0, sizeof ctx); |
| 461 | ctx.line = 1; |
| 462 | |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 463 | /* simulate adding open element1 into context */ |
| 464 | ctx.elements.count++; |
| 465 | /* default namespace defined in parent element1 */ |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 466 | assert_int_equal(LY_SUCCESS, lyxml_ns_add(&ctx, NULL, 0, strdup("urn:default"))); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 467 | assert_int_equal(1, ctx.ns.count); |
| 468 | /* going into child element1 */ |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 469 | /* simulate adding open element1 into context */ |
| 470 | ctx.elements.count++; |
| 471 | /* no namespace defined, going out (first, simulate closing of so far open element) */ |
| 472 | ctx.elements.count--; |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 473 | assert_int_equal(LY_SUCCESS, lyxml_ns_rm(&ctx)); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 474 | assert_int_equal(1, ctx.ns.count); |
| 475 | /* nothing else, going out of the parent element1 (first, simulate closing of so far open element) */ |
| 476 | ctx.elements.count--; |
Radek Krejci | 17a78d8 | 2019-05-15 15:49:55 +0200 | [diff] [blame] | 477 | assert_int_equal(LY_SUCCESS, lyxml_ns_rm(&ctx)); |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 478 | assert_int_equal(0, ctx.ns.count); |
| 479 | } |
| 480 | |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 481 | int main(void) |
| 482 | { |
| 483 | const struct CMUnitTest tests[] = { |
Radek Krejci | d972c25 | 2018-09-25 13:23:39 +0200 | [diff] [blame] | 484 | cmocka_unit_test_setup(test_element, logger_setup), |
| 485 | cmocka_unit_test_setup(test_attribute, logger_setup), |
Radek Krejci | 7a7fa90 | 2018-09-25 17:08:21 +0200 | [diff] [blame] | 486 | cmocka_unit_test_setup(test_text, logger_setup), |
Radek Krejci | 4b74d5e | 2018-09-26 14:30:55 +0200 | [diff] [blame] | 487 | cmocka_unit_test_setup(test_ns, logger_setup), |
Radek Krejci | e0734d2 | 2019-04-05 15:54:28 +0200 | [diff] [blame] | 488 | cmocka_unit_test_setup(test_ns2, logger_setup), |
Radek Krejci | d91dbaf | 2018-09-21 15:51:39 +0200 | [diff] [blame] | 489 | }; |
| 490 | |
| 491 | return cmocka_run_group_tests(tests, NULL, NULL); |
| 492 | } |