|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59808 - in sandbox/stm/branches/vbe/libs/stm: example/tx test
From: vicente.botet_at_[hidden]
Date: 2010-02-21 08:33:37
Author: viboes
Date: 2010-02-21 08:33:37 EST (Sun, 21 Feb 2010)
New Revision: 59808
URL: http://svn.boost.org/trac/boost/changeset/59808
Log:
Boost.STM/vbe:
* Refactor and add some test.
Text files modified:
sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp | 52 ++++++----
sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp | 192 +++++++++++++++++++++++++++++++--------
sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 16 +-
3 files changed, 190 insertions(+), 70 deletions(-)
Modified: sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/example/tx/list.cpp 2010-02-21 08:33:37 EST (Sun, 21 Feb 2010)
@@ -177,7 +177,6 @@
}
bool check_size(std::size_t val) {
BOOST_STM_E_TRANSACTION(_) {
- //~ std::cout<< __FILE__<<"["<<__LINE__<<"]"<<std::endl;
BOOST_STM_E_RETURN(_, (l.size()==val));
} BOOST_STM_E_END_TRANSACTION(_)
return false;
@@ -190,10 +189,9 @@
return false;
}
-bool insert1() {
+bool insert(int val) {
//thread_initializer thi;
BOOST_STM_TRANSACTION(_) {
- int val = 10;
l.insert(val);
} BOOST_STM_RETRY
return check_size(1);
@@ -210,20 +208,21 @@
l.insert(2);
} BOOST_STM_RETRY
}
-
-void remove2() {
- //thread_initializer thi;
- BOOST_STM_TRANSACTION(_) {
- l.remove(2);
- } BOOST_STM_RETRY
-}
-
void insert3_th() {
thread_initializer thi;
BOOST_STM_OUTER_TRANSACTION(_) {
l.insert(3);
} BOOST_STM_RETRY
}
+
+bool remove(int val) {
+ //thread_initializer thi;
+ BOOST_STM_TRANSACTION(_) {
+ l.remove(val);
+ } BOOST_STM_RETRY
+ return true;
+}
+
bool n1() {
BOOST_STM_TRANSACTION(_) {
int val = 10;
@@ -258,15 +257,8 @@
return false;
}
-int test_all() {
-
- //create();
+bool test_par() {
bool fails=false;
- fails= fails || !n1();
- fails= fails || !n2();
- fails= fails || !n3();
- fails= fails || !check_size(0);
- //~ fails= fails || !insert1();
thread th1(insert1_th);
thread th2(insert2_th);
thread th3(insert2_th);
@@ -280,11 +272,31 @@
fails= fails || !check_lookup(2);
fails= fails || !check_lookup(3);
fails= fails || !check_size(3);
- remove2();
+ fails= fails || !remove(2);
fails= fails || !check_lookup(1);
fails= fails || check_lookup(2);
fails= fails || !check_lookup(3);
fails= fails || !check_size(2);
+
+ return !fails;
+}
+
+int test_all() {
+
+ //create();
+ bool fails=false;
+ fails= fails || !n1();
+ fails= fails || !n2();
+ fails= fails || !n3();
+ fails= fails || !check_size(0);
+ fails= fails || !insert(1);
+ fails= fails || !remove(1);
+ fails= fails || !check_size(0);
+ fails= fails || !remove(2);
+ fails= fails || !check_size(0);
+
+ fails= fails || !test_par();
+
return fails;
}
Modified: sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/example/tx/numeric.cpp 2010-02-21 08:33:37 EST (Sun, 21 Feb 2010)
@@ -26,6 +26,13 @@
stm::tx::int_t counter(0);
stm::tx::int_t counter2(0);
+void reset() {
+
+ BOOST_STM_OUTER_TRANSACTION(_) {
+ counter=0;
+ } BOOST_STM_RETRY
+}
+
void inc() {
stm::thread_initializer thi;
@@ -48,7 +55,6 @@
} BOOST_STM_RETRY
}
bool check(int val) {
- //thread_initializer thi;
BOOST_STM_TRANSACTION(_) {
BOOST_STM_TX_RETURN(_, (counter==val));
} BOOST_STM_RETRY
@@ -56,7 +62,7 @@
}
bool test_equal() {
- //thread_initializer thi;
+ reset();
BOOST_STM_TRANSACTION(_) {
counter=1;
counter2=2;
@@ -72,7 +78,7 @@
}
bool test_diff() {
- //thread_initializer thi;
+ reset();
BOOST_STM_TRANSACTION(_) {
counter=1;
counter2=2;
@@ -87,7 +93,7 @@
}
bool test_assign() {
- //thread_initializer thi;
+ reset();
for(int i=0; i<2;++i) {
BOOST_STM_TRANSACTION_IN_LOOP(_) {
counter=1;
@@ -97,14 +103,13 @@
} BOOST_STM_END_TRANSACTION_IN_LOOP(_)
}
BOOST_STM_TRANSACTION(_) {
- //assert((counter==1) && (counter2==1) && (counter==counter2));
BOOST_STM_TX_RETURN(_, (counter==1) && (counter2==1) && (counter==counter2)) ;
} BOOST_STM_RETRY
return false;
}
bool test_less() {
- //thread_initializer thi;
+ reset();
for(;;) {
BOOST_STM_TRANSACTION_IN_LOOP(_) {
counter=1;
@@ -119,8 +124,74 @@
return false;
}
-bool test_throw_e() {
- //thread_initializer thi;
+bool test_outer_throw() {
+ reset();
+ BOOST_STM_TRANSACTION(_) {
+ counter=0;
+ } BOOST_STM_END_TRANSACTION(_)
+
+ try{
+ BOOST_STM_TRANSACTION(_) {
+ counter=1;
+ throw 1;
+ } BOOST_STM_END_TRANSACTION(_)
+ } catch (...) {}
+
+ BOOST_STM_TRANSACTION(_) {
+ BOOST_STM_TX_RETURN(_, (counter==0));
+ } BOOST_STM_END_TRANSACTION(_)
+
+ return true;
+}
+bool test_outer_throw_e() {
+ reset();
+ BOOST_STM_E_TRANSACTION(_) {
+ counter=0;
+ } BOOST_STM_E_END_TRANSACTION(_)
+
+ try{
+ BOOST_STM_E_TRANSACTION(_) {
+ counter=1;
+ throw 1;
+ } BOOST_STM_E_END_TRANSACTION(_)
+ } catch (...) {}
+
+ BOOST_STM_E_TRANSACTION(_) {
+ BOOST_STM_E_RETURN(_, (counter==0));
+ } BOOST_STM_E_END_TRANSACTION(_)
+
+ return true;
+}
+
+
+
+bool test_inner_throw() {
+ reset();
+ BOOST_STM_E_TRANSACTION(_) {
+ counter=0; counter2=0;
+ } BOOST_STM_E_END_TRANSACTION(_)
+
+ try{
+ BOOST_STM_TRANSACTION(_) {
+ counter=1;
+ BOOST_STM_TRANSACTION(__) {
+ throw 1;
+ } BOOST_STM_END_TRANSACTION(_)
+ catch (...){throw;}
+ counter=3;
+ } BOOST_STM_END_TRANSACTION(_)
+ } catch (...) {}
+ bool res=false;
+ BOOST_STM_TRANSACTION(_) {
+ //~ res=(counter==0) && (counter2==0);
+ BOOST_STM_TX_RETURN(_, (counter==0) && (counter2==0));
+ } BOOST_STM_END_TRANSACTION(_)
+
+ return res;
+}
+
+bool test_inner_throw_e() {
+ reset();
BOOST_STM_E_TRANSACTION(_) {
counter=0; counter2=0;
} BOOST_STM_E_END_TRANSACTION(_)
@@ -128,33 +199,46 @@
try{
BOOST_STM_E_TRANSACTION(_) {
counter=1;
- // BUG /bin/sh: line 4: 4428 Aborted (core dumped) "../../../bin.v2/libs/stm/test/numeric.test/gcc-3.4.4/debug/threading-multi/numeric.exe" > "../../../bin.v2/libs/stm/test/numeric.test/gcc-3.4.4/debug/threading-multi/numeric.output" 2>&1
- //~ BOOST_STM_E_TRANSACTION(_) {
- //~ counter=2;
+ BOOST_STM_E_TRANSACTION(_) {
+ counter=2;
throw 1;
- //~ } BOOST_STM_E_END_TRANSACTION(_)
- counter2=3;
+ } BOOST_STM_E_END_TRANSACTION(_)
+ counter=3;
} BOOST_STM_E_END_TRANSACTION(_)
} catch (...) {}
BOOST_STM_E_TRANSACTION(_) {
- BOOST_STM_E_RETURN(_, (counter==0) && (counter2==0));
+ BOOST_STM_E_RETURN(_, (counter==0) );
} BOOST_STM_E_END_TRANSACTION(_)
return false;
}
+bool test_nested_e() {
+ reset();
+ BOOST_STM_E_TRANSACTION(_) {
+ counter=1;
+ BOOST_STM_E_TRANSACTION(_) {
+ counter2=2;
+ } BOOST_STM_E_END_TRANSACTION(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
+
+ BOOST_STM_E_TRANSACTION(_) {
+ BOOST_STM_E_RETURN(_, (counter==1) && (counter2==2));
+ } BOOST_STM_E_END_TRANSACTION(_)
+
+ return false;
+}
bool test_assign_e() {
- //thread_initializer thi;
- for(int i=0; i<2;++i)
- {
- BOOST_STM_E_TRANSACTION_IN_LOOP(_) {
- counter=1;
- counter2=counter;
- continue;
- counter2=3;
- } BOOST_STM_E_END_TRANSACTION_IN_LOOP(_)
+ reset();
+ for(int i=0; i<2;++i) {
+ BOOST_STM_E_TRANSACTION_IN_LOOP(_) {
+ counter=1;
+ counter2=counter;
+ continue;
+ counter2=3;
+ } BOOST_STM_E_END_TRANSACTION_IN_LOOP(_)
}
BOOST_STM_E_TRANSACTION(_) {
BOOST_STM_E_RETURN(_, (counter==1) && (counter2==1) && (counter==counter2)) ;
@@ -164,49 +248,45 @@
}
bool test_less_e() {
- //thread_initializer thi;
- for(;;)
- {
- BOOST_STM_E_TRANSACTION_IN_LOOP(_)
- {
- counter=1;
- counter2=2;
- break;
- counter2=0;
- } BOOST_STM_E_END_TRANSACTION_IN_LOOP(_)
+ reset();
+ for(;;) {
+ BOOST_STM_E_TRANSACTION_IN_LOOP(_) {
+ counter=1;
+ counter2=2;
+ break;
+ counter2=0;
+ } BOOST_STM_E_END_TRANSACTION_IN_LOOP(_)
}
- BOOST_STM_E_TRANSACTION(_)
- {
+ BOOST_STM_E_TRANSACTION(_) {
BOOST_STM_E_RETURN(_, counter<counter2);
} BOOST_STM_E_END_TRANSACTION(_)
return false;
}
bool test_le() {
- //thread_initializer thi;
+ reset();
BOOST_STM_TRANSACTION(_) {
counter=1;
counter2=1;
} BOOST_STM_RETRY
BOOST_STM_TRANSACTION(_) {
- //assert(counter<=counter2);
BOOST_STM_TX_RETURN(_, (counter<=counter2)) ;
} BOOST_STM_RETRY
return false;
}
bool test_const(stm::tx::numeric<int> const& c) {
- //thread_initializer thi;
+ reset();
BOOST_STM_TRANSACTION(_) {
counter2=c;
} BOOST_STM_RETRY
BOOST_STM_E_TRANSACTION(_) {
- //assert(c==counter2);
BOOST_STM_E_RETURN(_, c==counter2) ;
} BOOST_STM_E_END_TRANSACTION(_)
return false;
}
bool test_par() {
+ reset();
thread th1(inc);
thread th2(decr);
thread th3(inc1);
@@ -220,19 +300,47 @@
return check(2);
}
+bool test_twice() {
+ BOOST_STM_TRANSACTION(_) {
+ BOOST_STM_TRANSACTION(_) {
+ } BOOST_STM_END_TRANSACTION(_)
+ } BOOST_STM_END_TRANSACTION(_)
+
+ return true;
+}
+
+bool test_twice_e() {
+ BOOST_STM_E_TRANSACTION(_) {
+ BOOST_STM_E_TRANSACTION(_) {
+ } BOOST_STM_E_END_TRANSACTION(_)
+ } BOOST_STM_E_END_TRANSACTION(_)
+
+ return true;
+}
+
int test_all() {
int fails=0;
- fails += !test_par();
+ //~ fails += !test_twice();
+ //~ fails += !test_twice();
+ //~ fails += !test_twice_e();
+ //~ fails += !test_twice_e();
+ fails += !test_inner_throw_e();
+ fails += !test_outer_throw();
+ fails += !test_outer_throw_e();
+
fails += !test_equal();
fails += !test_diff();
fails += !test_assign();
- fails += !test_less();
fails += !test_assign_e();
+ fails += !test_less();
fails += !test_less_e();
- fails += !test_throw_e();
+ fails += !test_nested_e();
fails += !test_le();
fails += !test_const(counter);
+
+ fails += !test_par();
+
return fails;
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 2010-02-21 08:33:37 EST (Sun, 21 Feb 2010)
@@ -275,17 +275,21 @@
########### fails sometimes
#assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 52
[ run stm : -bench linkedlist -def -threads 4 -inserts 100 : : : linkedlist_def_t4_i100 ]
- ;
- alias failures
- :
+ ########### fails sometimes
+ [ run stm : -bench tx_linear_lock -def -threads 2 -inserts 100 -latm tx : : : tx_linear_lock_def_tx_t2_i100 ]
+
########### fails sometimes
[ run stm : -bench ll -dir -threads 4 -inserts 100 -latm tx : : : ll_dir_t4_tx_i100 ]
########### fails sometimes 19:00 091107
[ run stm : -bench ll -dir -threads 2 -inserts 100 -latm tx : : : ll_dir_t2_tx_i100 ]
- ########### fails sometimes
+ ;
+
+ alias failures
+ :
+ ########### fails often
[ run stm : -bench ll -def -threads 2 -inserts 100 -latm tx : : : ll_def_tx_t2_i100 ]
########### fails with CHECK all-modes
@@ -305,15 +309,11 @@
# assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
[ run stm : -bench ll -def -threads 2 -inserts 100 -latm full : : : ll_def_full_t2_i100 ]
-
########### fails all-modes
# assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
# 19469 [sig] tx_linear_lock_def_t2 3768 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
[ run stm : -bench tx_linear_lock -def -threads 2 -inserts 100 -latm full : : : tx_linear_lock_def_full_t2_i100 ]
- ########### fails
- [ run stm : -bench tx_linear_lock -def -threads 2 -inserts 100 -latm tx : : : tx_linear_lock_def_tx_t2_i100 ]
-
########### fails all-modes
# /bin/sh: line 4: 3660 Segmentation fault (core dumped) "bin/isolated_composed_int_lock_def_t2.test/gcc-3.4.4/debug/threading-multi/isolated_composed_int_lock_def_t2.exe" > "bin/isolated_composed_int_lock_def_t2.test/gcc-3.4.4/debug/threading-multi/isolated_composed_int_lock_def_t2.output" 2>&1
# assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
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