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

Latest commit

 

History

History
636 lines (482 loc) · 18.2 KB

File metadata and controls

636 lines (482 loc) · 18.2 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"
Jul 13, 2011
Jul 13, 2011
29
#include "SDL_test.h"
Jun 21, 2011
Jun 21, 2011
31
#include "xml_logger.h"
Jun 28, 2011
Jun 28, 2011
33
34
35
36
37
/*! Static strings for XML elements */
const char *documentRoot = "testlog";
const char *parametersElementName = "parameters";
const char *parameterElementName = "parameter";
const char *startTimeElementName = "startTime";
Jul 25, 2011
Jul 25, 2011
38
const char *seedElementName = "seed";
Jul 24, 2011
Jul 24, 2011
39
const char *execKeyElementName = "executionKey";
Jun 28, 2011
Jun 28, 2011
40
41
42
43
const char *numSuitesElementName = "numSuites";
const char *numTestElementName = "numTests";
const char *numPassedTestsElementName = "numPassedTests";
const char *numFailedTestsElementName = "numFailedTests";
Jul 11, 2011
Jul 11, 2011
44
const char *numSkippedTestsElementName = "numSkippedTests";
Jun 28, 2011
Jun 28, 2011
45
46
47
48
49
50
51
52
53
54
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";
Jul 13, 2011
Jul 13, 2011
55
const char *resultDescriptionElementName = "resultDescription";
Jun 28, 2011
Jun 28, 2011
56
57
58
59
const char *assertElementName = "assert";
const char *messageElementName = "message";
const char *timeElementName = "time";
const char *assertSummaryElementName = "assertSummary";
Jun 28, 2011
Jun 28, 2011
60
const char *assertCountElementName = "assertCount";
Jun 28, 2011
Jun 28, 2011
61
62
63
64
65
66
const char *assertsPassedElementName = "assertsPassed";
const char *assertsFailedElementName = "assertsFailed";
const char *logElementName = "log";
/*! Current indentationt level */
Jun 27, 2011
Jun 27, 2011
67
68
69
70
71
72
static int indentLevel;
//! Constants for XMLOuputters EOL parameter
#define YES 1
#define NO 0
Jun 28, 2011
Jun 28, 2011
73
/*! Controls printing the indentation in relation to line breaks */
Jun 27, 2011
Jun 27, 2011
74
75
76
77
78
static int prevEOL = YES;
/*
* Prints out the given xml element etc.
*
Jun 28, 2011
Jun 28, 2011
79
80
* \todo Make the destination of the output changeable (defaults to stdout)
*
Jul 14, 2011
Jul 14, 2011
81
* \param currentIndentLevel the indent level of the message
Jun 27, 2011
Jun 27, 2011
82
83
84
85
* \param EOL will it print end of line character or not
* \param the XML element itself
*
*/
Jun 28, 2011
Jun 28, 2011
86
void
Jul 14, 2011
Jul 14, 2011
87
XMLOutputter(const int currentIndentLevel,
Jun 28, 2011
Jun 28, 2011
88
89
90
91
int EOL, const char *message)
{
if(ValidateString(message)) {
int ident = 0;
Jul 14, 2011
Jul 14, 2011
92
for( ; ident < currentIndentLevel && prevEOL; ++ident) {
Jul 4, 2011
Jul 4, 2011
93
fprintf(stdout, " "); // \todo make configurable?
Jun 28, 2011
Jun 28, 2011
94
}
Jun 27, 2011
Jun 27, 2011
95
Jun 28, 2011
Jun 28, 2011
96
prevEOL = EOL;
Jun 27, 2011
Jun 27, 2011
97
Jun 28, 2011
Jun 28, 2011
98
99
100
101
102
103
104
if(EOL) {
fprintf(stdout, "%s\n", message);
} else {
fprintf(stdout, "%s", message);
}
fflush(stdout);
Jun 27, 2011
Jun 27, 2011
105
} else {
Jun 28, 2011
Jun 28, 2011
106
fprintf(stdout, "Error: Tried to output invalid string!");
Jun 27, 2011
Jun 27, 2011
107
}
Jun 27, 2011
Jun 27, 2011
108
Jul 1, 2011
Jul 1, 2011
109
SDL_free((char *)message);
Jun 27, 2011
Jun 27, 2011
110
}
Jun 23, 2011
Jun 23, 2011
111
Jun 21, 2011
Jun 21, 2011
112
void
Jul 25, 2011
Jul 25, 2011
113
114
XMLRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
time_t eventTime, void *data)
Jul 1, 2011
Jul 1, 2011
116
char *xslStylesheet = (char *)data;
Jun 30, 2011
Jun 30, 2011
117
118
char *output = XMLOpenDocument(documentRoot, xslStylesheet);
Jun 27, 2011
Jun 27, 2011
119
XMLOutputter(indentLevel++, YES, output);
Jun 23, 2011
Jun 23, 2011
120
Jul 25, 2011
Jul 25, 2011
121
// log harness parameters
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);
Jul 25, 2011
Jul 25, 2011
142
143
144
145
146
147
148
149
150
151
152
// log seed
output = XMLOpenElement(seedElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(runSeed);
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(seedElementName);
XMLOutputter(--indentLevel, YES, output);
// log start time
Jun 28, 2011
Jun 28, 2011
153
output = XMLOpenElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
154
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
156
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
157
XMLOutputter(indentLevel, NO, output);
Jun 23, 2011
Jun 23, 2011
158
Jun 28, 2011
Jun 28, 2011
159
output = XMLCloseElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
160
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
163
void
Jun 22, 2011
Jun 22, 2011
164
XMLRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
Jul 11, 2011
Jul 11, 2011
165
int testSkippedCount, time_t endTime, double totalRuntime)
Jun 27, 2011
Jun 27, 2011
167
// log suite count
Jun 28, 2011
Jun 28, 2011
168
char *output = XMLOpenElement(numSuitesElementName);
Jun 27, 2011
Jun 27, 2011
169
170
171
172
173
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(suiteCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
174
output = XMLCloseElement(numSuitesElementName);
Jun 27, 2011
Jun 27, 2011
175
176
177
XMLOutputter(--indentLevel, YES, output);
// log test count
Jun 28, 2011
Jun 28, 2011
178
output = XMLOpenElement(numTestElementName);
Jun 27, 2011
Jun 27, 2011
179
180
181
182
183
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
184
output = XMLCloseElement(numTestElementName);
Jun 27, 2011
Jun 27, 2011
185
186
187
XMLOutputter(--indentLevel, YES, output);
// log passed test count
Jun 28, 2011
Jun 28, 2011
188
output = XMLOpenElement(numPassedTestsElementName);
Jun 27, 2011
Jun 27, 2011
189
190
191
192
193
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testPassCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
194
output = XMLCloseElement(numPassedTestsElementName);
Jun 27, 2011
Jun 27, 2011
195
196
197
XMLOutputter(--indentLevel, YES, output);
// log failed test count
Jun 28, 2011
Jun 28, 2011
198
output = XMLOpenElement(numFailedTestsElementName);
Jun 27, 2011
Jun 27, 2011
199
200
201
202
203
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testFailCount));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
204
output = XMLCloseElement(numFailedTestsElementName);
Jun 27, 2011
Jun 27, 2011
205
206
XMLOutputter(--indentLevel, YES, output);
Jul 11, 2011
Jul 11, 2011
207
208
209
210
211
212
213
214
215
216
217
// log skipped test count
output = XMLOpenElement(numSkippedTestsElementName);
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testSkippedCount));
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(numSkippedTestsElementName);
XMLOutputter(--indentLevel, YES, output);
// log end tite
Jun 28, 2011
Jun 28, 2011
218
output = XMLOpenElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
219
220
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
221
output = XMLAddContent(TimestampToString(endTime));
Jun 27, 2011
Jun 27, 2011
222
223
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
224
output = XMLCloseElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
225
226
227
XMLOutputter(--indentLevel, YES, output);
// log total runtime
Jun 28, 2011
Jun 28, 2011
228
output = XMLOpenElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
229
230
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
231
output = XMLAddContent(DoubleToString(totalRuntime));
Jun 27, 2011
Jun 27, 2011
232
233
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
234
output = XMLCloseElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
235
236
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
237
output = XMLCloseDocument(documentRoot);
Jun 27, 2011
Jun 27, 2011
238
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
241
void
Jun 21, 2011
Jun 21, 2011
242
XMLSuiteStarted(const char *suiteName, time_t eventTime)
Jun 28, 2011
Jun 28, 2011
244
char *output = XMLOpenElement(suiteElementName);
Jun 27, 2011
Jun 27, 2011
245
246
XMLOutputter(indentLevel++, YES, output);
Jun 28, 2011
Jun 28, 2011
247
248
249
250
251
252
253
254
255
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
256
output = XMLOpenElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
257
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
258
Jun 27, 2011
Jun 27, 2011
259
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
260
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
262
output = XMLCloseElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
263
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
266
void
Jun 21, 2011
Jun 21, 2011
267
XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
Jun 27, 2011
Jun 27, 2011
268
time_t endTime, double totalRuntime)
Jun 27, 2011
Jun 27, 2011
270
// log tests passed
Jun 28, 2011
Jun 28, 2011
271
char *output = XMLOpenElement(testsPassedElementName);
Jun 27, 2011
Jun 27, 2011
272
273
274
275
276
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsPassed));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
277
output = XMLCloseElement(testsPassedElementName);
Jun 27, 2011
Jun 27, 2011
278
279
280
XMLOutputter(--indentLevel, YES, output);
// log tests failed
Jun 28, 2011
Jun 28, 2011
281
output = XMLOpenElement(testsFailedElementName);
Jun 27, 2011
Jun 27, 2011
282
283
284
285
286
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsFailed));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
287
output = XMLCloseElement(testsFailedElementName);
Jun 27, 2011
Jun 27, 2011
288
289
290
XMLOutputter(--indentLevel, YES, output);
// log tests skipped
Jun 28, 2011
Jun 28, 2011
291
output = XMLOpenElement(testsSkippedElementName);
Jun 27, 2011
Jun 27, 2011
292
293
294
295
296
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(IntToString(testsSkipped));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
297
output = XMLCloseElement(testsSkippedElementName);
Jun 27, 2011
Jun 27, 2011
298
299
300
XMLOutputter(--indentLevel, YES, output);
// log tests skipped
Jun 28, 2011
Jun 28, 2011
301
output = XMLOpenElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
302
303
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
304
output = XMLAddContent(TimestampToString(endTime));
Jun 27, 2011
Jun 27, 2011
305
306
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
307
output = XMLCloseElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
308
309
XMLOutputter(--indentLevel, YES, output);
Jun 27, 2011
Jun 27, 2011
310
// log total runtime
Jun 28, 2011
Jun 28, 2011
311
output = XMLOpenElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
312
313
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
314
output = XMLAddContent(DoubleToString(totalRuntime));
Jun 27, 2011
Jun 27, 2011
315
316
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
317
output = XMLCloseElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
318
319
320
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
321
output = XMLCloseElement(suiteElementName);
Jun 27, 2011
Jun 27, 2011
322
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
325
void
Jun 27, 2011
Jun 27, 2011
326
XMLTestStarted(const char *testName, const char *suiteName,
Jul 25, 2011
Jul 25, 2011
327
const char *testDescription, char *execKey, time_t startTime)
Jun 28, 2011
Jun 28, 2011
329
char * output = XMLOpenElement(testElementName);
Jun 27, 2011
Jun 27, 2011
330
XMLOutputter(indentLevel++, YES, output);
Jun 23, 2011
Jun 23, 2011
331
332
333
//Attribute attribute = {"test", "value"};
//XMLOpenElementWithAttribute("name", &attribute);
Jun 28, 2011
Jun 28, 2011
334
output = XMLOpenElement(nameElementName);
Jun 27, 2011
Jun 27, 2011
335
XMLOutputter(indentLevel++, NO, output);
Jun 22, 2011
Jun 22, 2011
336
Jun 23, 2011
Jun 23, 2011
337
output = XMLAddContent(testName);
Jun 27, 2011
Jun 27, 2011
338
XMLOutputter(indentLevel, NO, output);
Jun 21, 2011
Jun 21, 2011
339
Jun 28, 2011
Jun 28, 2011
340
output = XMLCloseElement(nameElementName);
Jun 27, 2011
Jun 27, 2011
341
XMLOutputter(--indentLevel, YES, output);
Jun 23, 2011
Jun 23, 2011
342
Jun 28, 2011
Jun 28, 2011
343
output = XMLOpenElement(descriptionElementName);
Jun 27, 2011
Jun 27, 2011
344
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
345
346
output = XMLAddContent(testDescription);
Jun 27, 2011
Jun 27, 2011
347
XMLOutputter(indentLevel, NO, output);
Jun 23, 2011
Jun 23, 2011
348
Jun 28, 2011
Jun 28, 2011
349
output = XMLCloseElement(descriptionElementName);
Jun 27, 2011
Jun 27, 2011
350
351
XMLOutputter(--indentLevel, YES, output);
Jul 24, 2011
Jul 24, 2011
352
353
354
355
// log exec key
output = XMLOpenElement(execKeyElementName);
XMLOutputter(indentLevel++, NO, output);
Jul 25, 2011
Jul 25, 2011
356
output = XMLAddContent(IntToHexString(execKey));
Jul 24, 2011
Jul 24, 2011
357
358
359
360
361
362
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(execKeyElementName);
XMLOutputter(--indentLevel, YES, output);
// log start time
Jun 28, 2011
Jun 28, 2011
363
output = XMLOpenElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
364
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
365
Jun 27, 2011
Jun 27, 2011
366
output = XMLAddContent(TimestampToString(startTime));
Jun 27, 2011
Jun 27, 2011
367
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
369
output = XMLCloseElement(startTimeElementName);
Jun 27, 2011
Jun 27, 2011
370
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
373
void
Jun 22, 2011
Jun 22, 2011
374
XMLTestEnded(const char *testName, const char *suiteName,
Jun 27, 2011
Jun 27, 2011
375
int testResult, time_t endTime, double totalRuntime)
Jul 13, 2011
Jul 13, 2011
377
// Log test result
Jun 28, 2011
Jun 28, 2011
378
char *output = XMLOpenElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
379
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
380
Jul 13, 2011
Jul 13, 2011
381
382
383
384
385
386
387
388
389
390
391
switch(testResult) {
case TEST_RESULT_PASS:
output = XMLAddContent("passed");
break;
case TEST_RESULT_FAILURE:
output = XMLAddContent("failed");
break;
case TEST_RESULT_NO_ASSERT:
output = XMLAddContent("failed");
break;
case TEST_RESULT_SKIPPED:
Jul 11, 2011
Jul 11, 2011
392
output = XMLAddContent("skipped");
Jul 13, 2011
Jul 13, 2011
393
394
break;
case TEST_RESULT_KILLED:
Jun 26, 2011
Jun 26, 2011
395
output = XMLAddContent("failed");
Jul 13, 2011
Jul 13, 2011
396
397
398
399
break;
case TEST_RESULT_SETUP_FAILURE:
output = XMLAddContent("failed");
break;
Jun 26, 2011
Jun 26, 2011
400
}
Jul 13, 2011
Jul 13, 2011
401
XMLOutputter(indentLevel, NO, output);
Jun 27, 2011
Jun 27, 2011
402
Jun 28, 2011
Jun 28, 2011
403
output = XMLCloseElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
404
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
405
Jul 13, 2011
Jul 13, 2011
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
// Log description of test result. Why the test failed,
// if there's some specific reason
output = XMLOpenElement(resultDescriptionElementName);
XMLOutputter(indentLevel++, NO, output);
switch(testResult) {
case TEST_RESULT_PASS:
case TEST_RESULT_FAILURE:
case TEST_RESULT_SKIPPED:
output = XMLAddContent("");
break;
case TEST_RESULT_NO_ASSERT:
output = XMLAddContent("No assert");
break;
case TEST_RESULT_KILLED:
output = XMLAddContent("Timeout exceeded");
break;
case TEST_RESULT_SETUP_FAILURE:
output = XMLAddContent("Setup failure, couldn't be executed");
break;
}
XMLOutputter(indentLevel, NO, output);
output = XMLCloseElement(resultDescriptionElementName);
XMLOutputter(--indentLevel, YES, output);
Jun 27, 2011
Jun 27, 2011
432
// log total runtime
Jun 28, 2011
Jun 28, 2011
433
output = XMLOpenElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
434
435
436
437
438
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(endTime));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
439
output = XMLCloseElement(endTimeElementName);
Jun 27, 2011
Jun 27, 2011
440
441
442
XMLOutputter(--indentLevel, YES, output);
// log total runtime
Jun 28, 2011
Jun 28, 2011
443
output = XMLOpenElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
444
445
446
447
448
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(DoubleToString(totalRuntime));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
449
output = XMLCloseElement(totalRuntimeElementName);
Jun 27, 2011
Jun 27, 2011
450
451
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
452
output = XMLCloseElement(testElementName);
Jun 27, 2011
Jun 27, 2011
453
XMLOutputter(--indentLevel, YES, output);
Jun 21, 2011
Jun 21, 2011
456
void
Jun 21, 2011
Jun 21, 2011
457
XMLAssert(const char *assertName, int assertResult, const char *assertMessage,
Jun 27, 2011
Jun 27, 2011
458
459
time_t eventTime)
{
Jun 28, 2011
Jun 28, 2011
460
char *output = XMLOpenElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
461
462
XMLOutputter(indentLevel++, YES, output);
Jun 28, 2011
Jun 28, 2011
463
464
465
466
467
468
469
470
471
472
473
// 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
474
// log assert result
Jun 28, 2011
Jun 28, 2011
475
output = XMLOpenElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
476
477
478
479
480
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent((assertResult) ? "pass" : "failure");
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
481
output = XMLCloseElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
482
483
484
XMLOutputter(--indentLevel, YES, output);
// log assert message
Jun 28, 2011
Jun 28, 2011
485
output = XMLOpenElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
486
487
488
489
490
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
491
output = XMLCloseElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
492
493
494
XMLOutputter(--indentLevel, YES, output);
// log event time
Jun 28, 2011
Jun 28, 2011
495
output = XMLOpenElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
496
497
498
499
500
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(TimestampToString(eventTime));
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
501
output = XMLCloseElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
502
503
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
504
output = XMLCloseElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
505
506
507
508
509
510
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
512
char *output = XMLOpenElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
513
XMLOutputter(indentLevel++, YES, output);
Jun 23, 2011
Jun 23, 2011
514
Jun 28, 2011
Jun 28, 2011
515
516
517
518
519
520
521
522
523
524
525
// 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
526
// log assert result
Jun 28, 2011
Jun 28, 2011
527
output = XMLOpenElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
528
XMLOutputter(indentLevel++, NO, output);
Jun 23, 2011
Jun 23, 2011
530
output = XMLAddContent((assertResult) ? "pass" : "failure");
Jun 27, 2011
Jun 27, 2011
531
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
533
output = XMLCloseElement(resultElementName);
Jun 27, 2011
Jun 27, 2011
534
535
536
XMLOutputter(--indentLevel, YES, output);
// log assert message
Jun 28, 2011
Jun 28, 2011
537
output = XMLOpenElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
538
539
540
541
542
XMLOutputter(indentLevel++, NO, output);
output = XMLAddContent(assertMessage);
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
543
output = XMLCloseElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
544
545
546
XMLOutputter(--indentLevel, YES, output);
// log event time
Jun 28, 2011
Jun 28, 2011
547
output = XMLOpenElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
548
549
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
550
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
551
552
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
553
output = XMLCloseElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
554
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
556
output = XMLCloseElement(assertElementName);
Jun 27, 2011
Jun 27, 2011
557
XMLOutputter(--indentLevel, YES, output);
Jun 19, 2011
Jun 19, 2011
558
559
}
Jun 26, 2011
Jun 26, 2011
560
void
Jun 27, 2011
Jun 27, 2011
561
562
XMLAssertSummary(int numAsserts, int numAssertsFailed,
int numAssertsPass, time_t eventTime)
Jun 26, 2011
Jun 26, 2011
563
{
Jun 28, 2011
Jun 28, 2011
564
char *output = XMLOpenElement(assertSummaryElementName);
Jun 27, 2011
Jun 27, 2011
565
XMLOutputter(indentLevel++, YES, output);
Jun 26, 2011
Jun 26, 2011
566
Jun 28, 2011
Jun 28, 2011
567
output = XMLOpenElement(assertCountElementName);
Jun 27, 2011
Jun 27, 2011
568
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
569
Jun 27, 2011
Jun 27, 2011
570
571
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
572
Jun 28, 2011
Jun 28, 2011
573
output = XMLCloseElement(assertCountElementName);
Jun 27, 2011
Jun 27, 2011
574
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
575
Jun 28, 2011
Jun 28, 2011
576
output = XMLOpenElement(assertsPassedElementName);
Jun 27, 2011
Jun 27, 2011
577
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
578
Jun 27, 2011
Jun 27, 2011
579
580
output = XMLAddContent(IntToString(numAssertsPass));
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
581
Jun 28, 2011
Jun 28, 2011
582
output = XMLCloseElement(assertsPassedElementName);
Jun 27, 2011
Jun 27, 2011
583
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
584
Jun 28, 2011
Jun 28, 2011
585
output = XMLOpenElement(assertsFailedElementName);
Jun 27, 2011
Jun 27, 2011
586
XMLOutputter(indentLevel++, NO, output);
Jun 26, 2011
Jun 26, 2011
587
Jun 27, 2011
Jun 27, 2011
588
589
output = XMLAddContent(IntToString(numAsserts));
XMLOutputter(indentLevel, NO, output);
Jun 26, 2011
Jun 26, 2011
590
Jun 28, 2011
Jun 28, 2011
591
output = XMLCloseElement(assertsFailedElementName);
Jun 27, 2011
Jun 27, 2011
592
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
593
Jun 28, 2011
Jun 28, 2011
594
output = XMLCloseElement(assertSummaryElementName);
Jun 27, 2011
Jun 27, 2011
595
XMLOutputter(--indentLevel, YES, output);
Jun 26, 2011
Jun 26, 2011
596
597
}
Jun 21, 2011
Jun 21, 2011
598
void
Jul 18, 2011
Jul 18, 2011
599
XMLLog(time_t eventTime, char *fmt, ...)
Jul 18, 2011
Jul 18, 2011
601
602
603
604
605
606
607
608
609
// create the log message
va_list args;
char logMessage[1024];
memset(logMessage, 0, sizeof(logMessage));
va_start( args, fmt );
SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
va_end( args );
Jun 28, 2011
Jun 28, 2011
610
char *output = XMLOpenElement(logElementName);
Jul 18, 2011
Jul 18, 2011
611
XMLOutputter(indentLevel++, YES, output);
Jun 27, 2011
Jun 27, 2011
612
613
// log message
Jun 28, 2011
Jun 28, 2011
614
output = XMLOpenElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
615
XMLOutputter(indentLevel++, NO, output);
Jun 21, 2011
Jun 21, 2011
616
Jul 18, 2011
Jul 18, 2011
617
// fix this here!
Jun 23, 2011
Jun 23, 2011
618
output = XMLAddContent(logMessage);
Jun 27, 2011
Jun 27, 2011
619
620
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
621
output = XMLCloseElement(messageElementName);
Jun 27, 2011
Jun 27, 2011
622
623
624
XMLOutputter(--indentLevel, YES, output);
// log eventTime
Jun 28, 2011
Jun 28, 2011
625
output = XMLOpenElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
626
627
XMLOutputter(indentLevel++, NO, output);
Jun 27, 2011
Jun 27, 2011
628
output = XMLAddContent(TimestampToString(eventTime));
Jun 27, 2011
Jun 27, 2011
629
630
XMLOutputter(indentLevel, NO, output);
Jun 28, 2011
Jun 28, 2011
631
output = XMLCloseElement(timeElementName);
Jun 27, 2011
Jun 27, 2011
632
XMLOutputter(--indentLevel, YES, output);
Jun 28, 2011
Jun 28, 2011
634
output = XMLCloseElement(logElementName);
Jun 27, 2011
Jun 27, 2011
635
XMLOutputter(--indentLevel, YES, output);