Opened 11 years ago
Closed 11 years ago
#6004 closed Bugs (fixed)
boost thread unit test module bug on Microsoft Visual Studio debug mode
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | test |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | thread BOOST_CHECK bug | Cc: | viboes |
Description
Hi, glad to see you. I've figured out the bug of unit test on MSVC debug mode. if I use BOOST_CHECK in working thread, it does not work correctly. You can download source codes and video clip at http://www.gilgil.net/10328 . Thank you.
#define BOOST_TEST_MODULE MyUnitTest #include <boost/test/unit_test.hpp> #include <boost/thread.hpp>
BOOST_AUTO_TEST_SUITE ( MySuite );
void func() {
BOOST_CHECK ( true );
}
BOOST_AUTO_TEST_CASE( ThreadTest ) {
static const int THREAD_CNT = 1000; boost::thread* t[THREAD_CNT]; for (int i = 0; i < THREAD_CNT; i++) {
t[i] = new boost::thread(func);
} for (int i = 0; i < THREAD_CNT; i++) {
t[i]->join();
} for (int i = 0; i < THREAD_CNT; i++) {
delete t[i];
}
}
BOOST_AUTO_TEST_SUITE_END (); MySuite
Attachments (1)
Change History (6)
by , 11 years ago
Attachment: | thread_unit_test.zip added |
---|
comment:2 by , 11 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
What exactly the problem is? Is this related to a bad behavior on Boost.Thread? If not, you should assign it to Boost.Test.
comment:3 by , 11 years ago
I didn't know that BOOST_CHECK is not thread safe until a few months ago.
void func(){
BOOST_CHECK ( true );
}
This code is executed in many other threads, and not so good code.
comment:4 by , 11 years ago
Component: | thread → test |
---|
Please close this ticket if you consider Boost.Test BOOST_CHECK shouldn't be thread-safe.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
boost thread unit test sample code