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
47fe1687
Commit
47fe1687
authored
Jul 20, 2011
by
Markus Kauppila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using SDL timer to kill hung tests.
parent
82d0a869
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
runner.c
test/test-automation/runner.c
+20
-7
No files found.
test/test-automation/runner.c
View file @
47fe1687
...
...
@@ -585,29 +585,39 @@ LoadCountFailedAssertsFunction(void *suite) {
* \param timeout Timeout interval in seconds!
* \param callback Function that will be called after timeout has elapsed
*/
void
SetTestTimeout
(
int
timeout
,
void
(
*
callback
)(
int
))
void
SetTestTimeout
(
int
timeout
,
void
(
*
callback
)(
int
))
{
if
(
callback
==
NULL
)
{
fprintf
(
stderr
,
"Error: timeout callback can't be NULL"
);
}
if
(
timeout
<
0
)
{
fprintf
(
stderr
,
"Error: timeout value must be bigger than zero."
);
}
#if 0
int
tm
=
(
timeout
>
universal_timeout
?
timeout
:
universal_timeout
);
#if 1
/* Init SDL timer if not initialized before */
if
(
SDL_WasInit
(
SDL_INIT_TIMER
)
==
0
)
{
if
(
SDL_InitSubSystem
(
SDL_INIT_TIMER
))
{
fprintf
(
stderr
,
"Error: Failed to init timer subsystem"
);
fprintf
(
stderr
,
"%s
\n
"
,
SDL_GetError
());
}
}
/* Note:
* SDL_Init(SDL_INIT_TIMER) should be successfully called before using this
*/
int timeoutInMilliseconds = timeout * 1000;
int
timeoutInMilliseconds
=
tm
*
1000
;
SDL_TimerID
timerID
=
SDL_AddTimer
(
timeoutInMilliseconds
,
callback
,
0x0
);
if
(
timerID
==
NULL
)
{
fprintf
(
stderr
,
"Error: Creation of SDL timer failed.
\n
"
);
fprintf(stderr, "%s\n", SDL_GetError());
fprintf
(
stderr
,
"
Error:
%s
\n
"
,
SDL_GetError
());
}
#else
int
tm
=
(
timeout
>
universal_timeout
?
timeout
:
universal_timeout
);
signal
(
SIGALRM
,
callback
);
alarm
((
unsigned
int
)
tm
);
#endif
...
...
@@ -1075,5 +1085,8 @@ main(int argc, char *argv[])
RunEnded
(
totalTestPassCount
+
totalTestFailureCount
,
suiteCounter
,
totalTestPassCount
,
totalTestFailureCount
,
totalTestSkipCount
,
time
(
0
),
totalRunTime
);
// Some SDL subsystem might be init'ed so shut them down
SDL_Quit
();
return
(
totalTestFailureCount
?
1
:
0
);
}
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