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
5f77401c
Commit
5f77401c
authored
Jun 30, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added user-supplied XSL style sheets for XML-based test reports.
Added new command line option: --xsl.
parent
cdc832d2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
12 deletions
+62
-12
logger.h
test/test-automation/logger.h
+3
-2
plain_logger.c
test/test-automation/plain_logger.c
+2
-1
plain_logger.h
test/test-automation/plain_logger.h
+4
-1
runner.c
test/test-automation/runner.c
+25
-2
xml.c
test/test-automation/xml.c
+14
-2
xml.h
test/test-automation/xml.h
+1
-1
xml_logger.c
test/test-automation/xml_logger.c
+11
-2
xml_logger.h
test/test-automation/xml_logger.h
+2
-1
No files found.
test/test-automation/logger.h
View file @
5f77401c
...
@@ -25,9 +25,10 @@
...
@@ -25,9 +25,10 @@
/*!
/*!
* Typedefs for function pointers that implement the generic
* Typedefs for function pointers that implement the generic
* logging interface
* logging interface. See the headers of implementations (plain_logger.h or
* xml_logger.h) for more information.
*/
*/
typedef
void
(
*
RunStartedFp
)(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
);
typedef
void
(
*
RunStartedFp
)(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
void
*
data
);
typedef
void
(
*
RunEndedFp
)(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
typedef
void
(
*
RunEndedFp
)(
int
testCount
,
int
suiteCount
,
int
testPassCount
,
int
testFailCount
,
time_t
endTime
,
double
totalRuntime
);
time_t
endTime
,
double
totalRuntime
);
...
...
test/test-automation/plain_logger.c
View file @
5f77401c
...
@@ -28,7 +28,8 @@ Output(const char *message, ...)
...
@@ -28,7 +28,8 @@ Output(const char *message, ...)
}
}
void
void
PlainRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
)
PlainRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
void
*
data
)
{
{
/*
/*
Output("Test run started with following parameters\n");
Output("Test run started with following parameters\n");
...
...
test/test-automation/plain_logger.h
View file @
5f77401c
...
@@ -9,8 +9,11 @@
...
@@ -9,8 +9,11 @@
* \param parameterCount How many parameters were given
* \param parameterCount How many parameters were given
* \param runnerParameters What parameters were given to the runner
* \param runnerParameters What parameters were given to the runner
* \param eventTime When the execution started
* \param eventTime When the execution started
* \param data Any additional data logger needs
*
*/
*/
void
PlainRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
);
void
PlainRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
void
*
data
);
/*!
/*!
* Prints out information about ending the test run.
* Prints out information about ending the test run.
...
...
test/test-automation/runner.c
View file @
5f77401c
...
@@ -51,6 +51,8 @@ static int only_selected_suite = 0;
...
@@ -51,6 +51,8 @@ static int only_selected_suite = 0;
static
int
only_tests_with_string
=
0
;
static
int
only_tests_with_string
=
0
;
//!< Flag for enabling XML logging
//!< Flag for enabling XML logging
static
int
xml_enabled
=
0
;
static
int
xml_enabled
=
0
;
//! Flag for enabling user-supplied style sheet for XML test report
static
int
custom_xsl_enabled
=
0
;
//!< Size of the test and suite name buffers
//!< Size of the test and suite name buffers
...
@@ -63,6 +65,9 @@ char selected_suite_name[NAME_BUFFER_SIZE];
...
@@ -63,6 +65,9 @@ char selected_suite_name[NAME_BUFFER_SIZE];
//!< substring of test case name
//!< substring of test case name
char
testcase_name_substring
[
NAME_BUFFER_SIZE
];
char
testcase_name_substring
[
NAME_BUFFER_SIZE
];
//! Name for user-supplied XSL style sheet name
char
xsl_stylesheet_name
[
NAME_BUFFER_SIZE
];
//! Default directory of the test suites
//! Default directory of the test suites
#define DEFAULT_TEST_DIRECTORY "tests/"
#define DEFAULT_TEST_DIRECTORY "tests/"
...
@@ -535,6 +540,7 @@ printUsage() {
...
@@ -535,6 +540,7 @@ printUsage() {
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 FILENAME Use the given file as XSL style sheet for XML
\n
"
);
// \todo add to wiki
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
"
);
...
@@ -581,6 +587,21 @@ ParseOptions(int argc, char *argv[])
...
@@ -581,6 +587,21 @@ ParseOptions(int argc, char *argv[])
memset
(
selected_test_name
,
0
,
NAME_BUFFER_SIZE
);
memset
(
selected_test_name
,
0
,
NAME_BUFFER_SIZE
);
strcpy
(
selected_test_name
,
testName
);
strcpy
(
selected_test_name
,
testName
);
}
}
else
if
(
SDL_strcmp
(
arg
,
"--xsl"
)
==
0
)
{
custom_xsl_enabled
=
1
;
char
*
stylesheet
=
NULL
;
if
(
(
i
+
1
)
<
argc
)
{
stylesheet
=
argv
[
++
i
];
}
else
{
printf
(
"runner: filename of XSL stylesheet is missing
\n
"
);
printUsage
();
exit
(
1
);
}
memset
(
xsl_stylesheet_name
,
0
,
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
;
char
*
substring
=
NULL
;
char
*
substring
=
NULL
;
...
@@ -649,8 +670,12 @@ main(int argc, char *argv[])
...
@@ -649,8 +670,12 @@ main(int argc, char *argv[])
#endif
#endif
if
(
xml_enabled
)
{
if
(
xml_enabled
)
{
SetupXMLLogger
();
SetupXMLLogger
();
RunStarted
(
argc
,
argv
,
time
(
0
),
xsl_stylesheet_name
);
}
else
{
}
else
{
SetupPlainLogger
();
SetupPlainLogger
();
RunStarted
(
argc
,
argv
,
time
(
0
),
NULL
);
}
}
const
Uint32
startTicks
=
SDL_GetTicks
();
const
Uint32
startTicks
=
SDL_GetTicks
();
...
@@ -671,8 +696,6 @@ main(int argc, char *argv[])
...
@@ -671,8 +696,6 @@ main(int argc, char *argv[])
return
0
;
return
0
;
}
}
RunStarted
(
argc
,
argv
,
time
(
0
));
char
*
currentSuiteName
=
NULL
;
char
*
currentSuiteName
=
NULL
;
int
suiteStartTime
=
SDL_GetTicks
();
int
suiteStartTime
=
SDL_GetTicks
();
...
...
test/test-automation/xml.c
View file @
5f77401c
...
@@ -193,12 +193,22 @@ EscapeString(const char *string)
...
@@ -193,12 +193,22 @@ EscapeString(const char *string)
*/
*/
char
*
char
*
XMLOpenDocument
(
const
char
*
rootTag
)
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 make this optional (and let the user supply the filename?)
const
char
*
style
=
"<?xml-stylesheet type=
\"
text/xsl
\"
href=
\"
style.xsl
\"
?>
\n
"
;
const
char
*
styleStart
=
"<?xml-stylesheet type=
\"
text/xsl
\"
href=
\"
"
;
const
char
*
styleEnd
=
"
\"
?>
\n
"
;
const
int
sizeStyleStart
=
SDL_strlen
(
styleStart
);
const
int
sizeStyleEnd
=
SDL_strlen
(
styleEnd
);
const
int
sizeStyleSheetName
=
SDL_strlen
(
xslStyle
);
const
int
tempSize
=
sizeStyleStart
+
sizeStyleEnd
+
sizeStyleSheetName
+
1
;
char
*
style
=
SDL_malloc
(
tempSize
);
memset
(
style
,
0
,
tempSize
);
snprintf
(
style
,
tempSize
,
"%s%s%s"
,
styleStart
,
xslStyle
,
styleEnd
);
memset
(
buffer
,
0
,
bufferSize
);
memset
(
buffer
,
0
,
bufferSize
);
snprintf
(
buffer
,
bufferSize
,
"<%s>"
,
rootTag
);
snprintf
(
buffer
,
bufferSize
,
"<%s>"
,
rootTag
);
...
@@ -219,6 +229,8 @@ XMLOpenDocument(const char *rootTag)
...
@@ -219,6 +229,8 @@ XMLOpenDocument(const char *rootTag)
strcat
(
retBuf
,
style
);
strcat
(
retBuf
,
style
);
strcat
(
retBuf
,
buffer
);
strcat
(
retBuf
,
buffer
);
SDL_free
(
style
);
return
retBuf
;
return
retBuf
;
}
}
...
...
test/test-automation/xml.h
View file @
5f77401c
...
@@ -39,7 +39,7 @@ typedef struct Attribute {
...
@@ -39,7 +39,7 @@ typedef struct Attribute {
* \param rootTag Root tag for the XML document
* \param rootTag Root tag for the XML document
* \return The generated XML output
* \return The generated XML output
*/
*/
char
*
XMLOpenDocument
(
const
char
*
rootTag
);
char
*
XMLOpenDocument
(
const
char
*
rootTag
,
const
char
*
xslStyle
);
/*!
/*!
* Closes the XML-document.
* Closes the XML-document.
...
...
test/test-automation/xml_logger.c
View file @
5f77401c
...
@@ -105,9 +105,18 @@ XMLOutputter(const int currentIdentLevel,
...
@@ -105,9 +105,18 @@ XMLOutputter(const int currentIdentLevel,
}
}
void
void
XMLRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
)
XMLRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
void
*
data
)
{
{
char
*
output
=
XMLOpenDocument
(
documentRoot
);
char
*
xslStylesheet
=
"style.xsl"
;
if
(
data
!=
NULL
)
{
char
*
tmp
=
(
char
*
)
data
;
if
(
SDL_strlen
(
tmp
)
>
0
)
{
xslStylesheet
=
tmp
;
}
}
char
*
output
=
XMLOpenDocument
(
documentRoot
,
xslStylesheet
);
XMLOutputter
(
indentLevel
++
,
YES
,
output
);
XMLOutputter
(
indentLevel
++
,
YES
,
output
);
output
=
XMLOpenElement
(
parametersElementName
);
output
=
XMLOpenElement
(
parametersElementName
);
...
...
test/test-automation/xml_logger.h
View file @
5f77401c
...
@@ -9,8 +9,9 @@
...
@@ -9,8 +9,9 @@
* \param parameterCount How many parameters were given
* \param parameterCount How many parameters were given
* \param runnerParameters What parameters were given to the runner
* \param runnerParameters What parameters were given to the runner
* \param eventTime When the execution started
* \param eventTime When the execution started
* \param data Any additional data logger needs
*/
*/
void
XMLRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
);
void
XMLRunStarted
(
int
parameterCount
,
char
*
runnerParameters
[],
time_t
eventTime
,
void
*
data
);
/*!
/*!
* Prints out information about ending the test run in XML
* Prints out information about ending the test run in XML
...
...
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