Boost logo

Boost-Commit :

From: gennadiy.rozental_at_[hidden]
Date: 2008-07-24 23:59:19


Author: rogeeff
Date: 2008-07-24 23:59:18 EDT (Thu, 24 Jul 2008)
New Revision: 47791
URL: http://svn.boost.org/trac/boost/changeset/47791

Log:
datesync_access_test added

Added:
   trunk/libs/test/test/sync_access_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/test/test/Jamfile.v2 | 6 ++++--
   1 files changed, 4 insertions(+), 2 deletions(-)

Modified: trunk/libs/test/test/Jamfile.v2
==============================================================================
--- trunk/libs/test/test/Jamfile.v2 (original)
+++ trunk/libs/test/test/Jamfile.v2 2008-07-24 23:59:18 EDT (Thu, 24 Jul 2008)
@@ -6,11 +6,11 @@
 # See http://www.boost.org/libs/test for the library home page.
 
 
-rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source_files * )
+rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source_files * : extra-libs ? )
 {
    source_files ?= $(test-name).cpp ;
 
- return [ $(test-rule) $(source_files) ../build//$(lib-name)
+ return [ $(test-rule) $(source_files) ../build//$(lib-name) $(extra-libs)
             : #args
             : $(pattern_file)
             : #<stlport-iostream>on
@@ -54,6 +54,8 @@
           [ test-btl-lib run : token_iterator_test : boost_unit_test_framework ]
           [ test-btl-lib run : boost_check_equal_str : boost_unit_test_framework ]
           [ test-btl-lib run : test_tree_management_test : boost_unit_test_framework ]
+ [ test-btl-lib run : sync_access_test : boost_unit_test_framework/<link>static : : : /boost/thread//boost_thread ]
+
             ;
 
 # A target that runs all the tests

Added: trunk/libs/test/test/sync_access_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/test/test/sync_access_test.cpp 2008-07-24 23:59:18 EDT (Thu, 24 Jul 2008)
@@ -0,0 +1,36 @@
+#define BOOST_TEST_MODULE sync_access_test
+#include <boost/test/unit_test.hpp>
+
+#include <boost/thread.hpp>
+#include <boost/thread/barrier.hpp>
+#include <boost/bind.hpp>
+#include <boost/ref.hpp>
+
+
+using namespace boost;
+namespace ut = boost::unit_test;
+
+static boost::mutex m;
+
+/// thread execution function
+static void thread_function(boost::barrier& b)
+{
+ b.wait(); /// wait until memory barrier allows the execution
+ boost::mutex::scoped_lock lock(m); /// lock mutex
+ BOOST_CHECK_EQUAL(1,0); /// produce the fault
+}
+
+/// test function which creates threads
+BOOST_AUTO_TEST_CASE( test_multiple_assertion_faults )
+{
+ boost::thread_group tg; // thread group to manage all threads
+ boost::barrier b(100); // memory barrier, which should block all threads
+ // until all 100 threads were created
+
+ for(size_t i=0; i<100; ++i)
+ tg.create_thread(boost::bind(thread_function, ref(b))); /// create a thread and pass it the barrier
+
+ tg.join_all();
+}
+
+// EOF


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