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
e2799bbb
Commit
e2799bbb
authored
Jun 24, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added case insensitivity to XML elements.
parent
7b600bf8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
55 deletions
+81
-55
logger.c
test/test-automation/logger.c
+10
-2
logger.h
test/test-automation/logger.h
+1
-1
plain_logger.c
test/test-automation/plain_logger.c
+5
-5
xml.c
test/test-automation/xml.c
+59
-34
xml.h
test/test-automation/xml.h
+0
-5
xml_logger.c
test/test-automation/xml_logger.c
+6
-8
No files found.
test/test-automation/logger.c
View file @
e2799bbb
...
...
@@ -4,6 +4,8 @@
#include <string.h>
#include <stdarg.h>
#include <SDL/SDL.h>
#include "logger.h"
#include "xml_logger.h"
#include "plain_logger.h"
...
...
@@ -25,9 +27,15 @@ LogFp Log = 0;
* \return Possible error value (\todo)
*/
int
LogGenericOutput
(
const
char
*
message
)
LogGenericOutput
(
const
char
*
message
,
...
)
{
fprintf
(
stderr
,
"%s
\n
"
,
message
);
va_list
list
;
va_start
(
list
,
message
);
char
buffer
[
1024
];
SDL_vsnprintf
(
buffer
,
sizeof
(
buffer
),
message
,
list
);
fprintf
(
stderr
,
"%s
\n
"
,
buffer
);
fflush
(
stderr
);
}
...
...
test/test-automation/logger.h
View file @
e2799bbb
...
...
@@ -24,7 +24,7 @@
#include <time.h>
// Function pointer to function which handles to output
typedef
int
(
*
LogOutputFp
)(
const
char
*
);
typedef
int
(
*
LogOutputFp
)(
const
char
*
,
...
);
/*!
...
...
test/test-automation/plain_logger.c
View file @
e2799bbb
...
...
@@ -25,14 +25,14 @@ PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCoun
void
PlainSuiteStarted
(
const
char
*
suiteName
,
time_t
eventTime
)
{
printf
(
"Executing tests in %s
\n
"
,
suiteName
);
logger
(
"Executing tests in %s
\n
"
,
suiteName
);
}
void
PlainSuiteEnded
(
int
testsPassed
,
int
testsFailed
,
int
testsSkipped
,
double
endTime
,
time_t
totalRuntime
)
{
printf
(
"Suite executed. %d passed, %d failed and %d skipped
\n
"
,
testsPassed
,
testsFailed
,
testsSkipped
);
logger
(
"Suite executed. %d passed, %d failed and %d skipped
\n
"
,
testsPassed
,
testsFailed
,
testsSkipped
);
}
void
...
...
@@ -44,8 +44,8 @@ void
PlainTestEnded
(
const
char
*
testName
,
const
char
*
suiteName
,
int
testResult
,
int
numAsserts
,
time_t
endTime
,
time_t
totalRuntime
)
{
printf
(
"Asserts:%d
\n
"
,
numAsserts
);
printf
(
"%s: ok
\n
"
,
testName
);
logger
(
"Asserts:%d
\n
"
,
numAsserts
);
logger
(
"%s: ok
\n
"
,
testName
);
}
void
...
...
@@ -53,7 +53,7 @@ PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
time_t
eventTime
)
{
const
char
*
result
=
(
assertResult
)
?
"passed"
:
"failed"
;
printf
(
"%s %d: %s
\n
"
,
assertName
,
assertResult
,
assertMessage
);
logger
(
"%s %d: %s
\n
"
,
assertName
,
assertResult
,
assertMessage
);
}
void
...
...
test/test-automation/xml.c
View file @
e2799bbb
...
...
@@ -53,7 +53,10 @@ AddOpenTag(const char *tag)
}
memset
(
openTag
,
0
,
sizeof
(
TagList
));
openTag
->
tag
=
tag
;
// Should be fine without malloc?
const
int
tagSize
=
SDL_strlen
(
tag
)
+
1
;
openTag
->
tag
=
SDL_malloc
(
tagSize
);
strncpy
(
openTag
->
tag
,
tag
,
tagSize
);
openTag
->
next
=
openTags
;
openTags
=
openTag
;
...
...
@@ -75,15 +78,27 @@ RemoveOpenTag(const char *tag)
int
retVal
=
0
;
const
int
size
=
SDL_strlen
(
tag
);
char
*
tempTag
=
SDL_malloc
(
size
);
strncpy
(
tempTag
,
tag
,
size
);
// Tag should always be the same as previously opened tag
// It prevents opening and ending tag mismatch
if
(
SDL_strcmp
(
openTags
->
t
ag
,
tag
)
==
0
)
{
if
(
SDL_strcmp
(
tempT
ag
,
tag
)
==
0
)
{
TagList
*
openTag
=
openTags
;
openTags
=
openTags
->
next
;
SDL_free
(
openTag
->
tag
)
;
free
(
openTag
);
/*
int counter = 0;
for(; counter < strlen(buffer); ++counter) {
buffer[counter] = tolower(buffer[counter]);
}
*/
openTags
=
openTags
->
next
;
SDL_free
(
openTag
);
}
else
{
printf
(
"Debug |
RemoveOpenTag(): open/end tag mismatch"
);
//printf("Debug | xml.c:
RemoveOpenTag(): open/end tag mismatch");
retVal
=
1
;
}
...
...
@@ -153,7 +168,30 @@ const char *EscapeString(const char *string) {
return
stringBuffer
;
}
/*! Turns all the characters of the given
* string to lowercase and returns the resulting string.
*
* \param string String to be converted
* \return Lower-case version of the given string
*/
char
*
ToLowerCase
(
char
*
string
)
{
const
int
size
=
SDL_strlen
(
string
);
char
*
ret
=
SDL_malloc
(
size
+
1
);
strncpy
(
ret
,
string
,
size
);
ret
[
size
]
=
'\0'
;
// turn the tag to lower case for case-insensitive comparation
int
counter
=
0
;
for
(;
counter
<
size
;
++
counter
)
{
ret
[
counter
]
=
tolower
(
ret
[
counter
]);
}
// printf("Debug: %s == %s\n", string, ret);
return
ret
;
}
/*
===================
...
...
@@ -177,7 +215,6 @@ XMLOpenDocument(const char *rootTag)
memset
(
buffer
,
0
,
bufferSize
);
snprintf
(
buffer
,
bufferSize
,
"<%s>"
,
rootTag
);
//logger(buffer);
AddOpenTag
(
rootTag
);
...
...
@@ -217,25 +254,6 @@ XMLOpenElement(const char *tag)
return
ret
;
}
char
*
XMLOpenElementWithAttribute
(
const
char
*
tag
,
Attribute
*
attribute
)
{
memset
(
buffer
,
0
,
bufferSize
);
snprintf
(
buffer
,
bufferSize
,
"<%s %s='%s'>"
,
tag
,
attribute
->
attribute
,
attribute
->
value
);
logger
(
buffer
);
AddOpenTag
(
tag
);
const
int
size
=
SDL_strlen
(
buffer
);
char
*
ret
=
SDL_malloc
(
size
+
1
);
strncpy
(
ret
,
buffer
,
size
);
ret
[
size
]
=
'\0'
;
return
ret
;
}
char
*
XMLAddContent
(
const
char
*
content
)
{
...
...
@@ -265,22 +283,29 @@ XMLCloseElement(const char *tag)
while
(
openTag
)
{
TagList
*
temp
=
openTag
->
next
;
memset
(
buffer
,
0
,
bufferSize
);
snprintf
(
buffer
,
bufferSize
,
"</%s>"
,
openTag
->
tag
);
char
*
lowOpenTag
=
ToLowerCase
(
openTag
->
tag
);
char
*
lowTag
=
ToLowerCase
(
tag
);
// \todo use strNcat
strcat
(
ret
,
buffer
);
//logger(buffer);
const
int
openTagSize
=
SDL_strlen
(
openTag
->
tag
);
const
int
tagSize
=
SDL_strlen
(
tag
);
const
int
openTagSize
=
SDL_strlen
(
lowOpenTag
);
const
int
tagSize
=
SDL_strlen
(
lowTag
);
const
int
compSize
=
(
openTagSize
>
tagSize
)
?
openTagSize
:
tagSize
;
memset
(
buffer
,
0
,
bufferSize
);
int
breakOut
=
0
;
if
(
SDL_strncmp
(
openTag
->
tag
,
t
ag
,
compSize
)
==
0
)
{
if
(
SDL_strncmp
(
lowOpenTag
,
lowT
ag
,
compSize
)
==
0
)
{
breakOut
=
1
;
snprintf
(
buffer
,
bufferSize
,
"</%s>"
,
tag
);
}
else
{
snprintf
(
buffer
,
bufferSize
,
"</%s>"
,
openTag
->
tag
);
}
SDL_free
(
lowOpenTag
);
SDL_free
(
lowTag
);
// \todo use strNcat
strcat
(
ret
,
buffer
);
RemoveOpenTag
(
openTag
->
tag
);
openTag
=
temp
;
...
...
test/test-automation/xml.h
View file @
e2799bbb
...
...
@@ -53,11 +53,6 @@ char *XMLCloseDocument();
*/
char
*
XMLOpenElement
(
const
char
*
tag
);
/*!
* Opens XML-element with given attributes
*/
char
*
XMLOpenElementWithAttribute
(
const
char
*
tag
,
Attribute
*
attribute
);
/*!
* Add content to currently open element.
*
...
...
test/test-automation/xml_logger.c
View file @
e2799bbb
...
...
@@ -32,11 +32,11 @@ XMLRunStarted(LogOutputFp outputFn, const char *runnerParameters, time_t eventTi
{
logger
=
outputFn
;
char
*
output
=
XMLOpenDocument
(
"te
s
tlog"
);
char
*
output
=
XMLOpenDocument
(
"te
ST
tlog"
);
logger
(
output
);
SDL_free
(
output
);
output
=
XMLOpenElement
(
"pa
r
ameters"
);
output
=
XMLOpenElement
(
"pa
R
ameters"
);
logger
(
output
);
SDL_free
(
output
);
...
...
@@ -44,7 +44,7 @@ XMLRunStarted(LogOutputFp outputFn, const char *runnerParameters, time_t eventTi
logger
(
output
);
SDL_free
(
output
);
output
=
XMLCloseElement
(
"
p
arameters"
);
output
=
XMLCloseElement
(
"
P
arameters"
);
logger
(
output
);
SDL_free
(
output
);
}
...
...
@@ -53,7 +53,7 @@ void
XMLRunEnded
(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
time_t
totalRuntime
)
{
char
*
output
=
XMLCloseDocument
(
"testl
o
g"
);
char
*
output
=
XMLCloseDocument
(
"testl
O
g"
);
logger
(
output
);
SDL_free
(
output
);
}
...
...
@@ -65,12 +65,12 @@ XMLSuiteStarted(const char *suiteName, time_t eventTime)
logger
(
output
);
SDL_free
(
output
);
output
=
XMLOpenElement
(
"
event
Time"
);
output
=
XMLOpenElement
(
"
EVENT
Time"
);
logger
(
output
);
SDL_free
(
output
);
//XMLAddContent(evenTime);
output
=
XMLCloseElement
(
"eventT
ime
"
);
output
=
XMLCloseElement
(
"eventT
IME
"
);
logger
(
output
);
SDL_free
(
output
);
}
...
...
@@ -91,7 +91,6 @@ XMLTestStarted(const char *testName, const char *suiteName, const char *testDesc
logger
(
output
);
SDL_free
(
output
);
//Attribute attribute = {"test", "value"};
//XMLOpenElementWithAttribute("name", &attribute);
output
=
XMLOpenElement
(
"name"
);
...
...
@@ -111,7 +110,6 @@ XMLTestStarted(const char *testName, const char *suiteName, const char *testDesc
logger
(
output
);
SDL_free
(
output
);
output
=
XMLAddContent
(
testDescription
);
logger
(
output
);
SDL_free
(
output
);
...
...
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