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: gilgil1973@… 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)

thread_unit_test.zip (2.5 KB ) - added by gilgil1973@… 11 years ago.
boost thread unit test sample code

Download all attachments as: .zip

Change History (6)

by gilgil1973@…, 11 years ago

Attachment: thread_unit_test.zip added

boost thread unit test sample code

comment:1 by anonymous, 11 years ago

I've figured out BOOST_CHECK is not thread-safe. :(

comment:2 by viboes, 11 years ago

Cc: viboes added
Owner: changed from Anthony Williams to viboes
Status: newassigned

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 anonymous, 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 viboes, 11 years ago

Component: threadtest

Please close this ticket if you consider Boost.Test BOOST_CHECK shouldn't be thread-safe.

comment:5 by gilgil1973@…, 11 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.