Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82459 - in trunk/libs/thread/test: sync/futures/async sync/mutual_exclusion/locks/unique_lock/cons sync/mutual_exclusion/shared_mutex sync/mutual_exclusion/timed_mutex threads/thread/members
From: vicente.botet_at_[hidden]
Date: 2013-01-12 04:48:55


Author: viboes
Date: 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
New Revision: 82459
URL: http://svn.boost.org/trac/boost/changeset/82459

Log:
Thread: adjust some durations on tests
Text files modified:
   trunk/libs/thread/test/sync/futures/async/async_pass.cpp | 36 +++++++++++++++++++++++-------------
   trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp | 38 +++++++++++++++++++++++++++-----------
   trunk/libs/thread/test/sync/mutual_exclusion/shared_mutex/try_lock_for_pass.cpp | 3 ++-
   trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp | 3 ++-
   trunk/libs/thread/test/threads/thread/members/try_join_for_pass.cpp | 2 +-
   trunk/libs/thread/test/threads/thread/members/try_join_until_pass.cpp | 4 ++--
   6 files changed, 57 insertions(+), 29 deletions(-)

Modified: trunk/libs/thread/test/sync/futures/async/async_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/futures/async/async_pass.cpp (original)
+++ trunk/libs/thread/test/sync/futures/async/async_pass.cpp 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
@@ -113,7 +113,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -130,7 +131,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -148,7 +150,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -165,7 +168,7 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
     std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
@@ -182,7 +185,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -216,7 +220,7 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(&f.get() == &i);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
     std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
@@ -233,7 +237,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(&f.get() == &i);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -249,7 +254,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(&f.get() == &i);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -288,7 +294,8 @@
     std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
     Clock::time_point t1 = Clock::now();
     std::cout << __FILE__ <<"["<<__LINE__<<"]"<<std::endl;
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -304,7 +311,7 @@
     Clock::time_point t0 = Clock::now();
     f.get();
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
     std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
@@ -321,7 +328,8 @@
     Clock::time_point t0 = Clock::now();
     f.get();
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -358,7 +366,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(*f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");
@@ -377,7 +386,8 @@
     Clock::time_point t0 = Clock::now();
     BOOST_TEST(*f.get() == 3);
     Clock::time_point t1 = Clock::now();
- BOOST_TEST(t1 - t0 < ms(100));
+ BOOST_TEST(t1 - t0 < ms(120));
+ std::cout << __FILE__ <<"["<<__LINE__<<"] "<< (t1 - t0).count() << std::endl;
     } catch (std::exception& ex) {
       std::cout << __FILE__ <<"["<<__LINE__<<"]"<<ex.what() << std::endl;
       BOOST_TEST(false && "exception thrown");

Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
@@ -30,8 +30,8 @@
 void f()
 {
 #if defined BOOST_THREAD_USES_CHRONO
- time_point t0 = Clock::now();
   {
+ time_point t0 = Clock::now();
 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
   auto
 #else
@@ -39,8 +39,13 @@
 #endif
     lk = boost::make_unique_lock(m, boost::try_to_lock);
     BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
   }
   {
+ time_point t0 = Clock::now();
 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
   auto
 #else
@@ -48,8 +53,13 @@
 #endif
     lk = boost::make_unique_lock(m, boost::try_to_lock);
     BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
   }
   {
+ time_point t0 = Clock::now();
 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
   auto
 #else
@@ -57,22 +67,28 @@
 #endif
     lk = boost::make_unique_lock(m, boost::try_to_lock);
     BOOST_TEST(lk.owns_lock() == false);
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
   }
- while (true)
   {
+ time_point t0 = Clock::now();
+ while (true)
+ {
 #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
- auto
+ auto
 #else
- boost::unique_lock<boost::mutex>
+ boost::unique_lock<boost::mutex>
 #endif
- lk = boost::make_unique_lock(m, boost::try_to_lock);
- if (lk.owns_lock()) break;
+ lk = boost::make_unique_lock(m, boost::try_to_lock);
+ if (lk.owns_lock()) break;
+ }
+ time_point t1 = Clock::now();
+ ns d = t1 - t0 - ms(250);
+ // This test is spurious as it depends on the time the thread system switches the threads
+ BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
   }
- time_point t1 = Clock::now();
- //m.unlock();
- ns d = t1 - t0 - ms(250);
- // This test is spurious as it depends on the time the thread system switches the threads
- BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
 #else
 // time_point t0 = Clock::now();
 // {

Modified: trunk/libs/thread/test/sync/mutual_exclusion/shared_mutex/try_lock_for_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/shared_mutex/try_lock_for_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/shared_mutex/try_lock_for_pass.cpp 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
@@ -64,7 +64,8 @@
   {
     m.lock();
     boost::thread t(f2);
- boost::this_thread::sleep_for(ms(300));
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::this_thread::sleep_for(ms(300)+ms(1000));
     m.unlock();
     t.join();
   }

Modified: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_for_pass.cpp 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
@@ -66,7 +66,8 @@
   {
     m.lock();
     boost::thread t(f2);
- boost::this_thread::sleep_for(ms(300));
+ // This test is spurious as it depends on the time the thread system switches the threads
+ boost::this_thread::sleep_for(ms(300)+ms(1000));
     m.unlock();
     t.join();
   }

Modified: trunk/libs/thread/test/threads/thread/members/try_join_for_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/members/try_join_for_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/members/try_join_for_pass.cpp 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
@@ -88,7 +88,7 @@
   {
     boost::thread t0( (G()));
     BOOST_TEST(t0.joinable());
- BOOST_TEST(t0.try_join_for(boost::chrono::milliseconds(50)));
+ BOOST_TEST(t0.try_join_for(boost::chrono::milliseconds(150)));
     BOOST_TEST(!t0.joinable());
   }
   {

Modified: trunk/libs/thread/test/threads/thread/members/try_join_until_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/members/try_join_until_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/members/try_join_until_pass.cpp 2013-01-12 04:48:54 EST (Sat, 12 Jan 2013)
@@ -89,7 +89,7 @@
   {
     boost::thread t0( (G()));
     BOOST_TEST(t0.joinable());
- t0.try_join_until(boost::chrono::steady_clock::now()+boost::chrono::milliseconds(50));
+ t0.try_join_until(boost::chrono::steady_clock::now()+boost::chrono::milliseconds(150));
     BOOST_TEST(!t0.joinable());
   }
   {
@@ -141,7 +141,7 @@
   {
     boost::thread t0( (G()));
     BOOST_TEST(t0.joinable());
- t0.try_join_until(boost::chrono::steady_clock::now()+boost::chrono::milliseconds(50));
+ t0.try_join_until(boost::chrono::steady_clock::now()+boost::chrono::milliseconds(150));
     try
     {
       t0.join();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk