Boost C++ Libraries: Ticket #6004: boost thread unit test module bug on Microsoft Visual Studio debug mode https://svn.boost.org/trac10/ticket/6004 <p> 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 <a class="ext-link" href="http://www.gilgil.net/10328"><span class="icon">​</span>http://www.gilgil.net/10328</a> . Thank you. </p> <hr /> <p> #define BOOST_TEST_MODULE <a class="missing wiki">MyUnitTest</a> #include &lt;boost/test/unit_test.hpp&gt; #include &lt;boost/thread.hpp&gt; </p> <p> BOOST_AUTO_TEST_SUITE ( <a class="missing wiki">MySuite</a> ); </p> <blockquote> <p> void func() { </p> <blockquote> <p> BOOST_CHECK ( true ); </p> </blockquote> <p> } </p> </blockquote> <blockquote> <p> BOOST_AUTO_TEST_CASE( <a class="missing wiki">ThreadTest</a> ) { </p> <blockquote> <p> static const int THREAD_CNT = 1000; boost::thread* t[THREAD_CNT]; for (int i = 0; i &lt; THREAD_CNT; i++) { </p> <blockquote> <p> t[i] = new boost::thread(func); </p> </blockquote> <p> } for (int i = 0; i &lt; THREAD_CNT; i++) { </p> <blockquote> <p> t[i]-&gt;join(); </p> </blockquote> <p> } for (int i = 0; i &lt; THREAD_CNT; i++) { </p> <blockquote> <p> delete t[i]; </p> </blockquote> <p> } </p> </blockquote> <p> } </p> </blockquote> <p> BOOST_AUTO_TEST_SUITE_END (); <em> <a class="missing wiki">MySuite</a> </em></p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6004 Trac 1.4.3 gilgil1973@… Mon, 10 Oct 2011 20:02:31 GMT attachment set https://svn.boost.org/trac10/ticket/6004 https://svn.boost.org/trac10/ticket/6004 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">thread_unit_test.zip</span> </li> </ul> <p> boost thread unit test sample code </p> Ticket anonymous Mon, 14 Nov 2011 20:16:19 GMT <link>https://svn.boost.org/trac10/ticket/6004#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6004#comment:1</guid> <description> <p> I've figured out BOOST_CHECK is not thread-safe. :( </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 02 Dec 2011 21:41:24 GMT</pubDate> <title>owner, status changed; cc set https://svn.boost.org/trac10/ticket/6004#comment:2 https://svn.boost.org/trac10/ticket/6004#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> What exactly the problem is? Is this related to a bad behavior on Boost.Thread? If not, you should assign it to Boost.Test. </p> Ticket anonymous Sat, 03 Dec 2011 07:29:16 GMT <link>https://svn.boost.org/trac10/ticket/6004#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6004#comment:3</guid> <description> <p> I didn't know that BOOST_CHECK is not thread safe until a few months ago. </p> <p> void func(){ </p> <blockquote> <p> BOOST_CHECK ( true ); </p> </blockquote> <p> } </p> <p> This code is executed in many other threads, and not so good code. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 07 Dec 2011 00:06:26 GMT</pubDate> <title>component changed https://svn.boost.org/trac10/ticket/6004#comment:4 https://svn.boost.org/trac10/ticket/6004#comment:4 <ul> <li><strong>component</strong> <span class="trac-field-old">thread</span> → <span class="trac-field-new">test</span> </li> </ul> <p> Please close this ticket if you consider Boost.Test BOOST_CHECK shouldn't be thread-safe. </p> Ticket gilgil1973@… Wed, 07 Dec 2011 02:04:09 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6004#comment:5 https://svn.boost.org/trac10/ticket/6004#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket