diff --git a/test/test_condition_variable_any_dispatch.cpp b/test/test_condition_variable_any_dispatch.cpp index f0331edd..e227fd45 100644 --- a/test/test_condition_variable_any_dispatch.cpp +++ b/test/test_condition_variable_any_dispatch.cpp @@ -225,7 +225,7 @@ void fn2( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -258,7 +258,7 @@ void fn3( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(test2 != 0); BOOST_CHECK(r); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(250+100)); BOOST_CHECK(test2 == 0); BOOST_CHECK(!r); } @@ -280,7 +280,7 @@ void fn4( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -301,7 +301,7 @@ void fn5( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(t1 - t0 < ms(250+1000)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100)); BOOST_CHECK(test2 == 0); } ++runs; diff --git a/test/test_condition_variable_any_post.cpp b/test/test_condition_variable_any_post.cpp index eb41abe8..da6d882a 100644 --- a/test/test_condition_variable_any_post.cpp +++ b/test/test_condition_variable_any_post.cpp @@ -225,7 +225,7 @@ void fn2( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -258,7 +258,7 @@ void fn3( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(test2 != 0); BOOST_CHECK(r); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(250+100)); BOOST_CHECK(test2 == 0); BOOST_CHECK(!r); } @@ -280,7 +280,7 @@ void fn4( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -301,7 +301,7 @@ void fn5( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) BOOST_CHECK(t1 - t0 < ms(250+1000)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100)); BOOST_CHECK(test2 == 0); } ++runs; diff --git a/test/test_condition_variable_dispatch.cpp b/test/test_condition_variable_dispatch.cpp index ddb5eaf4..dc5e00fe 100644 --- a/test/test_condition_variable_dispatch.cpp +++ b/test/test_condition_variable_dispatch.cpp @@ -222,7 +222,7 @@ void fn2( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -254,7 +254,7 @@ void fn3( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(test2 != 0); BOOST_CHECK(r); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(250+100)); BOOST_CHECK(test2 == 0); BOOST_CHECK(!r); } @@ -275,7 +275,7 @@ void fn4( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -295,7 +295,7 @@ void fn5( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(t1 - t0 < ms(250+1000)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100)); BOOST_CHECK(test2 == 0); } ++runs; diff --git a/test/test_condition_variable_post.cpp b/test/test_condition_variable_post.cpp index 7c11d618..3f043a7b 100644 --- a/test/test_condition_variable_post.cpp +++ b/test/test_condition_variable_post.cpp @@ -222,7 +222,7 @@ void fn2( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -254,7 +254,7 @@ void fn3( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(test2 != 0); BOOST_CHECK(r); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(250+100)); BOOST_CHECK(test2 == 0); BOOST_CHECK(!r); } @@ -275,7 +275,7 @@ void fn4( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(t1 - t0 < ms(250)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100+1000)); BOOST_CHECK(test2 == 0); } ++runs; @@ -295,7 +295,7 @@ void fn5( boost::fibers::mutex & m, boost::fibers::condition_variable & cv) { BOOST_CHECK(t1 - t0 < ms(250+1000)); BOOST_CHECK(test2 != 0); } else { - BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+2)); + BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+100)); BOOST_CHECK(test2 == 0); } ++runs; diff --git a/test/test_fiber_dispatch.cpp b/test/test_fiber_dispatch.cpp index 47992a54..3cdb9cb3 100644 --- a/test/test_fiber_dispatch.cpp +++ b/test/test_fiber_dispatch.cpp @@ -269,7 +269,6 @@ void test_join_bind() { BOOST_CHECK_EQUAL( value1, 3); BOOST_CHECK_EQUAL( value2, "abc"); } -#if 0 { value1 = 0; value2 = ""; @@ -284,12 +283,11 @@ void test_join_bind() { std::placeholders::_1, std::placeholders::_2 ), - i, abc); + i, std::ref( abc) ); f.join(); BOOST_CHECK_EQUAL( value1, 3); BOOST_CHECK_EQUAL( value2, "abc"); } -#endif } void test_join_in_fiber() { @@ -364,11 +362,9 @@ void test_sleep_for() { boost::this_fiber::sleep_for(ms); time_point t1 = Clock::now(); std::chrono::nanoseconds ns = (t1 - t0) - ms; - std::chrono::nanoseconds err = ms / 100; - // The time slept is within 1% of 500ms + std::chrono::nanoseconds err = ms / 10; // This test is spurious as it depends on the time the fiber system switches the fiber BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count()); - //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+std::chrono::milliseconds(1000)).count()); } void test_sleep_until() { @@ -380,11 +376,9 @@ void test_sleep_until() { boost::this_fiber::sleep_until(t0 + ms); time_point t1 = Clock::now(); std::chrono::nanoseconds ns = (t1 - t0) - ms; - std::chrono::nanoseconds err = ms / 100; - // The time slept is within 1% of 500ms + std::chrono::nanoseconds err = ms / 10; // This test is spurious as it depends on the time the thread system switches the threads BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count()); - //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+std::chrono::milliseconds(1000)).count()); } { typedef std::chrono::system_clock Clock; @@ -394,11 +388,9 @@ void test_sleep_until() { boost::this_fiber::sleep_until(t0 + ms); time_point t1 = Clock::now(); std::chrono::nanoseconds ns = (t1 - t0) - ms; - std::chrono::nanoseconds err = ms / 100; - // The time slept is within 1% of 500ms + std::chrono::nanoseconds err = ms / 10; // This test is spurious as it depends on the time the thread system switches the threads BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count()); - //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+std::chrono::milliseconds(1000)).count()); } } diff --git a/test/test_fiber_post.cpp b/test/test_fiber_post.cpp index fc7aa23a..96671554 100644 --- a/test/test_fiber_post.cpp +++ b/test/test_fiber_post.cpp @@ -269,7 +269,6 @@ void test_join_bind() { BOOST_CHECK_EQUAL( value1, 3); BOOST_CHECK_EQUAL( value2, "abc"); } -#if 0 { value1 = 0; value2 = ""; @@ -284,12 +283,11 @@ void test_join_bind() { std::placeholders::_1, std::placeholders::_2 ), - i, abc); + i, std::ref( abc) ); f.join(); BOOST_CHECK_EQUAL( value1, 3); BOOST_CHECK_EQUAL( value2, "abc"); } -#endif } void test_join_in_fiber() { @@ -364,11 +362,9 @@ void test_sleep_for() { boost::this_fiber::sleep_for(ms); time_point t1 = Clock::now(); std::chrono::nanoseconds ns = (t1 - t0) - ms; - std::chrono::nanoseconds err = ms / 100; - // The time slept is within 1% of 500ms + std::chrono::nanoseconds err = ms / 10; // This test is spurious as it depends on the time the fiber system switches the fiber BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count()); - //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+std::chrono::milliseconds(1000)).count()); } void test_sleep_until() { @@ -380,11 +376,9 @@ void test_sleep_until() { boost::this_fiber::sleep_until(t0 + ms); time_point t1 = Clock::now(); std::chrono::nanoseconds ns = (t1 - t0) - ms; - std::chrono::nanoseconds err = ms / 100; - // The time slept is within 1% of 500ms + std::chrono::nanoseconds err = ms / 10; // This test is spurious as it depends on the time the thread system switches the threads BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count()); - //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+std::chrono::milliseconds(1000)).count()); } { typedef std::chrono::system_clock Clock; @@ -394,11 +388,9 @@ void test_sleep_until() { boost::this_fiber::sleep_until(t0 + ms); time_point t1 = Clock::now(); std::chrono::nanoseconds ns = (t1 - t0) - ms; - std::chrono::nanoseconds err = ms / 100; - // The time slept is within 1% of 500ms + std::chrono::nanoseconds err = ms / 10; // This test is spurious as it depends on the time the thread system switches the threads BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count()); - //BOOST_TEST(std::abs(static_cast(ns.count())) < (err+std::chrono::milliseconds(1000)).count()); } } diff --git a/test/test_future_dispatch.cpp b/test/test_future_dispatch.cpp index 49cda20d..2990ec41 100644 --- a/test/test_future_dispatch.cpp +++ b/test/test_future_dispatch.cpp @@ -99,7 +99,7 @@ void fn12( boost::fibers::promise< int& > p) { } void fn13( boost::fibers::promise< void > p) { - boost::this_fiber::sleep_for( ms(500) ); + boost::this_fiber::sleep_for( ms(400) ); p.set_value(); } @@ -414,7 +414,7 @@ void test_future_wait_for() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_for( ms(300) ); + status = f1.wait_for( ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -434,7 +434,7 @@ void test_future_wait_for_ref() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_for( ms(300) ); + status = f1.wait_for( ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -454,7 +454,7 @@ void test_future_wait_for_void() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_for( ms(300) ); + status = f1.wait_for( ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -474,7 +474,7 @@ void test_future_wait_until() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_until( Clock::now() + ms(300) ); + status = f1.wait_until( Clock::now() + ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -494,7 +494,7 @@ void test_future_wait_until_ref() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_until( Clock::now() + ms(300) ); + status = f1.wait_until( Clock::now() + ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -514,7 +514,7 @@ void test_future_wait_until_void() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_until( Clock::now() + ms(300) ); + status = f1.wait_until( Clock::now() + ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); diff --git a/test/test_future_post.cpp b/test/test_future_post.cpp index b6c847a0..01deb26f 100644 --- a/test/test_future_post.cpp +++ b/test/test_future_post.cpp @@ -99,7 +99,7 @@ void fn12( boost::fibers::promise< int& > p) { } void fn13( boost::fibers::promise< void > p) { - boost::this_fiber::sleep_for( ms(500) ); + boost::this_fiber::sleep_for( ms(400) ); p.set_value(); } @@ -414,7 +414,7 @@ void test_future_wait_for() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_for( ms(300) ); + status = f1.wait_for( ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -434,7 +434,7 @@ void test_future_wait_for_ref() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_for( ms(300) ); + status = f1.wait_for( ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -454,7 +454,7 @@ void test_future_wait_for_void() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_for( ms(300) ); + status = f1.wait_for( ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -474,7 +474,7 @@ void test_future_wait_until() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_until( Clock::now() + ms(300) ); + status = f1.wait_until( Clock::now() + ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -494,7 +494,7 @@ void test_future_wait_until_ref() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_until( Clock::now() + ms(300) ); + status = f1.wait_until( Clock::now() + ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() ); @@ -514,7 +514,7 @@ void test_future_wait_until_void() { BOOST_CHECK( boost::fibers::future_status::timeout == status); BOOST_CHECK( f1.valid() ); - status = f1.wait_until( Clock::now() + ms(300) ); + status = f1.wait_until( Clock::now() + ms(400) ); BOOST_CHECK( boost::fibers::future_status::ready == status); BOOST_CHECK( f1.valid() );