Hello, is Boost.Test framework thread safe in regards to the following use case: I would like to start multiple threads with some testing tasks. These threads will call boost TestTools functions (BOOST_CHECK... etc.). Is this scenario supported? With Kind Regards, Ovanes Markarian
Ovanes Markarian
Hello,is Boost.Test framework thread safe in regards to the following use
case:I would like to start multiple threads with some testing tasks. These threads will call boost TestTools functions (BOOST_CHECK... etc.). Is this scenario supported? No. You will have ti serialize access to the UTF. The simplest way is just use wrapper macro. gennadiy
Thanks for the answer!
I read some post (mainly: you and William Kempf) about Program Execution
Monitor and its MT support. This was in 2002/2003 did you manage to solve
these issues?
Many thanks,
Ovanes
On Jan 10, 2008 7:47 PM, Gennadiy Rozental
Ovanes Markarian
writes: Hello,is Boost.Test framework thread safe in regards to the following
use case:I would like to start multiple threads with some testing tasks. These threads will call boost TestTools functions (BOOST_CHECK... etc.). Is this scenario supported?
No. You will have ti serialize access to the UTF. The simplest way is just use wrapper macro.
gennadiy
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
If I correclty understood you I should do smth. similar like this:
boost::mutex m;
struct thread_safety_test
{
static void thread_function(boost::barrier& b)
{
b.wait();
boost::mutex::scoped_lock lock(m);
BOOST_CHECK_EQUAL(1,0);
}
void test_multiple_assertion_faults()
{
boost::thread_group tg;
boost::barrier b(100);
for(size_t i=0; i<100; ++i)
{
tg.create_thread(boost::bind(thread_function, ref(b)));
}
}
};
But unfortunately this does not work. May be I miss smth. here.
With Kind Regards,
Ovanes
On Jan 10, 2008 8:01 PM, Ovanes Markarian
Thanks for the answer!
I read some post (mainly: you and William Kempf) about Program Execution Monitor and its MT support. This was in 2002/2003 did you manage to solve these issues?
Many thanks, Ovanes
On Jan 10, 2008 7:47 PM, Gennadiy Rozental
wrote: Ovanes Markarian
writes: Hello,is Boost.Test framework thread safe in regards to the following
use case:I would like to start multiple threads with some testing tasks. These threads will call boost TestTools functions (BOOST_CHECK... etc.). Is this scenario supported?
No. You will have ti serialize access to the UTF. The simplest way is just use wrapper macro.
gennadiy
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ovanes Markarian
struct thread_safety_test { static void thread_function(boost::barrier& b) { b.wait();
Can't comment in these. I never used this class. | boost::mutex::scoped_lock lock(m); | BOOST_CHECK_EQUAL(1,0); | } | | void test_multiple_assertion_faults() | { | boost::thread_group tg; | boost::barrier b(100); | | for(size_t i=0; i<100; ++i) | { | tg.create_thread(boost::bind(thread_function, ref(b))); | } | } | }; | But unfortunately this does not work. May be I miss smth. here. I am not an expert in MT, but what exactly is the problem? Do you run is from inside the test case? Gennadiy
On Jan 10, 2008 8:48 PM, Gennadiy Rozental
Ovanes Markarian
writes: struct thread_safety_test { static void thread_function(boost::barrier& b) { b.wait();
Can't comment in these. I never used this class.
| boost::mutex::scoped_lock lock(m); | BOOST_CHECK_EQUAL(1,0); | } | | void test_multiple_assertion_faults() | { | boost::thread_group tg; | boost::barrier b(100); | | for(size_t i=0; i<100; ++i) | { | tg.create_thread(boost::bind(thread_function, ref(b))); | } | } | }; | But unfortunately this does not work. May be I miss smth. here.
I am not an expert in MT, but what exactly is the problem?
Do you run is from inside the test case?
Yes. The class specified is passed to the BOOST_CLASS_TEST_CASE( multiple_assertion_faults, thread_safety_test)
The idea of my code is: Create 100 threads and wait until all of them are created. (barrier is used for that).
After all threads were created lock the mutex and produce the assertion fault. In MSVC 7.1 this code crashes after the second call to BOOST_CHECK_EQUAL.
I thought you would be aware of this issue.
Many thanks for your help! Ovanes
Ovanes Markarian
The idea of my code is: Create 100 threads and wait until all of them are created. (barrier is used for that). After all threads were created lock the mutex and produce the assertion fault. In MSVC 7.1 this code crashes after the second call to BOOST_CHECK_EQUAL.
Can you post complete compilable example? Will I need library for boost threads?
Gennadiy,
many thanks for your help. The attached file will reproduce the behavior. It
depends on boost bind, boost reference_wrapper, boost thread and boost test.
Many thanks,
Ovanes
On Jan 11, 2008 7:48 AM, Gennadiy Rozental
Ovanes Markarian
writes: The idea of my code is: Create 100 threads and wait until all of them are created. (barrier is used for that). After all threads were created lock the mutex and produce the assertion fault. In MSVC 7.1 this code crashes after the second call to BOOST_CHECK_EQUAL.
Can you post complete compilable example? Will I need library for boost threads?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ovanes Markarian
Thanks for the answer!I read some post (mainly: you and William Kempf) about
Program Execution Monitor and its MT support. This was in 2002/2003 did you manage to solve these issues?Many thanks,Ovanes Boost.Test should be reentrant (unless I slipped again - there is no real unit tests for this in my own test suite).
participants (2)
-
Gennadiy Rozental
-
Ovanes Markarian