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

Latest commit

 

History

History
654 lines (497 loc) · 18.6 KB

File metadata and controls

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