Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
557 lines (417 loc) · 15.9 KB

File metadata and controls

557 lines (417 loc) · 15.9 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
Jun 26, 2011
Jun 26, 2011
21
22
#include <stdio.h>
#include <stdlib.h>
Jun 27, 2011
Jun 27, 2011
23
#include <time.h>
Jun 26, 2011
Jun 26, 2011
24
Jun 23, 2011
Jun 23, 2011
25
26
#include <SDL/SDL.h>
Jun 21, 2011
Jun 21, 2011
27
#include "xml.h"
Jun 28, 2011
Jun 28, 2011
28
#include "logger_helpers.h"
Jun 21, 2011
Jun 21, 2011
30
#include "xml_logger.h"
Jun 28, 2011
Jun 28, 2011
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*! Static strings for XML elements */
const char *documentRoot = "testlog";
const char *parametersElementName = "parameters";
const char *parameterElementName = "parameter";
const char *startTimeElementName = "startTime";
const char *numSuitesElementName = "numSuites";
const char *numTestElementName = "numTests";
const char *numPassedTestsElementName = "numPassedTests";
const char *numFailedTestsElementName = "numFailedTests";
const char *endTimeElementName = "endTime";
const char *totalRuntimeElementName = "totalRuntime";
const char *suiteElementName = "suite";
const char *testsPassedElementName = "testsPassed";
const char *testsFailedElementName = "testsFailed";
const char *testsSkippedElementName = "testsSkipped";
const char *testElementName = "test";
const char *nameElementName = "name";
const char *descriptionElementName = "description";
const char *resultElementName = "result";
const char *assertElementName = "assert";
const char *messageElementName = "message";
const char *timeElementName = "time";
const char *assertSummaryElementName = "assertSummary";
Jun 28, 2011
Jun 28, 2011
55
const char *assertCountElementName = "assertCount";
Jun 28, 2011
Jun 28, 2011
56
57
58
59
60
61
const char *assertsPassedElementName = "assertsPassed";
const char *assertsFailedElementName = "assertsFailed";
const char *logElementName = "log";
/*! Current indentationt level */
Jun 27, 2011
Jun 27, 2011
62
63
64
65
66
67
static int indentLevel;
//! Constants for XMLOuputters EOL parameter
#define YES 1
#define NO 0
Jun 28, 2011
Jun 28, 2011
68
/*! Controls printing the indentation in relation to line breaks */
Jun 27, 2011
Jun 27, 2011
69
70
71
72
73
static int prevEOL = YES;
/*
* Prints out the given xml element etc.
*
Jun 28, 2011
Jun 28, 2011
74
75
* \todo Make the destination of the output changeable (defaults to stdout)
*
Jun 27, 2011
Jun 27, 2011
76
77
78
79
80
* \param identLevel the indent level of the message
* \param EOL will it print end of line character or not
* \param the XML element itself
*
*/
Jun 28, 2011
Jun 28, 2011
81
82
83
84
85
86
87
88
89
void
XMLOutputter(const int currentIdentLevel,
int EOL, const char *message)
{
if(ValidateString(message)) {
int ident = 0;
for( ; ident < currentIdentLevel && prevEOL; ++ident) {
printf(" "); // \todo make configurable?
}
Jun 27, 2011
Jun 27, 2011
90
Jun 28, 2011
Jun 28, 2011
91
prevEOL = EOL;
Jun 27, 2011
Jun 27, 2011
92
Jun 28, 2011
Jun 28, 2011
93
94
95
96
97
98
99
if(EOL) {
fprintf(stdout, "%s\n", message);
} else {
fprintf(stdout, "%s", message);
}
fflush(stdout);
Jun 27, 2011
Jun 27, 2011
100
} else {
Jun 28, 2011
Jun 28, 2011
101
fprintf(stdout, "Error: Tried to output invalid string!");
Jun 27, 2011
Jun 27, 2011
102
}
Jun 27, 2011
Jun 27, 2011
103
Jun 28, 2011
Jun 28, 2011
104
SDL_free(message);
Jun 27, 2011
Jun 27, 2011
105
}
Jun 23, 2011
Jun 23, 2011
106
Jun 21, 2011
Jun 21, 2011
107
void
Jun 30, 2011
Jun 30, 2011
108
109
XMLRunStarted(int parameterCount, char *runnerParameters[], time_t eventTime,
void *data)
Jun 30, 2011
Jun 30, 2011
111
112
113
114
115
116
117
118
119
char *xslStylesheet = "style.xsl";
if(data != NULL) {
char *tmp = (char *)data;
if(SDL_strlen(tmp) > 0) {
xslStylesheet = tmp;
}
}
char *output = XMLOpenDocument(documentRoot, xslStylesheet);
Jun 27, 2011
Jun 27, 2011
120
XMLOutputter(indentLevel++, YES, output);
Jun 23, 2011
Jun 23, 2011
121
Jun 28, 2011
Jun 28, 2011
122
output = XMLOpenElement(parametersElementName);
Jun 27, 2011
Jun 27, 2011
123
124
125
126
127
128
XMLOutputter(indentLevel++, YES, output);
int counter = 0;
for(counter = 0; counter < parameterCount; counter++) {
char *parameter = runnerParameters[counter];
Jun 28, 2011
Jun 28, 2011
129
output = XMLOpenElement(parameterElementName);
Jun 27, 2011
Jun 27, 2011
130
131
132
133
134
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(parameter);
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
135
output = XMLCloseElement(parameterElementName);
Jun 27, 2011
Jun 27, 2011
136
137
138
XMLOutputter(--indentLevel, YES, output);
}
Jun 28, 2011
Jun 28, 2011
139
output = XMLCloseElement(parametersElementName);
Jun 27, 2011
Jun 27, 2011
140
141
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
142
output = XMLOpenElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
143
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
145
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
146
XMLOutputter(indentLevel, NO, output);
Jun 23, 2011
Jun 23, 2011
147
Jun 28, 2011
Jun 28, 2011
148
output = XMLCloseElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
149
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
152
void
Jun 22, 2011
Jun 22, 2011
153
XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
Jun 27, 2011
Jun 27, 2011
154
time_t endTime, double totalRuntime)
Jun 27, 2011
Jun 27, 2011
156
// log suite count
Jun 28, 2011
Jun 28, 2011
157
char *output = XMLOpenElement(numSuitesElementName);
Jun 27, 2011
Jun 27, 2011
158
159
160
161
162
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(suiteCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
163
output = XMLCloseElement(numSuitesElementName);
Jun 27, 2011
Jun 27, 2011
164
165
166
XMLOutputter(--indentLevel, YES, output);
// log test count
Jun 28, 2011
Jun 28, 2011
167
output = XMLOpenElement(numTestElementName);
Jun 27, 2011
Jun 27, 2011
168
169
170
171
172
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
173
output = XMLCloseElement(numTestElementName);
Jun 27, 2011
Jun 27, 2011
174
175
176
XMLOutputter(--indentLevel, YES, output);
// log passed test count
Jun 28, 2011
Jun 28, 2011
177
output = XMLOpenElement(numPassedTestsElementName);
Jun 27, 2011
Jun 27, 2011
178
179
180
181
182
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testPassCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
183
output = XMLCloseElement(numPassedTestsElementName);
Jun 27, 2011
Jun 27, 2011
184
185
186
XMLOutputter(--indentLevel, YES, output);
// log failed test count
Jun 28, 2011
Jun 28, 2011
187
output = XMLOpenElement(numFailedTestsElementName);
Jun 27, 2011
Jun 27, 2011
188
189
190
191
192
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testFailCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
193
output = XMLCloseElement(numFailedTestsElementName);
Jun 27, 2011
Jun 27, 2011
194
195
196
XMLOutputter(--indentLevel, YES, output);
// log end timte
Jun 28, 2011
Jun 28, 2011
197
output = XMLOpenElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
198
199
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
200
output = XMLAddContent(TimestampToString(endTime));
Jun 27, 2011
Jun 27, 2011
201
202
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
203
output = XMLCloseElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
204
205
206
XMLOutputter(--indentLevel, YES, output);
// log total runtime
Jun 28, 2011
Jun 28, 2011
207
output = XMLOpenElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
208
209
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
210
output = XMLAddContent(DoubleToString(totalRuntime));
Jun 27, 2011
Jun 27, 2011
211
212
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
213
output = XMLCloseElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
214
215
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
216
output = XMLCloseDocument(documentRoot);
Jun 27, 2011
Jun 27, 2011
217
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
220
void
Jun 21, 2011
Jun 21, 2011
221
XMLSuiteStarted(const char *suiteName, time_t eventTime)
Jun 28, 2011
Jun 28, 2011
223
char *output = XMLOpenElement(suiteElementName);
Jun 27, 2011
Jun 27, 2011
224
225
XMLOutputter(indentLevel++, YES, output);
Jun 28, 2011
Jun 28, 2011
226
227
228
229
230
231
232
233
234
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(suiteName);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
235
output = XMLOpenElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
236
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
237
Jun 27, 2011
Jun 27, 2011
238
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
239
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
241
output = XMLCloseElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
242
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
245
void
Jun 21, 2011
Jun 21, 2011
246
XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
Jun 27, 2011
Jun 27, 2011
247
time_t endTime, double totalRuntime)
Jun 27, 2011
Jun 27, 2011
249
// log tests passed
Jun 28, 2011
Jun 28, 2011
250
char *output = XMLOpenElement(testsPassedElementName);
Jun 27, 2011
Jun 27, 2011
251
252
253
254
255
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsPassed));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
256
output = XMLCloseElement(testsPassedElementName);
Jun 27, 2011
Jun 27, 2011
257
258
259
XMLOutputter(--indentLevel, YES, output);
// log tests failed
Jun 28, 2011
Jun 28, 2011
260
output = XMLOpenElement(testsFailedElementName);
Jun 27, 2011
Jun 27, 2011
261
262
263
264
265
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsFailed));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
266
output = XMLCloseElement(testsFailedElementName);
Jun 27, 2011
Jun 27, 2011
267
268
269
XMLOutputter(--indentLevel, YES, output);
// log tests skipped
Jun 28, 2011
Jun 28, 2011
270
output = XMLOpenElement(testsSkippedElementName);
Jun 27, 2011
Jun 27, 2011
271
272
273
274
275
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsSkipped));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
276
output = XMLCloseElement(testsSkippedElementName);
Jun 27, 2011
Jun 27, 2011
277
278
279
XMLOutputter(--indentLevel, YES, output);
// log tests skipped
Jun 28, 2011
Jun 28, 2011
280
output = XMLOpenElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
281
282
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
283
output = XMLAddContent(TimestampToString(endTime));
Jun 27, 2011
Jun 27, 2011
284
285
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
286
output = XMLCloseElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
287
288
XMLOutputter(--indentLevel, YES, output);
Jun 27, 2011
Jun 27, 2011
289
// log total runtime
Jun 28, 2011
Jun 28, 2011
290
output = XMLOpenElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
291
292
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
293
output = XMLAddContent(DoubleToString(totalRuntime));
Jun 27, 2011
Jun 27, 2011
294
295
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
296
output = XMLCloseElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
297
298
299
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
300
output = XMLCloseElement(suiteElementName);
Jun 27, 2011
Jun 27, 2011
301
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
304
void
Jun 27, 2011
Jun 27, 2011
305
306
XMLTestStarted(const char *testName, const char *suiteName,
const char *testDescription, time_t startTime)
Jun 28, 2011
Jun 28, 2011
308
char * output = XMLOpenElement(testElementName);
Jun 27, 2011
Jun 27, 2011
309
XMLOutputter(indentLevel++, YES, output);
Jun 23, 2011
Jun 23, 2011
310
311
312
//Attribute attribute = {"test", "value"};
//XMLOpenElementWithAttribute("name", &attribute);
Jun 28, 2011
Jun 28, 2011
313
output = XMLOpenElement(nameElementName);
Jun 27, 2011
Jun 27, 2011
314
XMLOutputter(indentLevel++, NO, output);
Jun 22, 2011
Jun 22, 2011
315
Jun 23, 2011
Jun 23, 2011
316
output = XMLAddContent(testName);
Jun 27, 2011
Jun 27, 2011
317
XMLOutputter(indentLevel, NO, output);
Jun 21, 2011
Jun 21, 2011
318
Jun 28, 2011
Jun 28, 2011
319
output = XMLCloseElement(nameElementName);
Jun 27, 2011
Jun 27, 2011
320
XMLOutputter(--indentLevel, YES, output);
Jun 23, 2011
Jun 23, 2011
321
Jun 28, 2011
Jun 28, 2011
322
output = XMLOpenElement(descriptionElementName);
Jun 27, 2011
Jun 27, 2011
323
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
324
325
output = XMLAddContent(testDescription);
Jun 27, 2011
Jun 27, 2011
326
XMLOutputter(indentLevel, NO, output);
Jun 23, 2011
Jun 23, 2011
327
Jun 28, 2011
Jun 28, 2011
328
output = XMLCloseElement(descriptionElementName);
Jun 27, 2011
Jun 27, 2011
329
330
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
331
output = XMLOpenElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
332
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
333
Jun 27, 2011
Jun 27, 2011
334
output = XMLAddContent(TimestampToString(startTime));
Jun 27, 2011
Jun 27, 2011
335
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
337
output = XMLCloseElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
338
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
341
void
Jun 22, 2011
Jun 22, 2011
342
XMLTestEnded(const char *testName, const char *suiteName,
Jun 27, 2011
Jun 27, 2011
343
int testResult, time_t endTime, double totalRuntime)
Jun 28, 2011
Jun 28, 2011
345
char *output = XMLOpenElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
346
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
347
348
349
if(testResult) {
if(testResult == 2) {
Jun 27, 2011
Jun 27, 2011
350
output = XMLAddContent("failed. No assert");
Jun 26, 2011
Jun 26, 2011
351
352
353
} else {
output = XMLAddContent("failed");
}
Jun 27, 2011
Jun 27, 2011
354
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
355
356
} else {
output = XMLAddContent("passed");
Jun 27, 2011
Jun 27, 2011
357
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
358
}
Jun 27, 2011
Jun 27, 2011
359
Jun 28, 2011
Jun 28, 2011
360
output = XMLCloseElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
361
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
362
Jun 27, 2011
Jun 27, 2011
363
// log total runtime
Jun 28, 2011
Jun 28, 2011
364
output = XMLOpenElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
365
366
367
368
369
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
370
output = XMLCloseElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
371
372
373
XMLOutputter(--indentLevel, YES, output);
// log total runtime
Jun 28, 2011
Jun 28, 2011
374
output = XMLOpenElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
375
376
377
378
379
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
380
output = XMLCloseElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
381
382
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
383
output = XMLCloseElement(testElementName);
Jun 27, 2011
Jun 27, 2011
384
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
387
void
Jun 21, 2011
Jun 21, 2011
388
XMLAssert(const char *assertName, int assertResult, const char *assertMessage,
Jun 27, 2011
Jun 27, 2011
389
390
time_t eventTime)
{
Jun 28, 2011
Jun 28, 2011
391
char *output = XMLOpenElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
392
393
XMLOutputter(indentLevel++, YES, output);
Jun 28, 2011
Jun 28, 2011
394
395
396
397
398
399
400
401
402
403
404
// log assert name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertName);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
Jun 27, 2011
Jun 27, 2011
405
// log assert result
Jun 28, 2011
Jun 28, 2011
406
output = XMLOpenElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
407
408
409
410
411
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent((assertResult) ? "pass" : "failure");
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
412
output = XMLCloseElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
413
414
415
XMLOutputter(--indentLevel, YES, output);
// log assert message
Jun 28, 2011
Jun 28, 2011
416
output = XMLOpenElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
417
418
419
420
421
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
422
output = XMLCloseElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
423
424
425
XMLOutputter(--indentLevel, YES, output);
// log event time
Jun 28, 2011
Jun 28, 2011
426
output = XMLOpenElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
427
428
429
430
431
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
432
output = XMLCloseElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
433
434
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
435
output = XMLCloseElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
436
437
438
439
440
441
XMLOutputter(--indentLevel, YES, output);
}
void
XMLAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
int actualValue, int excpected, time_t eventTime)
Jun 28, 2011
Jun 28, 2011
443
char *output = XMLOpenElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
444
XMLOutputter(indentLevel++, YES, output);
Jun 23, 2011
Jun 23, 2011
445
Jun 28, 2011
Jun 28, 2011
446
447
448
449
450
451
452
453
454
455
456
// log assert name
output = XMLOpenElement(nameElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertName);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(nameElementName);
XMLOutputter(--indentLevel, YES, output);
Jun 27, 2011
Jun 27, 2011
457
// log assert result
Jun 28, 2011
Jun 28, 2011
458
output = XMLOpenElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
459
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
461
output = XMLAddContent((assertResult) ? "pass" : "failure");
Jun 27, 2011
Jun 27, 2011
462
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
464
output = XMLCloseElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
465
466
467
XMLOutputter(--indentLevel, YES, output);
// log assert message
Jun 28, 2011
Jun 28, 2011
468
output = XMLOpenElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
469
470
471
472
473
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
474
output = XMLCloseElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
475
476
477
XMLOutputter(--indentLevel, YES, output);
// log event time
Jun 28, 2011
Jun 28, 2011
478
output = XMLOpenElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
479
480
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
481
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
482
483
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
484
output = XMLCloseElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
485
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
487
output = XMLCloseElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
488
XMLOutputter(--indentLevel, YES, output);
Jun 19, 2011
Jun 19, 2011
489
490
}
Jun 26, 2011
Jun 26, 2011
491
void
Jun 27, 2011
Jun 27, 2011
492
493
XMLAssertSummary(int numAsserts, int numAssertsFailed,
int numAssertsPass, time_t eventTime)
Jun 26, 2011
Jun 26, 2011
494
{
Jun 28, 2011
Jun 28, 2011
495
char *output = XMLOpenElement(assertSummaryElementName);
Jun 27, 2011
Jun 27, 2011
496
XMLOutputter(indentLevel++, YES, output);
Jun 26, 2011
Jun 26, 2011
497
Jun 28, 2011
Jun 28, 2011
498
output = XMLOpenElement(assertCountElementName);
Jun 27, 2011
Jun 27, 2011
499
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
500
Jun 27, 2011
Jun 27, 2011
501
502
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
503
Jun 28, 2011
Jun 28, 2011
504
output = XMLCloseElement(assertCountElementName);
Jun 27, 2011
Jun 27, 2011
505
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
506
Jun 28, 2011
Jun 28, 2011
507
output = XMLOpenElement(assertsPassedElementName);
Jun 27, 2011
Jun 27, 2011
508
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
509
Jun 27, 2011
Jun 27, 2011
510
511
output = XMLAddContent(IntToString(numAssertsPass));
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
512
Jun 28, 2011
Jun 28, 2011
513
output = XMLCloseElement(assertsPassedElementName);
Jun 27, 2011
Jun 27, 2011
514
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
515
Jun 28, 2011
Jun 28, 2011
516
output = XMLOpenElement(assertsFailedElementName);
Jun 27, 2011
Jun 27, 2011
517
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
518
Jun 27, 2011
Jun 27, 2011
519
520
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
521
Jun 28, 2011
Jun 28, 2011
522
output = XMLCloseElement(assertsFailedElementName);
Jun 27, 2011
Jun 27, 2011
523
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
524
Jun 28, 2011
Jun 28, 2011
525
output = XMLCloseElement(assertSummaryElementName);
Jun 27, 2011
Jun 27, 2011
526
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
527
528
}
Jun 21, 2011
Jun 21, 2011
529
530
void
XMLLog(const char *logMessage, time_t eventTime)
Jun 28, 2011
Jun 28, 2011
532
char *output = XMLOpenElement(logElementName);
Jun 27, 2011
Jun 27, 2011
533
534
535
XMLOutputter(indentLevel++, NO, output);
// log message
Jun 28, 2011
Jun 28, 2011
536
output = XMLOpenElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
537
XMLOutputter(indentLevel++, NO, output);
Jun 21, 2011
Jun 21, 2011
538
Jun 23, 2011
Jun 23, 2011
539
output = XMLAddContent(logMessage);
Jun 27, 2011
Jun 27, 2011
540
541
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
542
output = XMLCloseElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
543
544
545
XMLOutputter(--indentLevel, YES, output);
// log eventTime
Jun 28, 2011
Jun 28, 2011
546
output = XMLOpenElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
547
548
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
549
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
550
551
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
552
output = XMLCloseElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
553
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
555
output = XMLCloseElement(logElementName);
Jun 27, 2011
Jun 27, 2011
556
XMLOutputter(--indentLevel, YES, output);