summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests/llframetimer_test.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-24 08:55:20 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-24 08:55:20 -0400
commit3ae8a821c3b627f3b02df636e7649f28b97d6f57 (patch)
tree79d5d3f2b262b7f5d60cc6135b80221878aa74b8 /indra/llcommon/tests/llframetimer_test.cpp
parent39b17157f9c31a4b911113561d4fc8f86396c430 (diff)
parentfde0868231a25b8c9ce03a86cb53f1738d35688d (diff)
merge
Diffstat (limited to 'indra/llcommon/tests/llframetimer_test.cpp')
-rwxr-xr-xindra/llcommon/tests/llframetimer_test.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/indra/llcommon/tests/llframetimer_test.cpp b/indra/llcommon/tests/llframetimer_test.cpp
index 8ac1c91a3a..be372bb855 100755
--- a/indra/llcommon/tests/llframetimer_test.cpp
+++ b/indra/llcommon/tests/llframetimer_test.cpp
@@ -84,25 +84,34 @@ namespace tut
template<> template<>
void frametimer_object_t::test<3>()
{
+ clock_t t1 = clock();
+ ms_sleep(200);
+ clock_t t2 = clock();
+ clock_t elapsed = t2 - t1 + 1;
+ std::cout << "Note: using clock(), ms_sleep() actually took " << (long)elapsed << "ms" << std::endl;
+
F64 seconds_since_epoch = LLFrameTimer::getTotalSeconds();
seconds_since_epoch += 2.0;
LLFrameTimer timer;
timer.setExpiryAt(seconds_since_epoch);
- ensure("timer not expired on create", !timer.hasExpired());
- int ii;
- for(ii = 0; ii < 10; ++ii)
+ /*
+ * Note that the ms_sleep(200) below is only guaranteed to return
+ * 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);
- LLFrameTimer::updateFrameTime();
- }
- ensure("timer not expired after a bit", !timer.hasExpired());
- for(ii = 0; ii < 10; ++ii)
- {
- ms_sleep(100);
- LLFrameTimer::updateFrameTime();
+ ms_sleep(200);
+ LLFrameTimer::updateFrameTime();
+ iterations_until_expiration++;
}
- ensure("timer expired", timer.hasExpired());
+ ensure("timer took too long to expire", iterations_until_expiration <= 10);
}
+
/*
template<> template<>
void frametimer_object_t::test<4>()