Debian Codegraph @

src/libxml_reporter.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/libxml_reporter.c`/include <cgreen/breadcrumb.h>cxx . . $ `<file>/include/cgreen/breadcrumb.h`/
2 #include <stdio.h>
3 #include <stdint.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <errno.h>
7 #include <inttypes.h>
8 #include <assert.h>
9
10 #include <libxml/xmlwriter.h>
11 #include <libxml/encoding.h>
12 #include <libxml/xmlIO.h>
13 #include <libxml/tree.h>
14
15 #include "libxml_reporter_internal.h"cxx . . $ `<file>/src/libxml_reporter_internal.h`/
16
17 #ifdef __ANDROID__
18 #include "cgreen/internal/android_headers/androidcompat.h"
19 #endif // #ifdef __ANDROID__
20
21 typedef structcxx . . $ $anonymous_type_5fa26bf8c5755000_0# {
22 XmlPrintercxx . . $ XmlPrinter# *printercxx . . $ $anonymous_type_5fa26bf8c5755000_0#printer.;
23 int segment_countcxx . . $ $anonymous_type_5fa26bf8c5755000_0#segment_count.;
24 } XmlMemocxx . . $ XmlMemo#;
25
26 #define XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!(x) (BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! x)
27
28 static void xml_reporter_start_suitecxx . . $ xml_reporter_start_suite(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *name,
29 int count);
30 static void xml_reporter_start_testcxx . . $ xml_reporter_start_test(499118f5be74126f).(TestReportercxx . . $ TestReporter# *reporter, const char *name);
31 static void xml_reporter_finish_testcxx . . $ xml_reporter_finish_test(4c7a3a1bff8d25e8).(TestReportercxx . . $ TestReporter# *reporter, const char *filename,
32 int line, const char *message);
33 static void xml_reporter_finish_suitecxx . . $ xml_reporter_finish_suite(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *filename,
34 int line);
35 static void xml_show_skipcxx . . $ xml_show_skip(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line);
36 static void xml_show_failcxx . . $ xml_show_fail(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line,
37 const char *message, va_listcxx . . $ va_list# arguments);
38 static void xml_show_incompletecxx . . $ xml_show_incomplete(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *filename,
39 int line, const char *message, va_listcxx . . $ va_list# arguments);
40
41 static const char *file_prefixcxx . . $ file_prefix.;
42
43 static int default_printercxx . . $ default_printer(57df01901802f030).(xmlDocPtrcxx . . $ xmlDocPtr# doc);
44
45 void set_libxml_reporter_printercxx . . $ set_libxml_reporter_printer(3d8c4a835df8455d).(TestReportercxx . . $ TestReporter# *reporter, XmlPrintercxx . . $ XmlPrinter# *printer)
46 {
47 XmlMemocxx . . $ XmlMemo# *memo = (XmlMemocxx . . $ XmlMemo#*)reporter->memocxx . . $ TestReporter_#memo.;
48 memo->printercxx . . $ $anonymous_type_5fa26bf8c5755000_0#printer. = printer;
49 }
50
51 TestReportercxx . . $ TestReporter# *create_libxml_reportercxx . . $ create_libxml_reporter(7e5a2d32a0879f75).(const char *prefix) {
52 TestReportercxx . . $ TestReporter# *reporter;
53 XmlMemocxx . . $ XmlMemo# *memo;
54
55 reporter = create_reportercxx . . $ create_reporter(a6a8ef953e197a65).();
56 if (reporter == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
57 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
58 }
59
60 memo = (XmlMemocxx . . $ XmlMemo# *) malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(XmlMemocxx . . $ XmlMemo#));
61 if (memo == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
62 destroy_reportercxx . . $ destroy_reporter(1083e9dac9de8fd0).(reporter);
63 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
64 }
65 reporter->memocxx . . $ TestReporter_#memo. = memo;
66 memo->printercxx . . $ $anonymous_type_5fa26bf8c5755000_0#printer. = &default_printercxx . . $ default_printer(57df01901802f030).;
67
68 file_prefixcxx . . $ file_prefix. = prefix;
69 reporter->start_suitecxx . . $ TestReporter_#start_suite. = &xml_reporter_start_suitecxx . . $ xml_reporter_start_suite(8490445735e6bcce).;
70 reporter->start_testcxx . . $ TestReporter_#start_test. = &xml_reporter_start_testcxx . . $ xml_reporter_start_test(499118f5be74126f).;
71 reporter->show_failcxx . . $ TestReporter_#show_fail. = &xml_show_failcxx . . $ xml_show_fail(fabf0cf23815ef65).;
72 reporter->show_skipcxx . . $ TestReporter_#show_skip. = &xml_show_skipcxx . . $ xml_show_skip(8490445735e6bcce).;
73 reporter->show_incompletecxx . . $ TestReporter_#show_incomplete. = &xml_show_incompletecxx . . $ xml_show_incomplete(fabf0cf23815ef65).;
74 reporter->finish_testcxx . . $ TestReporter_#finish_test. = &xml_reporter_finish_testcxx . . $ xml_reporter_finish_test(4c7a3a1bff8d25e8).;
75 reporter->finish_suitecxx . . $ TestReporter_#finish_suite. = &xml_reporter_finish_suitecxx . . $ xml_reporter_finish_suite(8490445735e6bcce).;
76 return reporter;
77 }
78
79 #ifndef PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!
80 #define PATH_MAX 4096
81 #endif
82 static char suite_pathcxx . . $ suite_path.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!];
83
84 static void print_path_separator_if_neededcxx . . $ print_path_separator_if_needed(11b0e290e57a7e53).(int *more_segments) {
85 if (*more_segments > 0) {
86 strcatcxx . . $ strcat(b7b3a83273496486).(suite_pathcxx . . $ suite_path., "/");
87 (*more_segments)--;
88 }
89 }
90
91 static void print_path_segment_walkercxx . . $ print_path_segment_walker(4611f29f2f861a56).(const char *segment, void *void_memo) {
92 XmlMemocxx . . $ XmlMemo# *memo = (XmlMemocxx . . $ XmlMemo# *)void_memo;
93
94 strncatcxx . . $ strncat(255158a415b673b0).(suite_pathcxx . . $ suite_path., segment, sizeof(suite_pathcxx . . $ suite_path.)-strlencxx . . $ strlen(751346f8406fd082).(suite_pathcxx . . $ suite_path.)-1);
95 print_path_separator_if_neededcxx . . $ print_path_separator_if_needed(11b0e290e57a7e53).(&memo->segment_countcxx . . $ $anonymous_type_5fa26bf8c5755000_0#segment_count.);
96 }
97
98 static void strcat_path_segmentcxx . . $ strcat_path_segment(4611f29f2f861a56).(const char *segment, void *more_segments) {
99 (void)more_segments;
100 if (suite_pathcxx . . $ suite_path.[0] != '\0') strcatcxx . . $ strcat(b7b3a83273496486).(suite_pathcxx . . $ suite_path., "-");
101 strncatcxx . . $ strncat(255158a415b673b0).(suite_pathcxx . . $ suite_path., segment, sizeof(suite_pathcxx . . $ suite_path.)-strlencxx . . $ strlen(751346f8406fd082).(suite_pathcxx . . $ suite_path.)-1);
102 }
103
104 static void add_suite_namecxx . . $ add_suite_name(85c52e162fed56f9).(const char *suite_name) {
105 if (suite_pathcxx . . $ suite_path.[0] != '\0')
106 strcatcxx . . $ strcat(b7b3a83273496486).(suite_pathcxx . . $ suite_path., "-");
107 strncatcxx . . $ strncat(255158a415b673b0).(suite_pathcxx . . $ suite_path., suite_name, sizeof(suite_pathcxx . . $ suite_path.)-strlencxx . . $ strlen(751346f8406fd082).(suite_pathcxx . . $ suite_path.)-1);
108 }
109
110 #define NESTED_SUITE_MAXcxx . . $ `src/libxml_reporter.c:110:9`! 100
111 struct xml_suite_contextcxx . . $ xml_suite_context# {
112 xmlDocPtrcxx . . $ xmlDocPtr# doccxx . . $ xml_suite_context#doc.;
113 xmlNodePtrcxx . . $ xmlNodePtr# suitecxx . . $ xml_suite_context#suite., curTestcxx . . $ xml_suite_context#curTest.;
114 FILEcxx . . $ FILE#* outFilecxx . . $ xml_suite_context#outFile.;
115 uint32_tcxx . . $ uint32_t# suite_durationcxx . . $ xml_suite_context#suite_duration.;
116 };
117 static struct xml_suite_contextcxx . . $ xml_suite_context# context_stackcxx . . $ context_stack.[NESTED_SUITE_MAXcxx . . $ `src/libxml_reporter.c:110:9`!];
118 static int context_stack_pcxx . . $ context_stack_p. = 0;
119
120 /*
121 * The table below is taken from the "Non-restricted characters" section of
122 * https://en.wikipedia.org/wiki/Valid_characters_in_XML
123 */
124 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! isNonRestrictedXMLCharcxx . . $ isNonRestrictedXMLChar(dfa6e707f7696010).(unsigned int c) {
125 return (c == 0x09u || c == 0x0Au || c == 0x0Du ||
126 (c >= 0x20u && c <= 0x7Eu) || c == 0x85u ||
127 (c >= 0xA0u && c <= 0xD7FFu) ||
128 (c >= 0xE000u && c <= 0xFDCFu) ||
129 (c >= 0xFDF0u && c <= 0xFFFDu) ||
130 (c >= 0x10000u && c <= 0x1FFFDu) ||
131 (c >= 0x20000u && c <= 0x2FFFDu) ||
132 (c >= 0x30000u && c <= 0x3FFFDu) ||
133 (c >= 0x40000u && c <= 0x4FFFDu) ||
134 (c >= 0x50000u && c <= 0x5FFFDu) ||
135 (c >= 0x60000u && c <= 0x6FFFDu) ||
136 (c >= 0x70000u && c <= 0x7FFFDu) ||
137 (c >= 0x80000u && c <= 0x8FFFDu) ||
138 (c >= 0x90000u && c <= 0x9FFFDu) ||
139 (c >= 0xA0000u && c <= 0xAFFFDu) ||
140 (c >= 0xB0000u && c <= 0xBFFFDu) ||
141 (c >= 0xC0000u && c <= 0xCFFFDu) ||
142 (c >= 0xD0000u && c <= 0xDFFFDu) ||
143 (c >= 0xE0000u && c <= 0xEFFFDu) ||
144 (c >= 0xF0000u && c <= 0xFFFFDu) ||
145 (c >= 0x100000u && c <= 0x10FFFD));
146 }
147
148 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! isOverlongUTF8cxx . . $ isOverlongUTF8(5d6186ea39519812).(unsigned int ucs, int len)
149 {
150 return ((ucs <= 0x7f && len > 1) ||
151 (ucs <= 0x7ff && len > 2) ||
152 (ucs <= 0xffff && len > 3) ||
153 (ucs <= 0x10ffff && len > 4));
154 }
155
156 /*
157 * Return a copy of the argument prepared to be used as an attribute value.
158 * The produced result is not necessary convertable back to the original set
159 * of bytes.
160 */
161 static xmlCharcxx . . $ xmlChar#* xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(const char *str) {
162 size_t len = strlencxx . . $ strlen(751346f8406fd082).(str);
163 /*
164 * The worst-case length of the output is 4 times the input length (if
165 * every input byte has to be escaped) plus 1 for the terminating NUL
166 * character
167 */
168 size_t retLen = len * 4 + 1;
169 xmlCharcxx . . $ xmlChar#* ret = xmlMalloccxx . . $ xmlMalloc.(retLen), *retPos = ret, *retEnd = ret + retLen;
170 if (!ret) {
171 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "memory allocation failure in %s\n", __func__);
172 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
173 }
174
175 const unsigned char *it = (const unsigned char*)str;
176 const unsigned char *itEnd = it + len;
177 while (*it) {
178 int utfLen = itEnd - it;
179 int ucs = xmlGetUTF8Charcxx . . $ xmlGetUTF8Char(a22006a682b0ead2).(it, &utfLen);
180 if (ucs != -1) {
181 if (!isOverlongUTF8cxx . . $ isOverlongUTF8(5d6186ea39519812).(ucs, utfLen)) {
182 if (isNonRestrictedXMLCharcxx . . $ isNonRestrictedXMLChar(dfa6e707f7696010).(ucs)) {
183 /* Valid UTF8 sequence of an allowed character */
184 while (utfLen--)
185 *retPos++ = *it++;
186 } else {
187 xmlStrPrintfcxx . . $ xmlStrPrintf(afa7041cac7e84de).(retPos, retEnd - retPos, "&x%x;", ucs);
188 }
189 } else {
190 /* Disallowed character or overlong UTF8, escape entire sequence */
191 for(int i = 0;i < utfLen;++i) {
192 xmlStrPrintfcxx . . $ xmlStrPrintf(afa7041cac7e84de).(retPos, retEnd-retPos, "\\x%.2" PRIx8cxx . . $ `<external>/15933738808807975373/inttypes.h:123:10`!, *it);
193 retPos += 4;
194 ++it;
195 }
196 }
197 } else {
198 /* Invalid UTF8, escape one byte then try to parse rest of input as UTF8 again */
199 xmlStrPrintfcxx . . $ xmlStrPrintf(afa7041cac7e84de).(retPos, retEnd-retPos, "\\x%.2" PRIx8cxx . . $ `<external>/15933738808807975373/inttypes.h:123:10`!, *it);
200 retPos += 4;
201 ++it;
202 }
203 }
204
205 *retPos = '\0';
206 return ret;
207 }
208
209 static void xml_reporter_start_suitecxx . . $ xml_reporter_start_suite(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *suitename, int count) {
210 char filename[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!];
211 int segment_decrementer = reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb.->depthcxx . . $ CgreenBreadcrumb_#depth.;
212 XmlMemocxx . . $ XmlMemo# *memo = (XmlMemocxx . . $ XmlMemo# *)reporter->memocxx . . $ TestReporter_#memo.;
213 if (context_stack_pcxx . . $ context_stack_p. >= NESTED_SUITE_MAXcxx . . $ `src/libxml_reporter.c:110:9`!)
214 abortcxx . . $ abort(8df32a62017fbbf6).();
215 struct xml_suite_contextcxx . . $ xml_suite_context# *ctx = &context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.++];
216
217 FILEcxx . . $ FILE# *out;
218
219 (void)count; /* UNUSED */
220
221 reporter->passescxx . . $ TestReporter_#passes. = 0;
222 reporter->failurescxx . . $ TestReporter_#failures. = 0;
223 reporter->skipscxx . . $ TestReporter_#skips. = 0;
224 reporter->exceptionscxx . . $ TestReporter_#exceptions. = 0;
225
226 suite_pathcxx . . $ suite_path.[0] = '\0';
227 walk_breadcrumbcxx . . $ walk_breadcrumb(e1235c45da9c923a).(reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb., strcat_path_segmentcxx . . $ strcat_path_segment(4611f29f2f861a56)., &segment_decrementer);
228 add_suite_namecxx . . $ add_suite_name(85c52e162fed56f9).(suitename);
229
230 if (snprintfcxx . . $ snprintf(ea502d73e74c754c).(filename, sizeof(filename), "%s-%s.xml", file_prefixcxx . . $ file_prefix., suite_pathcxx . . $ suite_path.) >= (int)sizeof(filename)) {
231 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "filename truncated; exceeds PATH_MAX (= %d)\n", PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!);
232 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
233 }
234 if (memo->printercxx . . $ $anonymous_type_5fa26bf8c5755000_0#printer. == default_printercxx . . $ default_printer(57df01901802f030).) {
235 // If we're really printing to files, then open one...
236 out = fopencxx . . $ fopen(82ec0787cd37e0a3).(filename, "w");
237 if (!out) {
238 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "could not open %s: %s\r\n", filename, strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
239 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
240 }
241 ctx->outFilecxx . . $ xml_suite_context#outFile. = out;
242 }
243
244 ctx->suite_durationcxx . . $ xml_suite_context#suite_duration. = 0;
245 ctx->doccxx . . $ xml_suite_context#doc. = xmlNewDoccxx . . $ xmlNewDoc(6ad5ddcc52642397).(XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("1.0"));
246 ctx->suitecxx . . $ xml_suite_context#suite. = xmlNewNodecxx . . $ xmlNewNode(cc9f3f2e425bac4).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("testsuite"));
247 xmlCharcxx . . $ xmlChar# *xml_suite_path = xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(suite_pathcxx . . $ suite_path.);
248 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(ctx->suitecxx . . $ xml_suite_context#suite., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("name"), xml_suite_path);
249 xmlFreecxx . . $ xmlFree.(xml_suite_path);
250 xmlDocSetRootElementcxx . . $ xmlDocSetRootElement(ad0e42d5f79fdac5).(ctx->doccxx . . $ xml_suite_context#doc., ctx->suitecxx . . $ xml_suite_context#suite.);
251
252 reporter_start_suitecxx . . $ reporter_start_suite(8490445735e6bcce).(reporter, suitename, 0);
253 }
254
255
256 /* Accumulate output from the actual test (the "<testcase>" nodes) in
257 a file since the tests usually are run in a child processes, so
258 there is no simple way to save output from it and then use it in
259 the parent (start_test() and finish_test() are run from parent) */
260
261 static FILEcxx . . $ FILE# *child_output_tmpfilecxx . . $ child_output_tmpfile.;
262 static xmlTextWriterPtrcxx . . $ xmlTextWriterPtr# child_output_writercxx . . $ child_output_writer.;
263
264 static void xml_reporter_start_testcxx . . $ xml_reporter_start_test(499118f5be74126f).(TestReportercxx . . $ TestReporter# *reporter, const char *testname) {
265 XmlMemocxx . . $ XmlMemo# *memo = (XmlMemocxx . . $ XmlMemo# *)reporter->memocxx . . $ TestReporter_#memo.;
266 struct xml_suite_contextcxx . . $ xml_suite_context# *ctx = &context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.-1];
267
268 ctx->curTestcxx . . $ xml_suite_context#curTest. = xmlNewChildcxx . . $ xmlNewChild(4c74f4d7754e7bc8).(ctx->suitecxx . . $ xml_suite_context#suite., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("testcase"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
269 xmlCharcxx . . $ xmlChar# *xml_testname = xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(testname);
270 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(ctx->curTestcxx . . $ xml_suite_context#curTest., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("name"), xml_testname);
271 xmlFreecxx . . $ xmlFree.(xml_testname);
272
273 memo->segment_countcxx . . $ $anonymous_type_5fa26bf8c5755000_0#segment_count. = reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb.->depthcxx . . $ CgreenBreadcrumb_#depth. - 1;
274 suite_pathcxx . . $ suite_path.[0] = '\0';
275 walk_breadcrumbcxx . . $ walk_breadcrumb(e1235c45da9c923a).(reporter->breadcrumbcxx . . $ TestReporter_#breadcrumb., print_path_segment_walkercxx . . $ print_path_segment_walker(4611f29f2f861a56)., memo);
276 xmlCharcxx . . $ xmlChar#* xml_suite_path = xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(suite_pathcxx . . $ suite_path.);
277 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(ctx->curTestcxx . . $ xml_suite_context#curTest., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("classname"), xml_suite_path);
278 xmlFreecxx . . $ xmlFree.(xml_suite_path);
279
280 reporter_start_testcxx . . $ reporter_start_test(499118f5be74126f).(reporter, testname);
281
282 child_output_tmpfilecxx . . $ child_output_tmpfile. = tmpfilecxx . . $ tmpfile(3637adb0f06093ef).();
283 xmlOutputBufferPtrcxx . . $ xmlOutputBufferPtr# tmpfileBuf
284 = xmlOutputBufferCreateFilecxx . . $ xmlOutputBufferCreateFile(4a183c04302c680).(child_output_tmpfilecxx . . $ child_output_tmpfile.,
285 xmlGetCharEncodingHandlercxx . . $ xmlGetCharEncodingHandler(d9f066c27b94404a).(XML_CHAR_ENCODING_UTF8cxx . . $ XML_CHAR_ENCODING_UTF8.));
286 child_output_writercxx . . $ child_output_writer. = xmlNewTextWritercxx . . $ xmlNewTextWriter(d29ea22b6b3d18e7).(tmpfileBuf);
287 }
288
289
290 static void xml_show_skipcxx . . $ xml_show_skip(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line) {
291 (void)file;
292 (void)line;
293 (void)reporter;
294
295 xmlTextWriterStartElementcxx . . $ xmlTextWriterStartElement(bf445c147f693955).(child_output_writercxx . . $ child_output_writer., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("skipped"));
296 xmlTextWriterEndElementcxx . . $ xmlTextWriterEndElement(7e81f973a4eb6684).(child_output_writercxx . . $ child_output_writer.); // </skipped>
297 xmlTextWriterFlushcxx . . $ xmlTextWriterFlush(7e81f973a4eb6684).(child_output_writercxx . . $ child_output_writer.);
298 }
299
300 static xmlCharcxx . . $ xmlChar#* xml_secure_vprintcxx . . $ xml_secure_vprint(722af53d1056f78d).(const char *format, va_listcxx . . $ va_list# ap)
301 {
302 char buf[100];
303 char *msg = buf;
304 const size_t len = sizeof(buf);
305
306 va_listcxx . . $ va_list# ap_store;
307 va_copycxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stdarg.h:57:9`!(ap_store, ap);
308 int res = vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(msg, len, format, ap_store);
309 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stdarg.h:53:9`!(ap_store);
310 if (res < 0) {
311 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "vsnprintf failed in xml_secure_vprint: %s\n", strerrorcxx . . $ strerror(ff224f080444ee45).(res));
312 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
313 }
314
315 if ((unsigned)res >= len) {
316 size_t msglen = res+1;
317 msg = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(msglen);
318 if (!msg) {
319 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "memory allocation failure in xml_secure_vprint\n");
320 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
321 }
322 res = vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(msg, msglen, format, ap);
323 if (res < 0) {
324 freecxx . . $ free(5d22bdacc48458e8).(msg);
325 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "vsnprintf failed in xml_secure_vprint: %s\n", strerrorcxx . . $ strerror(ff224f080444ee45).(res));
326 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
327 }
328 if ((unsigned)res >= msglen) {
329 // What? Did format get longer while allocating msg?
330 freecxx . . $ free(5d22bdacc48458e8).(msg);
331 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "vsnprintf failed in xml_secure_vprint: nondeterministic message length\n");
332 exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!);
333 }
334 }
335
336 xmlCharcxx . . $ xmlChar# *xml_msg = xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(msg);
337 if (msg != buf) freecxx . . $ free(5d22bdacc48458e8).(msg);
338 return xml_msg;
339 }
340
341 static void xml_show_failcxx . . $ xml_show_fail(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *file, int line,
342 const char *message, va_listcxx . . $ va_list# arguments) {
343 (void)reporter;
344
345 xmlTextWriterStartElementcxx . . $ xmlTextWriterStartElement(bf445c147f693955).(child_output_writercxx . . $ child_output_writer., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("failure"));
346
347 xmlCharcxx . . $ xmlChar# *xml_str = xml_secure_vprintcxx . . $ xml_secure_vprint(722af53d1056f78d).(message, arguments);
348 xmlTextWriterWriteAttributecxx . . $ xmlTextWriterWriteAttribute(ea634d2c1b0a45f7).(child_output_writercxx . . $ child_output_writer., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("message"), xml_str);
349 xmlFreecxx . . $ xmlFree.(xml_str);
350
351 xmlTextWriterStartElementcxx . . $ xmlTextWriterStartElement(bf445c147f693955).(child_output_writercxx . . $ child_output_writer., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("location"));
352 xmlCharcxx . . $ xmlChar# *xml_file = xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(file);
353 xmlTextWriterWriteAttributecxx . . $ xmlTextWriterWriteAttribute(ea634d2c1b0a45f7).(child_output_writercxx . . $ child_output_writer., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("file"), xml_file);
354 xmlFreecxx . . $ xmlFree.(xml_file);
355 xmlTextWriterWriteFormatAttributecxx . . $ xmlTextWriterWriteFormatAttribute(7505d83acb2f1180).(child_output_writercxx . . $ child_output_writer., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("line"), "%d", line);
356 xmlTextWriterEndElementcxx . . $ xmlTextWriterEndElement(7e81f973a4eb6684).(child_output_writercxx . . $ child_output_writer.); // </location>
357 xmlTextWriterEndElementcxx . . $ xmlTextWriterEndElement(7e81f973a4eb6684).(child_output_writercxx . . $ child_output_writer.); // </failure>
358 xmlTextWriterFlushcxx . . $ xmlTextWriterFlush(7e81f973a4eb6684).(child_output_writercxx . . $ child_output_writer.);
359 }
360
361 static xmlAttrPtrcxx . . $ xmlAttrPtr# xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(xmlNodePtrcxx . . $ xmlNodePtr# node, const xmlCharcxx . . $ xmlChar#* name, const char *format, ...)
362 {
363 va_listcxx . . $ va_list# vargs;
364 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stdarg.h:51:9`!(vargs, format);
365 xmlCharcxx . . $ xmlChar# *xml_str = xml_secure_vprintcxx . . $ xml_secure_vprint(722af53d1056f78d).(format, vargs);
366 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stdarg.h:53:9`!(vargs);
367
368 xmlAttrPtrcxx . . $ xmlAttrPtr# attr = xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(node, name, xml_str);
369 xmlFreecxx . . $ xmlFree.(xml_str);
370
371 return attr;
372 }
373
374 static void xml_show_incompletecxx . . $ xml_show_incomplete(fabf0cf23815ef65).(TestReportercxx . . $ TestReporter# *reporter, const char *filename,
375 int line, const char *message, va_listcxx . . $ va_list# arguments) {
376 (void)reporter;
377
378 struct xml_suite_contextcxx . . $ xml_suite_context# *ctx = &context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.-1];
379
380 xmlNodePtrcxx . . $ xmlNodePtr# errNode = xmlNewChildcxx . . $ xmlNewChild(4c74f4d7754e7bc8).(ctx->curTestcxx . . $ xml_suite_context#curTest., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("error"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
381 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(errNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("type"), XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("Fatal"));
382 if (message) {
383 xmlCharcxx . . $ xmlChar# *xml_msg = xml_secure_vprintcxx . . $ xml_secure_vprint(722af53d1056f78d).(message, arguments);
384 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(errNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("message"), xml_msg);
385 xmlFreecxx . . $ xmlFree.(xml_msg);
386 } else {
387 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(errNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("message"),
388 XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("Test terminated unexpectedly, likely from a non-standard exception or Posix signal"));
389 }
390 xmlNodePtrcxx . . $ xmlNodePtr# locNode = xmlNewChildcxx . . $ xmlNewChild(4c74f4d7754e7bc8).(errNode, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("location"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
391 xmlCharcxx . . $ xmlChar# *xml_filename = xmlEscapePropValuecxx . . $ xmlEscapePropValue(9a9251054631bf19).(filename);
392 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(locNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("file"), xml_filename);
393 xmlFreecxx . . $ xmlFree.(xml_filename);
394 xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(locNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("line"), "%d", line);
395 }
396
397 static void insert_child_resultscxx . . $ insert_child_results(bf278de72bf5147e).(struct xml_suite_contextcxx . . $ xml_suite_context# *ctx) {
398 char childData[4096];
399 fseekcxx . . $ fseek(543fae30d249f6b1).(child_output_tmpfilecxx . . $ child_output_tmpfile., 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!);
400
401 size_t pos = 0, ret;
402 while (!feofcxx . . $ feof(89bc1efcdac0ca22).(child_output_tmpfilecxx . . $ child_output_tmpfile.)) {
403 ret = freadcxx . . $ fread(738fc8ac1d711e58).(childData+pos, 1, sizeof(childData)-pos, child_output_tmpfilecxx . . $ child_output_tmpfile.);
404 if (ferrorcxx . . $ ferror(89bc1efcdac0ca22).(child_output_tmpfilecxx . . $ child_output_tmpfile.)) {
405 abortcxx . . $ abort(8df32a62017fbbf6).();
406 }
407 pos += ret;
408 }
409
410 fclosecxx . . $ fclose(89bc1efcdac0ca22).(child_output_tmpfilecxx . . $ child_output_tmpfile.);
411 if (pos > 0) {
412 childData[pos] = '\0';
413
414 xmlNodePtrcxx . . $ xmlNodePtr# childLst;
415 if (xmlParseBalancedChunkMemoryRecovercxx . . $ xmlParseBalancedChunkMemoryRecover(23a18623c2985e13).(ctx->doccxx . . $ xml_suite_context#doc., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!(childData), &childLst, 1) != 0) {
416 xmlNodePtrcxx . . $ xmlNodePtr# errNode = xmlNewChildcxx . . $ xmlNewChild(4c74f4d7754e7bc8).(ctx->curTestcxx . . $ xml_suite_context#curTest., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("error"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
417 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(errNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("type"), XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("Fatal"));
418 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(errNode, XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("message"),
419 XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("Test result XML truncated or malformed, "
420 "likely from abnormal process termination"));
421 }
422
423 xmlAddChildListcxx . . $ xmlAddChildList(93e65f4d4ebd68bd).(ctx->curTestcxx . . $ xml_suite_context#curTest., childLst);
424 }
425 }
426
427 static void xml_reporter_finish_testcxx . . $ xml_reporter_finish_test(4c7a3a1bff8d25e8).(TestReportercxx . . $ TestReporter# *reporter, const char *filename,
428 int line, const char *message) {
429 struct xml_suite_contextcxx . . $ xml_suite_context# *ctx = &context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.-1];
430
431 reporter_finish_testcxx . . $ reporter_finish_test(4c7a3a1bff8d25e8).(reporter, filename, line, message);
432 xmlFreeTextWritercxx . . $ xmlFreeTextWriter(30c71198a738ce89).(child_output_writercxx . . $ child_output_writer.);
433
434 xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(ctx->curTestcxx . . $ xml_suite_context#curTest., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("time"),
435 "%.5f", (double)reporter->durationcxx . . $ TestReporter_#duration./(double)1000);
436
437 ctx->suite_durationcxx . . $ xml_suite_context#suite_duration. += reporter->durationcxx . . $ TestReporter_#duration.;
438 insert_child_resultscxx . . $ insert_child_results(bf278de72bf5147e).(ctx);
439 }
440
441 static void deleteEmptycxx . . $ deleteEmpty(5712c9d4a25253).(xmlNodePtrcxx . . $ xmlNodePtr# elem)
442 {
443 while (elem != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
444 xmlNodePtrcxx . . $ xmlNodePtr# next = elem->nextcxx . . $ _xmlNode#next.;
445 if (xmlIsBlankNodecxx . . $ xmlIsBlankNode(e01056090f899f66).(elem)) {
446 xmlUnlinkNodecxx . . $ xmlUnlinkNode(5712c9d4a25253).(elem);
447 xmlFreeNodecxx . . $ xmlFreeNode(5712c9d4a25253).(elem);
448 } else if (elem->childrencxx . . $ _xmlNode#children.) {
449 deleteEmptycxx . . $ deleteEmpty(5712c9d4a25253).(elem->childrencxx . . $ _xmlNode#children.);
450 }
451
452 elem = next;
453 }
454 }
455
456 static int default_printercxx . . $ default_printer(57df01901802f030).(xmlDocPtrcxx . . $ xmlDocPtr# doc)
457 {
458 struct xml_suite_contextcxx . . $ xml_suite_context# *ctx = &context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.-1];
459 xmlOutputBufferPtrcxx . . $ xmlOutputBufferPtr# outBuf
460 = xmlOutputBufferCreateFilecxx . . $ xmlOutputBufferCreateFile(4a183c04302c680).(ctx->outFilecxx . . $ xml_suite_context#outFile.,
461 xmlGetCharEncodingHandlercxx . . $ xmlGetCharEncodingHandler(d9f066c27b94404a).(XML_CHAR_ENCODING_UTF8cxx . . $ XML_CHAR_ENCODING_UTF8.));
462 xmlSaveFormatFileTocxx . . $ xmlSaveFormatFileTo(6a35bfc30ffd0f80).(outBuf, doc, "UTF-8", 1);
463
464 return 0;
465 }
466
467 static void xml_reporter_finish_suitecxx . . $ xml_reporter_finish_suite(8490445735e6bcce).(TestReportercxx . . $ TestReporter# *reporter, const char *filename, int line) {
468 XmlMemocxx . . $ XmlMemo# *memo = (XmlMemocxx . . $ XmlMemo# *)reporter->memocxx . . $ TestReporter_#memo.;
469 struct xml_suite_contextcxx . . $ xml_suite_context# *ctx = &context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.-1];
470
471 reporter_finish_suitecxx . . $ reporter_finish_suite(8490445735e6bcce).(reporter, filename, line);
472
473 reporter->total_passescxx . . $ TestReporter_#total_passes. += reporter->passescxx . . $ TestReporter_#passes.;
474 reporter->total_failurescxx . . $ TestReporter_#total_failures. += reporter->failurescxx . . $ TestReporter_#failures.;
475 reporter->total_skipscxx . . $ TestReporter_#total_skips. += reporter->skipscxx . . $ TestReporter_#skips.;
476 reporter->total_exceptionscxx . . $ TestReporter_#total_exceptions. += reporter->exceptionscxx . . $ TestReporter_#exceptions.;
477
478 xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(ctx->suitecxx . . $ xml_suite_context#suite., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("failures"), "%d", reporter->failurescxx . . $ TestReporter_#failures.);
479 xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(ctx->suitecxx . . $ xml_suite_context#suite., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("errors"), "%d", reporter->exceptionscxx . . $ TestReporter_#exceptions.);
480 xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(ctx->suitecxx . . $ xml_suite_context#suite., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("skipped"), "%d", reporter->skipscxx . . $ TestReporter_#skips.);
481 xmlFormatPropcxx . . $ xmlFormatProp(22c88e8d467ffaae).(ctx->suitecxx . . $ xml_suite_context#suite., XMLSTRINGcxx . . $ `src/libxml_reporter.c:26:9`!("time"), "%.5f", (double)ctx->suite_durationcxx . . $ xml_suite_context#suite_duration./(double)1000);
482
483 deleteEmptycxx . . $ deleteEmpty(5712c9d4a25253).(ctx->suitecxx . . $ xml_suite_context#suite.);
484 memo->printercxx . . $ $anonymous_type_5fa26bf8c5755000_0#printer.(ctx->doccxx . . $ xml_suite_context#doc.);
485 xmlFreeDoccxx . . $ xmlFreeDoc(42de24d0ab3f771).(ctx->doccxx . . $ xml_suite_context#doc.);
486 if (context_stack_pcxx . . $ context_stack_p. > 1) {
487 context_stackcxx . . $ context_stack.[context_stack_pcxx . . $ context_stack_p.-2].suite_durationcxx . . $ xml_suite_context#suite_duration. += ctx->suite_durationcxx . . $ xml_suite_context#suite_duration.;
488 }
489 --context_stack_pcxx . . $ context_stack_p.;
490 }