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
4fdb4d47
Commit
4fdb4d47
authored
Jul 01, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redefined the usage of --xsl command option.
parent
06529787
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
44 deletions
+60
-44
runner.c
test/test-automation/runner.c
+24
-14
xml.c
test/test-automation/xml.c
+33
-22
xml.h
test/test-automation/xml.h
+1
-0
xml_logger.c
test/test-automation/xml_logger.c
+2
-8
No files found.
test/test-automation/runner.c
View file @
4fdb4d47
...
@@ -53,6 +53,8 @@ static int only_tests_with_string = 0;
...
@@ -53,6 +53,8 @@ static int only_tests_with_string = 0;
static
int
xml_enabled
=
0
;
static
int
xml_enabled
=
0
;
//! Flag for enabling user-supplied style sheet for XML test report
//! Flag for enabling user-supplied style sheet for XML test report
static
int
custom_xsl_enabled
=
0
;
static
int
custom_xsl_enabled
=
0
;
//! Flag for disabling xsl-style from xml report
static
int
xsl_enabled
=
0
;
//!< Size of the test and suite name buffers
//!< Size of the test and suite name buffers
...
@@ -548,12 +550,13 @@ void
...
@@ -548,12 +550,13 @@ void
printUsage
()
{
printUsage
()
{
printf
(
"Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST]
\n
"
);
printf
(
"Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST]
\n
"
);
printf
(
" [--name-contains SUBSTR] [--show-tests
\n
"
);
printf
(
" [--name-contains SUBSTR] [--show-tests
\n
"
);
printf
(
" [--xml] [--xsl STYLESHEET] [--help]
\n
"
);
printf
(
" [--xml] [--xsl
] [--xsl
STYLESHEET] [--help]
\n
"
);
printf
(
"Options:
\n
"
);
printf
(
"Options:
\n
"
);
printf
(
" --in-proc Executes tests in-process
\n
"
);
printf
(
" --in-proc Executes tests in-process
\n
"
);
printf
(
" --show-tests Prints out all the executable tests
\n
"
);
printf
(
" --show-tests Prints out all the executable tests
\n
"
);
printf
(
" --xml Enables XML logger
\n
"
);
printf
(
" --xml Enables XML logger
\n
"
);
printf
(
" --xsl STYLESHEET Use the given file as XSL style sheet for XML
\n
"
);
printf
(
" --xsl Adds default XSL stylesheet to XML test reports
\n
"
);
printf
(
" --xsl STYLESHEET Use the given file as XSL style sheet for XML
\n
"
);
printf
(
" -t --test TEST Executes only tests with given name
\n
"
);
printf
(
" -t --test TEST Executes only tests with given name
\n
"
);
printf
(
" -ts --name-contains SUBSTR Executes only tests that have given
\n
"
);
printf
(
" -ts --name-contains SUBSTR Executes only tests that have given
\n
"
);
printf
(
" substring in test name
\n
"
);
printf
(
" substring in test name
\n
"
);
...
@@ -601,19 +604,17 @@ ParseOptions(int argc, char *argv[])
...
@@ -601,19 +604,17 @@ ParseOptions(int argc, char *argv[])
strcpy
(
selected_test_name
,
testName
);
strcpy
(
selected_test_name
,
testName
);
}
}
else
if
(
SDL_strcmp
(
arg
,
"--xsl"
)
==
0
)
{
else
if
(
SDL_strcmp
(
arg
,
"--xsl"
)
==
0
)
{
custom_xsl_enabled
=
1
;
xsl_enabled
=
1
;
char
*
stylesheet
=
NULL
;
if
(
(
i
+
1
)
<
argc
)
{
if
(
(
i
+
1
)
<
argc
)
{
stylesheet
=
argv
[
++
i
];
char
*
stylesheet
=
argv
[
++
i
];
}
else
{
if
(
stylesheet
[
0
]
!=
'-'
)
{
printf
(
"runner: filename of XSL stylesheet is missing
\n
"
);
custom_xsl_enabled
=
1
;
printUsage
();
exit
(
1
);
}
memset
(
xsl_stylesheet_name
,
0
,
NAME_BUFFER_SIZE
);
memset
(
xsl_stylesheet_name
,
0
,
NAME_BUFFER_SIZE
);
strncpy
(
xsl_stylesheet_name
,
stylesheet
,
NAME_BUFFER_SIZE
);
strncpy
(
xsl_stylesheet_name
,
stylesheet
,
NAME_BUFFER_SIZE
);
}
}
}
}
else
if
(
SDL_strcmp
(
arg
,
"--name-contains"
)
==
0
||
SDL_strcmp
(
arg
,
"-ts"
)
==
0
)
{
else
if
(
SDL_strcmp
(
arg
,
"--name-contains"
)
==
0
||
SDL_strcmp
(
arg
,
"-ts"
)
==
0
)
{
only_tests_with_string
=
1
;
only_tests_with_string
=
1
;
...
@@ -685,7 +686,16 @@ main(int argc, char *argv[])
...
@@ -685,7 +686,16 @@ main(int argc, char *argv[])
if
(
xml_enabled
)
{
if
(
xml_enabled
)
{
SetupXMLLogger
();
SetupXMLLogger
();
RunStarted
(
argc
,
argv
,
time
(
0
),
xsl_stylesheet_name
);
char
*
sheet
=
NULL
;
if
(
xsl_enabled
)
{
sheet
=
"style.xsl"
;
// default style sheet;
}
if
(
custom_xsl_enabled
)
{
sheet
=
xsl_stylesheet_name
;
}
RunStarted
(
argc
,
argv
,
time
(
0
),
sheet
);
}
else
{
}
else
{
SetupPlainLogger
();
SetupPlainLogger
();
...
...
test/test-automation/xml.c
View file @
4fdb4d47
...
@@ -197,18 +197,21 @@ XMLOpenDocument(const char *rootTag, const char *xslStyle)
...
@@ -197,18 +197,21 @@ XMLOpenDocument(const char *rootTag, const char *xslStyle)
{
{
const
char
*
doctype
=
"<?xml version=
\"
1.0
\"
encoding=
\"
ISO-8859-1
\"
?>
\n
"
;
const
char
*
doctype
=
"<?xml version=
\"
1.0
\"
encoding=
\"
ISO-8859-1
\"
?>
\n
"
;
//! \todo make this optional (and let the user supply the filename?)
//! \todo refactor this mess
const
char
*
styleStart
=
"<?xml-stylesheet type=
\"
text/xsl
\"
href=
\"
"
;
char
*
style
=
NULL
;
const
char
*
styleEnd
=
"
\"
?>
\n
"
;
if
(
xslStyle
)
{
const
char
*
styleStart
=
"<?xml-stylesheet type=
\"
text/xsl
\"
href=
\"
"
;
const
int
sizeStyleStart
=
SDL_strlen
(
styleStart
);
const
char
*
styleEnd
=
"
\"
?>
\n
"
;
const
int
sizeStyleEnd
=
SDL_strlen
(
styleEnd
);
const
int
sizeStyleSheetName
=
SDL_strlen
(
xslStyle
);
const
int
sizeStyleStart
=
SDL_strlen
(
styleStart
);
const
int
sizeStyleEnd
=
SDL_strlen
(
styleEnd
);
const
int
tempSize
=
sizeStyleStart
+
sizeStyleEnd
+
sizeStyleSheetName
+
1
;
const
int
sizeStyleSheetName
=
SDL_strlen
(
xslStyle
);
char
*
style
=
SDL_malloc
(
tempSize
);
memset
(
style
,
0
,
tempSize
);
const
int
tempSize
=
sizeStyleStart
+
sizeStyleEnd
+
sizeStyleSheetName
+
1
;
SDL_snprintf
(
style
,
tempSize
,
"%s%s%s"
,
styleStart
,
xslStyle
,
styleEnd
);
style
=
SDL_malloc
(
tempSize
);
memset
(
style
,
0
,
tempSize
);
SDL_snprintf
(
style
,
tempSize
,
"%s%s%s"
,
styleStart
,
xslStyle
,
styleEnd
);
}
memset
(
buffer
,
0
,
bufferSize
);
memset
(
buffer
,
0
,
bufferSize
);
SDL_snprintf
(
buffer
,
bufferSize
,
"<%s>"
,
rootTag
);
SDL_snprintf
(
buffer
,
bufferSize
,
"<%s>"
,
rootTag
);
...
@@ -217,19 +220,27 @@ XMLOpenDocument(const char *rootTag, const char *xslStyle)
...
@@ -217,19 +220,27 @@ XMLOpenDocument(const char *rootTag, const char *xslStyle)
root
=
rootTag
;
// it's fine, as long as rootTag points to static memory?
root
=
rootTag
;
// it's fine, as long as rootTag points to static memory?
const
int
doctypeSize
=
SDL_strlen
(
doctype
);
char
*
retBuf
=
NULL
;
const
int
styleSize
=
SDL_strlen
(
style
);
if
(
xslStyle
)
{
const
int
tagSize
=
SDL_strlen
(
buffer
);
const
int
doctypeSize
=
SDL_strlen
(
doctype
);
const
int
styleSize
=
SDL_strlen
(
style
);
const
int
tagSize
=
SDL_strlen
(
buffer
);
const
int
size
=
doctypeSize
+
styleSize
+
tagSize
+
1
;
// extra byte for '\0'
const
int
size
=
doctypeSize
+
styleSize
+
tagSize
+
1
;
// extra byte for '\0'
char
*
retBuf
=
SDL_malloc
(
size
);
retBuf
=
SDL_malloc
(
size
);
// fill in the previous allocated retBuf
SDL_snprintf
(
retBuf
,
size
,
"%s%s%s"
,
doctype
,
style
,
buffer
);
strcat
(
retBuf
,
doctype
);
strcat
(
retBuf
,
style
);
strcat
(
retBuf
,
buffer
);
SDL_free
(
style
);
SDL_free
(
style
);
}
else
{
const
int
doctypeSize
=
SDL_strlen
(
doctype
);
const
int
tagSize
=
SDL_strlen
(
buffer
);
const
int
size
=
doctypeSize
+
tagSize
+
1
;
// extra byte for '\0'
retBuf
=
SDL_malloc
(
size
);
SDL_snprintf
(
retBuf
,
size
,
"%s%s"
,
doctype
,
buffer
);
}
return
retBuf
;
return
retBuf
;
}
}
...
...
test/test-automation/xml.h
View file @
4fdb4d47
...
@@ -37,6 +37,7 @@ typedef struct Attribute {
...
@@ -37,6 +37,7 @@ typedef struct Attribute {
* Note: XML creation is not thread-safe!
* Note: XML creation is not thread-safe!
*
*
* \param rootTag Root tag for the XML document
* \param rootTag Root tag for the XML document
* \param xslStyle Name of the style sheet file. (empty string if no style is used)
* \return The generated XML output
* \return The generated XML output
*/
*/
char
*
XMLOpenDocument
(
const
char
*
rootTag
,
const
char
*
xslStyle
);
char
*
XMLOpenDocument
(
const
char
*
rootTag
,
const
char
*
xslStyle
);
...
...
test/test-automation/xml_logger.c
View file @
4fdb4d47
...
@@ -101,20 +101,14 @@ XMLOutputter(const int currentIdentLevel,
...
@@ -101,20 +101,14 @@ XMLOutputter(const int currentIdentLevel,
fprintf
(
stdout
,
"Error: Tried to output invalid string!"
);
fprintf
(
stdout
,
"Error: Tried to output invalid string!"
);
}
}
SDL_free
(
message
);
SDL_free
(
(
char
*
)
message
);
}
}
void
void
XMLRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
XMLRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
void
*
data
)
void
*
data
)
{
{
char
*
xslStylesheet
=
"style.xsl"
;
char
*
xslStylesheet
=
(
char
*
)
data
;
if
(
data
!=
NULL
)
{
char
*
tmp
=
(
char
*
)
data
;
if
(
SDL_strlen
(
tmp
)
>
0
)
{
xslStylesheet
=
tmp
;
}
}
char
*
output
=
XMLOpenDocument
(
documentRoot
,
xslStylesheet
);
char
*
output
=
XMLOpenDocument
(
documentRoot
,
xslStylesheet
);
XMLOutputter
(
indentLevel
++
,
YES
,
output
);
XMLOutputter
(
indentLevel
++
,
YES
,
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