|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78197 - in trunk/libs/thread/test: . sync/mutual_exclusion/locks/unique_lock/cons sync/mutual_exclusion/recursive_mutex sync/mutual_exclusion/timed_mutex threads/thread/constr threads/thread/members
From: vicente.botet_at_[hidden]
Date: 2012-04-25 17:55:10
Author: viboes
Date: 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
New Revision: 78197
URL: http://svn.boost.org/trac/boost/changeset/78197
Log:
Thread: Try to fix some spourious error
Text files modified:
trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp | 2
trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp | 6 ++--
trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp | 2
trunk/libs/thread/test/test_2309.cpp | 15 +++++++--
trunk/libs/thread/test/test_futures.cpp | 60 +++++++++++++++++++++++++++++++++++++++
trunk/libs/thread/test/test_once.cpp | 8 +++++
trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp | 10 ++++++
trunk/libs/thread/test/threads/thread/constr/move_pass.cpp | 1
trunk/libs/thread/test/threads/thread/members/join_pass.cpp | 1
9 files changed, 95 insertions(+), 10 deletions(-)
Modified: trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/duration_pass.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -72,7 +72,7 @@
{
m.lock();
boost::thread t(f2);
- boost::this_thread::sleep_for(ms(300));
+ boost::this_thread::sleep_for(ms(300)+ms(1000));
m.unlock();
t.join();
}
Modified: trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/recursive_mutex/try_lock_pass.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -38,9 +38,9 @@
{
#if defined BOOST_THREAD_USES_CHRONO
time_point t0 = Clock::now();
- BOOST_TEST(!m.try_lock());
- BOOST_TEST(!m.try_lock());
- BOOST_TEST(!m.try_lock());
+// BOOST_TEST(!m.try_lock());
+// BOOST_TEST(!m.try_lock());
+// BOOST_TEST(!m.try_lock());
while (!m.try_lock())
;
time_point t1 = Clock::now();
Modified: trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp
==============================================================================
--- trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp (original)
+++ trunk/libs/thread/test/sync/mutual_exclusion/timed_mutex/try_lock_until_pass.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -66,7 +66,7 @@
{
m.lock();
boost::thread t(f2);
- boost::this_thread::sleep_for(ms(300));
+ boost::this_thread::sleep_for(ms(300)+ms(1000));
m.unlock();
t.join();
}
Modified: trunk/libs/thread/test/test_2309.cpp
==============================================================================
--- trunk/libs/thread/test/test_2309.cpp (original)
+++ trunk/libs/thread/test/test_2309.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -19,18 +19,18 @@
{
boost::this_thread::sleep(boost::posix_time::seconds(100));
}
- catch(boost::thread_interrupted& interrupt)
+ catch (boost::thread_interrupted& interrupt)
{
boost::mutex::scoped_lock lock(mutex_);
cerr << "Thread " << boost::this_thread::get_id() << " got interrupted" << endl;
throw(interrupt);
}
- catch(std::exception& e)
+ catch (std::exception& e)
{
boost::mutex::scoped_lock lock(mutex_);
cerr << "Thread " << boost::this_thread::get_id() << " caught std::exception" << e.what() << endl;
}
- catch(...)
+ catch (...)
{
boost::mutex::scoped_lock lock(mutex_);
cerr << "Thread " << boost::this_thread::get_id() << " caught something else" << endl;
@@ -39,7 +39,9 @@
void test()
{
- boost::thread_group threads;
+ try
+ {
+ boost::thread_group threads;
for (int i = 0; i < 2; ++i)
{
@@ -49,6 +51,11 @@
//boost::this_thread::sleep(1);
threads.interrupt_all();
threads.join_all();
+ }
+ catch (...)
+ {
+ BOOST_CHECK(false && "exception raised");
+ }
}
boost::unit_test_framework::test_suite* init_unit_test_suite(int, char*[])
Modified: trunk/libs/thread/test/test_futures.cpp
==============================================================================
--- trunk/libs/thread/test/test_futures.cpp (original)
+++ trunk/libs/thread/test/test_futures.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -11,9 +11,13 @@
#include <utility>
#include <memory>
#include <string>
+#include <iostream>
#include <boost/test/unit_test.hpp>
+#define LOG \
+ if (false) {} else std::cout << std::endl << __FILE__ << "[" << __LINE__ << "]"
+
#ifndef BOOST_NO_RVALUE_REFERENCES
template<typename T>
typename boost::remove_reference<T>::type&& cast_to_rval(T&& t)
@@ -80,6 +84,7 @@
void test_store_value_from_thread()
{
+ LOG;
boost::promise<int> pi2;
boost::unique_future<int> fi2(pi2.get_future());
boost::thread(set_promise_thread,&pi2);
@@ -94,6 +99,7 @@
void test_store_exception()
{
+ LOG;
boost::promise<int> pi3;
boost::unique_future<int> fi3=pi3.get_future();
boost::thread(set_promise_exception_thread,&pi3);
@@ -115,6 +121,7 @@
void test_initial_state()
{
+ LOG;
boost::unique_future<int> fi;
BOOST_CHECK(!fi.is_ready());
BOOST_CHECK(!fi.has_value());
@@ -135,6 +142,7 @@
void test_waiting_future()
{
+ LOG;
boost::promise<int> pi;
boost::unique_future<int> fi;
fi=pi.get_future();
@@ -149,6 +157,7 @@
void test_cannot_get_future_twice()
{
+ LOG;
boost::promise<int> pi;
pi.get_future();
@@ -165,6 +174,7 @@
void test_set_value_updates_future_state()
{
+ LOG;
boost::promise<int> pi;
boost::unique_future<int> fi;
fi=pi.get_future();
@@ -179,6 +189,7 @@
void test_set_value_can_be_retrieved()
{
+ LOG;
boost::promise<int> pi;
boost::unique_future<int> fi;
fi=pi.get_future();
@@ -196,6 +207,7 @@
void test_set_value_can_be_moved()
{
+ LOG;
// boost::promise<int> pi;
// boost::unique_future<int> fi;
// fi=pi.get_future();
@@ -213,6 +225,7 @@
void test_future_from_packaged_task_is_waiting()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
int i=0;
@@ -225,6 +238,7 @@
void test_invoking_a_packaged_task_populates_future()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
@@ -241,6 +255,7 @@
void test_invoking_a_packaged_task_twice_throws()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
pt();
@@ -258,6 +273,7 @@
void test_cannot_get_future_twice_from_task()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
pt.get_future();
try
@@ -273,6 +289,7 @@
void test_task_stores_exception_if_function_throws()
{
+ LOG;
boost::packaged_task<int> pt(throw_runtime_error);
boost::unique_future<int> fi=pt.get_future();
@@ -300,6 +317,7 @@
void test_void_promise()
{
+ LOG;
boost::promise<void> p;
boost::unique_future<void> f=p.get_future();
p.set_value();
@@ -312,6 +330,7 @@
void test_reference_promise()
{
+ LOG;
boost::promise<int&> p;
boost::unique_future<int&> f=p.get_future();
int i=42;
@@ -328,6 +347,7 @@
void test_task_returning_void()
{
+ LOG;
boost::packaged_task<void> pt(do_nothing);
boost::unique_future<void> fi=pt.get_future();
@@ -348,6 +368,7 @@
void test_task_returning_reference()
{
+ LOG;
boost::packaged_task<int&> pt(return_ref);
boost::unique_future<int&> fi=pt.get_future();
@@ -363,6 +384,7 @@
void test_shared_future()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
@@ -382,6 +404,7 @@
void test_copies_of_shared_future_become_ready_together()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
@@ -420,6 +443,7 @@
void test_shared_future_can_be_move_assigned_from_unique_future()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
@@ -435,6 +459,7 @@
void test_shared_future_void()
{
+ LOG;
boost::packaged_task<void> pt(do_nothing);
boost::unique_future<void> fi=pt.get_future();
@@ -452,6 +477,7 @@
void test_shared_future_ref()
{
+ LOG;
boost::promise<int&> p;
boost::shared_future<int&> f(p.get_future());
int i=42;
@@ -465,6 +491,7 @@
void test_can_get_a_second_future_from_a_moved_promise()
{
+ LOG;
boost::promise<int> pi;
boost::unique_future<int> fi=pi.get_future();
@@ -482,6 +509,7 @@
void test_can_get_a_second_future_from_a_moved_void_promise()
{
+ LOG;
boost::promise<void> pi;
boost::unique_future<void> fi=pi.get_future();
@@ -497,6 +525,7 @@
void test_unique_future_for_move_only_udt()
{
+ LOG;
boost::promise<X> pt;
boost::unique_future<X> fi=pt.get_future();
@@ -507,6 +536,7 @@
void test_unique_future_for_string()
{
+ LOG;
boost::promise<std::string> pt;
boost::unique_future<std::string> fi=pt.get_future();
@@ -557,6 +587,7 @@
void test_wait_callback()
{
+ LOG;
callback_called=0;
boost::promise<int> pi;
boost::unique_future<int> fi=pi.get_future();
@@ -571,6 +602,7 @@
void test_wait_callback_with_timed_wait()
{
+ LOG;
callback_called=0;
boost::promise<int> pi;
boost::unique_future<int> fi=pi.get_future();
@@ -594,6 +626,7 @@
void wait_callback_for_task(boost::packaged_task<int>& pt)
{
+ LOG;
boost::lock_guard<boost::mutex> lk(callback_mutex);
++callback_called;
try
@@ -608,6 +641,7 @@
void test_wait_callback_for_packaged_task()
{
+ LOG;
callback_called=0;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
@@ -622,6 +656,7 @@
void test_packaged_task_can_be_moved()
{
+ LOG;
boost::packaged_task<int> pt(make_int);
boost::unique_future<int> fi=pt.get_future();
@@ -649,6 +684,7 @@
void test_destroying_a_promise_stores_broken_promise()
{
+ LOG;
boost::unique_future<int> f;
{
@@ -668,6 +704,7 @@
void test_destroying_a_packaged_task_stores_broken_promise()
{
+ LOG;
boost::unique_future<int> f;
{
@@ -693,6 +730,7 @@
void test_wait_for_either_of_two_futures_1()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -710,6 +748,7 @@
void test_wait_for_either_of_two_futures_2()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -727,6 +766,7 @@
void test_wait_for_either_of_three_futures_1()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -747,6 +787,7 @@
void test_wait_for_either_of_three_futures_2()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -767,6 +808,7 @@
void test_wait_for_either_of_three_futures_3()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -787,6 +829,7 @@
void test_wait_for_either_of_four_futures_1()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -810,6 +853,7 @@
void test_wait_for_either_of_four_futures_2()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -833,6 +877,7 @@
void test_wait_for_either_of_four_futures_3()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -856,6 +901,7 @@
void test_wait_for_either_of_four_futures_4()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -879,6 +925,7 @@
void test_wait_for_either_of_five_futures_1()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -905,7 +952,8 @@
void test_wait_for_either_of_five_futures_2()
{
- boost::packaged_task<int> pt(make_int_slowly);
+ LOG;
+ boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
boost::unique_future<int> f2(pt2.get_future());
@@ -930,6 +978,7 @@
}
void test_wait_for_either_of_five_futures_3()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -955,6 +1004,7 @@
}
void test_wait_for_either_of_five_futures_4()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -980,6 +1030,7 @@
}
void test_wait_for_either_of_five_futures_5()
{
+ LOG;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> f1(pt.get_future());
boost::packaged_task<int> pt2(make_int_slowly);
@@ -1006,6 +1057,7 @@
void test_wait_for_either_invokes_callbacks()
{
+ LOG;
callback_called=0;
boost::packaged_task<int> pt(make_int_slowly);
boost::unique_future<int> fi=pt.get_future();
@@ -1022,6 +1074,7 @@
void test_wait_for_any_from_range()
{
+ LOG;
unsigned const count=10;
for(unsigned i=0;i<count;++i)
{
@@ -1056,6 +1109,7 @@
void test_wait_for_all_from_range()
{
+ LOG;
unsigned const count=10;
boost::unique_future<int> futures[count];
for(unsigned j=0;j<count;++j)
@@ -1075,6 +1129,7 @@
void test_wait_for_all_two_futures()
{
+ LOG;
unsigned const count=2;
boost::unique_future<int> futures[count];
for(unsigned j=0;j<count;++j)
@@ -1094,6 +1149,7 @@
void test_wait_for_all_three_futures()
{
+ LOG;
unsigned const count=3;
boost::unique_future<int> futures[count];
for(unsigned j=0;j<count;++j)
@@ -1113,6 +1169,7 @@
void test_wait_for_all_four_futures()
{
+ LOG;
unsigned const count=4;
boost::unique_future<int> futures[count];
for(unsigned j=0;j<count;++j)
@@ -1132,6 +1189,7 @@
void test_wait_for_all_five_futures()
{
+ LOG;
unsigned const count=5;
boost::unique_future<int> futures[count];
for(unsigned j=0;j<count;++j)
Modified: trunk/libs/thread/test/test_once.cpp
==============================================================================
--- trunk/libs/thread/test/test_once.cpp (original)
+++ trunk/libs/thread/test/test_once.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -8,6 +8,9 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/once.hpp>
+#define LOG \
+ if (false) {} else std::cout << std::endl << __FILE__ << "[" << __LINE__ << "]"
+
boost::once_flag flag=BOOST_ONCE_INIT;
int var_to_init=0;
boost::mutex m;
@@ -39,6 +42,8 @@
void test_call_once()
{
+ LOG;
+
unsigned const num_threads=20;
boost::thread_group group;
@@ -96,6 +101,8 @@
void test_call_once_arbitrary_functor()
{
+ LOG;
+
unsigned const num_threads=20;
boost::thread_group group;
@@ -155,6 +162,7 @@
void test_call_once_retried_on_exception()
{
+ LOG;
unsigned const num_threads=20;
boost::thread_group group;
Modified: trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/FArgs_pass.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -92,27 +92,36 @@
int main()
{
{
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
boost::thread t(f, 5, 5.5);
t.join();
BOOST_TEST(f_run == true);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
}
#ifndef BOOST_MSVC
f_run = false;
{
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
try
{
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
throw_one = 0;
boost::thread t(f, 5, 5.5);
BOOST_TEST(false);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
}
catch (...)
{
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
throw_one = 0xFFFF;
BOOST_TEST(!f_run);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
}
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
}
#endif
{
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
BOOST_TEST(G::n_alive == 0);
std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
BOOST_TEST(!G::op_run);
@@ -121,6 +130,7 @@
std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
BOOST_TEST(G::n_alive == 0);
BOOST_TEST(G::op_run);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << G::n_alive << std::endl;
}
return boost::report_errors();
Modified: trunk/libs/thread/test/threads/thread/constr/move_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/constr/move_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/constr/move_pass.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -55,6 +55,7 @@
void operator()(int i, double j)
{
BOOST_TEST(alive_ == 1);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << n_alive << std::endl;
BOOST_TEST(n_alive == 1);
BOOST_TEST(i == 5);
BOOST_TEST(j == 5.5);
Modified: trunk/libs/thread/test/threads/thread/members/join_pass.cpp
==============================================================================
--- trunk/libs/thread/test/threads/thread/members/join_pass.cpp (original)
+++ trunk/libs/thread/test/threads/thread/members/join_pass.cpp 2012-04-25 17:55:07 EDT (Wed, 25 Apr 2012)
@@ -52,6 +52,7 @@
void operator()()
{
BOOST_TEST(alive_ == 1);
+ std::cout << __FILE__ << ":" << __LINE__ <<" " << n_alive << std::endl;
BOOST_TEST(n_alive == 1);
op_run = true;
}
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