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
75691b7b
Commit
75691b7b
authored
Jun 01, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring runner.c. Added --help/-h command line option.
parent
de0a31c8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
18 deletions
+45
-18
runner.c
test/test-automation/runner.c
+45
-18
No files found.
test/test-automation/runner.c
View file @
75691b7b
...
@@ -30,23 +30,43 @@
...
@@ -30,23 +30,43 @@
//!< Function pointer to a test case function
//!< Function pointer to a test case function
typedef
int
(
*
TestCase
)(
void
*
arg
);
typedef
int
(
*
TestCase
)(
void
*
arg
);
//!< Flag for executing tests in-process
static
int
execute_inproc
=
0
;
/*!
/*!
* Loads test suite which is implemented as dynamic library.
* Returns the name for the dynamic library
* which implements the test suite.
*
*
* \return Pointer to loaded test suite, or NULL if library could not be loaded
* (in the future: scans the test/ directory and
* returns the names of the dynamic libraries
* implementing the test suites)
*
* \return Name of the dummy test suite
*/
*/
void
*
char
*
LoadTestSuite
()
ScanForTestSuites
()
{
{
#if defined(linux) || defined( __linux)
#if defined(linux) || defined( __linux)
char
*
libName
=
"tests/libtest.so"
;
char
*
libName
=
"tests/libtest.so"
;
#else
#else
char
*
libName
=
"tests/libtest.dylib"
;
char
*
libName
=
"tests/libtest.dylib"
;
#endif
#endif
return
libName
;
}
void
*
library
=
SDL_LoadObject
(
libName
);
/*!
* Loads test suite which is implemented as dynamic library.
*
* \param test0,330
*
* \return Pointer to loaded test suite, or NULL if library could not be loaded
*/
void
*
LoadTestSuite
(
char
*
testSuiteName
)
{
void
*
library
=
SDL_LoadObject
(
testSuiteName
);
if
(
library
==
NULL
)
{
if
(
library
==
NULL
)
{
fprintf
(
stderr
,
"Loading %s failed
\n
"
,
lib
Name
);
fprintf
(
stderr
,
"Loading %s failed
\n
"
,
testSuite
Name
);
fprintf
(
stderr
,
"%s
\n
"
,
SDL_GetError
());
fprintf
(
stderr
,
"%s
\n
"
,
SDL_GetError
());
}
}
...
@@ -127,11 +147,11 @@ HandleTestReturnValue(int stat_lock)
...
@@ -127,11 +147,11 @@ HandleTestReturnValue(int stat_lock)
return
returnValue
;
return
returnValue
;
}
}
//!< Flag for executing tests in-process
static
int
execute_inproc
=
0
;
/*!
/*!
* Parse command line arguments
* Parse command line arguments
*
* \param argc Count of command line arguments
* \param argv Array of commond lines arguments
*/
*/
void
void
ParseOptions
(
int
argc
,
char
*
argv
[])
ParseOptions
(
int
argc
,
char
*
argv
[])
...
@@ -140,9 +160,17 @@ ParseOptions(int argc, char *argv[])
...
@@ -140,9 +160,17 @@ ParseOptions(int argc, char *argv[])
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
const
char
*
arg
=
argv
[
i
];
const
char
*
arg
=
argv
[
i
];
if
(
SDL_strcmp
(
arg
,
"--in-proc"
)
==
0
)
{
if
(
SDL_strcmp
(
arg
,
"--in-proc"
)
==
0
)
{
execute_inproc
=
1
;
execute_inproc
=
1
;
}
}
else
if
(
SDL_strcmp
(
arg
,
"--help"
)
==
0
||
SDL_strcmp
(
arg
,
"-h"
)
==
0
)
{
printf
(
"Usage: ./runner [--in-proc] [--help]
\n
"
);
printf
(
"Options:
\n
"
);
printf
(
" --in-proc Executes tests in-process
\n
"
);
printf
(
" --help Print this help.:
\n
"
);
exit
(
0
);
}
// \todo print error for unknown option
}
}
}
}
...
@@ -161,11 +189,10 @@ main(int argc, char *argv[])
...
@@ -161,11 +189,10 @@ main(int argc, char *argv[])
int
failureCount
=
0
,
passCount
=
0
;
int
failureCount
=
0
,
passCount
=
0
;
char
*
libName
=
"libtest"
;
const
Uint32
startTicks
=
SDL_GetTicks
();
const
Uint32
startTicks
=
SDL_GetTicks
();
void
*
suite
=
LoadTestSuite
();
char
*
testSuiteName
=
ScanForTestSuites
();
void
*
suite
=
LoadTestSuite
(
testSuiteName
);
TestCaseReference
**
tests
=
QueryTestCases
(
suite
);
TestCaseReference
**
tests
=
QueryTestCases
(
suite
);
TestCaseReference
*
reference
=
NULL
;
TestCaseReference
*
reference
=
NULL
;
...
@@ -173,11 +200,11 @@ main(int argc, char *argv[])
...
@@ -173,11 +200,11 @@ main(int argc, char *argv[])
for
(
reference
=
tests
[
counter
];
reference
;
reference
=
tests
[
++
counter
])
{
for
(
reference
=
tests
[
counter
];
reference
;
reference
=
tests
[
++
counter
])
{
if
(
reference
->
enabled
==
TEST_DISABLED
)
{
if
(
reference
->
enabled
==
TEST_DISABLED
)
{
printf
(
"Test %s (in %s) disabled. Omitting...
\n
"
,
reference
->
name
,
lib
Name
);
printf
(
"Test %s (in %s) disabled. Omitting...
\n
"
,
reference
->
name
,
testSuite
Name
);
}
else
{
}
else
{
char
*
testname
=
reference
->
name
;
char
*
testname
=
reference
->
name
;
printf
(
"Running %s (in %s):
\n
"
,
testname
,
lib
Name
);
printf
(
"Running %s (in %s):
\n
"
,
testname
,
testSuite
Name
);
int
retVal
=
1
;
int
retVal
=
1
;
if
(
execute_inproc
)
{
if
(
execute_inproc
)
{
...
@@ -198,10 +225,10 @@ main(int argc, char *argv[])
...
@@ -198,10 +225,10 @@ main(int argc, char *argv[])
if
(
retVal
)
{
if
(
retVal
)
{
failureCount
++
;
failureCount
++
;
printf
(
"%s (in %s): FAILED
\n
"
,
testname
,
lib
Name
);
printf
(
"%s (in %s): FAILED
\n
"
,
testname
,
testSuite
Name
);
}
else
{
}
else
{
passCount
++
;
passCount
++
;
printf
(
"%s (in %s): ok
\n
"
,
testname
,
lib
Name
);
printf
(
"%s (in %s): ok
\n
"
,
testname
,
testSuite
Name
);
}
}
}
}
...
...
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