Skip to content
Snippets Groups Projects
Commit dbdbcbbd authored by Oz Linden's avatar Oz Linden
Browse files

rewrite an llframetimer test to be less sensitive to extended ms_sleep calls

parent fbaff6d3
No related branches found
No related tags found
No related merge requests found
...@@ -88,21 +88,24 @@ namespace tut ...@@ -88,21 +88,24 @@ namespace tut
seconds_since_epoch += 2.0; seconds_since_epoch += 2.0;
LLFrameTimer timer; LLFrameTimer timer;
timer.setExpiryAt(seconds_since_epoch); timer.setExpiryAt(seconds_since_epoch);
ensure("timer not expired on create", !timer.hasExpired()); /*
int ii; * Note that the ms_sleep(200) below is only guaranteed to return
for(ii = 0; ii < 10; ++ii) * in 200ms _or_more_, so it should be true that by the 10th
* iteration we've gotten to the 2 seconds requested above
* and the timer should expire, but it can expire in fewer iterations
* if one or more of the ms_sleep calls takes longer.
* (as it did when we moved to Mac OS X 10.10)
*/
int iterations_until_expiration = 0;
while ( !timer.hasExpired() )
{ {
ms_sleep(150); ms_sleep(200);
LLFrameTimer::updateFrameTime(); LLFrameTimer::updateFrameTime();
} iterations_until_expiration++;
ensure("timer not expired after a bit", !timer.hasExpired());
for(ii = 0; ii < 10; ++ii)
{
ms_sleep(100);
LLFrameTimer::updateFrameTime();
} }
ensure("timer expired", timer.hasExpired()); ensure("timer took too long to expire", iterations_until_expiration <= 10);
} }
/* /*
template<> template<> template<> template<>
void frametimer_object_t::test<4>() void frametimer_object_t::test<4>()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment