Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
a3b21d2e
Commit
a3b21d2e
authored
Jun 22, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XML elements now support single attribute. Fixes here and there.
parent
94c6ae4e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
65 deletions
+43
-65
logger.c
test/test-automation/logger.c
+4
-11
logger.h
test/test-automation/logger.h
+5
-3
plain_logger.c
test/test-automation/plain_logger.c
+4
-3
plain_logger.h
test/test-automation/plain_logger.h
+5
-3
xml.c
test/test-automation/xml.c
+11
-29
xml.h
test/test-automation/xml.h
+3
-5
xml_logger.c
test/test-automation/xml_logger.c
+7
-8
xml_logger.h
test/test-automation/xml_logger.h
+4
-3
No files found.
test/test-automation/logger.c
View file @
a3b21d2e
...
...
@@ -27,13 +27,6 @@ LogFp Log = 0;
int
LogGenericOutput
(
const
char
*
message
)
{
/*
int depth = indentDepth;
while(depth--) {
fprintf(stderr, " ");
}
*/
fprintf
(
stderr
,
"%s
\n
"
,
message
);
fflush
(
stderr
);
}
...
...
@@ -73,17 +66,17 @@ main(int argc, char *argv[])
Log
=
PlainLog
;
}
RunStarted
(
LogGenericOutput
,
"
All the data from harness
"
,
0
);
RunStarted
(
LogGenericOutput
,
"
some_data_here
"
,
0
);
SuiteStarted
(
"Suite data here"
,
0
);
TestStarted
(
"test1"
,
"desc"
,
0
);
TestEnded
(
"test1"
,
"
desc
"
,
0
,
0
,
0
,
0
);
TestStarted
(
"test1"
,
"
suite"
,
"
desc"
,
0
);
TestEnded
(
"test1"
,
"
suite
"
,
0
,
0
,
0
,
0
);
//XMLTestStarted("test2", "desc", 0);
//XMLTestEnded("test2", "desc", 0, 0, 0, 0);
SuiteEnded
(
0
,
0
,
0
,
0
.
0
f
,
0
);
RunEnded
(
0
,
0
);
RunEnded
(
0
,
0
,
0
,
0
,
0
,
0
);
return
0
;
}
test/test-automation/logger.h
View file @
a3b21d2e
...
...
@@ -32,14 +32,16 @@ typedef int (*LogOutputFp)(const char *);
*
*/
typedef
void
(
*
RunStartedFp
)(
LogOutputFp
outputFn
,
const
char
*
runnerParameters
,
time_t
eventTime
);
typedef
void
(
*
RunEndedFp
)(
time_t
endTime
,
time_t
totalRuntime
);
typedef
void
(
*
RunEndedFp
)(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
time_t
totalRuntime
);
typedef
void
(
*
SuiteStartedFp
)(
const
char
*
suiteName
,
time_t
eventTime
);
typedef
void
(
*
SuiteEndedFp
)(
int
testsPassed
,
int
testsFailed
,
int
testsSkipped
,
double
endTime
,
time_t
totalRuntime
);
typedef
void
(
*
TestStartedFp
)(
const
char
*
testName
,
const
char
*
testDescription
,
time_t
startTime
);
typedef
void
(
*
TestEndedFp
)(
const
char
*
testName
,
const
char
*
testDescription
,
int
testResult
,
typedef
void
(
*
TestStartedFp
)(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
time_t
startTime
);
typedef
void
(
*
TestEndedFp
)(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
int
numAsserts
,
time_t
endTime
,
time_t
totalRuntime
);
typedef
void
(
*
AssertFp
)(
const
char
*
assertName
,
int
assertResult
,
const
char
*
assertMessage
,
...
...
test/test-automation/plain_logger.c
View file @
a3b21d2e
...
...
@@ -16,7 +16,8 @@ PlainRunStarted(LogOutputFp outputFn, const char *runnerParameters, time_t event
}
void
PlainRunEnded
(
time_t
endTime
,
time_t
totalRuntime
)
PlainRunEnded
(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
time_t
totalRuntime
)
{
// \todo add total number of tests, suites, pass/failure test count
}
...
...
@@ -35,12 +36,12 @@ PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
}
void
PlainTestStarted
(
const
char
*
testName
,
const
char
*
testDescription
,
time_t
startTime
)
PlainTestStarted
(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
time_t
startTime
)
{
}
void
PlainTestEnded
(
const
char
*
testName
,
const
char
*
testDescription
,
PlainTestEnded
(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
int
numAsserts
,
time_t
endTime
,
time_t
totalRuntime
)
{
printf
(
"Asserts:%d
\n
"
,
numAsserts
);
...
...
test/test-automation/plain_logger.h
View file @
a3b21d2e
...
...
@@ -5,16 +5,18 @@
void
PlainRunStarted
(
LogOutputFp
outputFn
,
const
char
*
runnerParameters
,
time_t
eventTime
);
void
PlainRunEnded
(
time_t
endTime
,
time_t
totalRuntime
);
void
PlainRunEnded
(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
time_t
totalRuntime
);
void
PlainSuiteStarted
(
const
char
*
suiteName
,
time_t
eventTime
);
void
PlainSuiteEnded
(
int
testsPassed
,
int
testsFailed
,
int
testsSkipped
,
double
endTime
,
time_t
totalRuntime
);
void
PlainTestStarted
(
const
char
*
testName
,
const
char
*
testDescription
,
time_t
startTime
);
void
PlainTestStarted
(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
time_t
startTime
);
void
PlainTestEnded
(
const
char
*
testName
,
const
char
*
testDescription
,
void
PlainTestEnded
(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
int
numAsserts
,
time_t
endTime
,
time_t
totalRuntime
);
void
PlainAssert
(
const
char
*
assertName
,
int
assertResult
,
const
char
*
assertMessage
,
...
...
test/test-automation/xml.c
View file @
a3b21d2e
...
...
@@ -18,10 +18,6 @@
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _XML_C
#define _XML_C
#include <stdio.h>
#include <string.h>
#include <assert.h>
...
...
@@ -111,7 +107,7 @@ PrintOpenTags()
/*
===================
Functions to handle
XML creation
Functions to handle
creation of XML elements
===================
*/
...
...
@@ -128,7 +124,7 @@ XMLOpenDocument(const char *rootTag, LogOutputFp log)
size_t
size
=
SDL_strlen
(
rootTag
)
+
3
+
1
;
/* one extra for '\0', '<' and '>' */
char
*
buffer
=
SDL_malloc
(
size
);
snprintf
(
buffer
,
size
,
"
%s%s%s"
,
"<"
,
rootTag
,
">"
);
snprintf
(
buffer
,
size
,
"
<%s>"
,
rootTag
);
logger
(
buffer
);
SDL_free
(
buffer
);
...
...
@@ -148,7 +144,7 @@ XMLOpenElement(const char *tag)
{
size_t
size
=
SDL_strlen
(
tag
)
+
2
+
1
;
/* one extra for '\0', '<' */
char
*
buffer
=
SDL_malloc
(
size
);
snprintf
(
buffer
,
size
,
"
%s%s%s"
,
"<"
,
tag
,
">"
);
snprintf
(
buffer
,
size
,
"
<%s>"
,
tag
);
logger
(
buffer
);
SDL_free
(
buffer
);
...
...
@@ -157,32 +153,20 @@ XMLOpenElement(const char *tag)
void
XMLOpenElementWithAttribute
(
const
char
*
tag
,
Attribute
attribute
)
XMLOpenElementWithAttribute
(
const
char
*
tag
,
Attribute
*
attribute
)
{
size_t
size
=
SDL_strlen
(
tag
)
+
2
+
1
;
/* one extra for '\0', '<' */
char
*
buffer
=
SDL_malloc
(
size
);
const
int
bufferSize
=
1024
;
char
buffer
[
bufferSize
];
memset
(
buffer
,
0
,
bufferSize
);
snprintf
(
buffer
,
bufferSize
,
"<%s %s='%s'>"
,
tag
,
attribute
->
attribute
,
attribute
->
value
);
snprintf
(
buffer
,
size
,
"%s%s"
,
"<"
,
tag
);
logger
(
buffer
);
SDL_free
(
buffer
);
AddOpenTag
(
tag
);
}
//! \todo make this static and remove from interface?
void
XMLAddAttribute
(
const
char
*
attribute
,
const
char
*
value
)
{
size_t
attributeSize
=
SDL_strlen
(
attribute
);
size_t
valueSize
=
SDL_strlen
(
value
);
size_t
size
=
1
+
attributeSize
+
3
+
valueSize
+
1
;
char
*
buffer
=
SDL_malloc
(
size
);
// 1 for '='
snprintf
(
buffer
,
size
,
" %s%s
\"
%s
\"
"
,
attribute
,
"="
,
value
);
logger
(
buffer
);
SDL_free
(
buffer
);
}
void
XMLAddContent
(
const
char
*
content
)
{
...
...
@@ -203,7 +187,7 @@ XMLCloseElement(const char *tag)
size_t
size
=
SDL_strlen
(
openTag
->
tag
)
+
4
+
1
;
/* one extra for '\0', '<', '/' and '>' */
char
*
buffer
=
SDL_malloc
(
size
);
snprintf
(
buffer
,
size
,
"
%s%s%s"
,
"</"
,
openTag
->
tag
,
">"
);
snprintf
(
buffer
,
size
,
"
<%s>"
,
openTag
->
tag
);
logger
(
buffer
);
SDL_free
(
buffer
);
...
...
@@ -226,5 +210,3 @@ XMLCloseElement(const char *tag)
}
}
#endif
test/test-automation/xml.h
View file @
a3b21d2e
...
...
@@ -23,6 +23,7 @@
#include "logger.h"
/*! Defines attribute for XML elements */
typedef
struct
Attribute
{
const
char
*
attribute
;
const
char
*
value
;
...
...
@@ -52,12 +53,9 @@ void XMLCloseDocument();
void
XMLOpenElement
(
const
char
*
tag
);
/*!
* Add attribute to currently open element.
*
* \param attribute Name of the attribute
* \param value Value of the given attribute
* Opens XML-element with given attributes
*/
void
XML
AddAttribute
(
const
char
*
attribute
,
const
char
*
valu
e
);
void
XML
OpenElementWithAttribute
(
const
char
*
tag
,
Attribute
*
attribut
e
);
/*!
* Add content to currently open element.
...
...
test/test-automation/xml_logger.c
View file @
a3b21d2e
...
...
@@ -18,9 +18,6 @@
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _XML_LOGGER_C
#define _XML_LOGGER_C
#include "xml.h"
#include "logger.h"
...
...
@@ -37,7 +34,8 @@ XMLRunStarted(LogOutputFp outputFn, const char *runnerParameters, time_t eventTi
}
void
XMLRunEnded
(
time_t
endTime
,
time_t
totalRuntime
)
XMLRunEnded
(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
time_t
totalRuntime
)
{
XMLCloseDocument
(
"testlog"
);
}
...
...
@@ -60,11 +58,13 @@ XMLSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
}
void
XMLTestStarted
(
const
char
*
testName
,
const
char
*
testDescription
,
time_t
startTime
)
XMLTestStarted
(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
time_t
startTime
)
{
XMLOpenElement
(
"test"
);
XMLOpenElement
(
"name"
);
Attribute
attribute
=
{
"test"
,
"value"
};
XMLOpenElementWithAttribute
(
"name"
,
&
attribute
);
XMLAddContent
(
testName
);
XMLCloseElement
(
"name"
);
...
...
@@ -78,7 +78,7 @@ XMLTestStarted(const char *testName, const char *testDescription, time_t startTi
}
void
XMLTestEnded
(
const
char
*
testName
,
const
char
*
testDescription
,
XMLTestEnded
(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
int
numAsserts
,
time_t
endTime
,
time_t
totalRuntime
)
{
XMLCloseElement
(
"test"
);
...
...
@@ -108,4 +108,3 @@ XMLLog(const char *logMessage, time_t eventTime)
XMLCloseElement
(
"log"
);
}
#endif
test/test-automation/xml_logger.h
View file @
a3b21d2e
...
...
@@ -5,16 +5,17 @@
void
XMLRunStarted
(
LogOutputFp
outputFn
,
const
char
*
runnerParameters
,
time_t
eventTime
);
void
XMLRunEnded
(
time_t
endTime
,
time_t
totalRuntime
);
void
XMLRunEnded
(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
time_t
totalRuntime
);
void
XMLSuiteStarted
(
const
char
*
suiteName
,
time_t
eventTime
);
void
XMLSuiteEnded
(
int
testsPassed
,
int
testsFailed
,
int
testsSkipped
,
double
endTime
,
time_t
totalRuntime
);
void
XMLTestStarted
(
const
char
*
testName
,
const
char
*
testDescription
,
time_t
startTime
);
void
XMLTestStarted
(
const
char
*
testName
,
const
char
*
suiteName
,
const
char
*
testDescription
,
time_t
startTime
);
void
XMLTestEnded
(
const
char
*
testName
,
const
char
*
testDescription
,
void
XMLTestEnded
(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
int
numAsserts
,
time_t
endTime
,
time_t
totalRuntime
);
void
XMLAssert
(
const
char
*
assertName
,
int
assertResult
,
const
char
*
assertMessage
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment