Skip to content

Commit 3bf3f5a

Browse files
committed
Add more traces to test failures to have more information on CI
1 parent 37e334e commit 3bf3f5a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

test/robust_mutex_test.hpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ int robust_mutex_test(int argc, char *argv[])
6363
std::string s(argv[0]); s += " child ";
6464
s += get_process_id_name();
6565
std::cout << "... launching child" << std::endl;
66-
if(0 != std::system(s.c_str()))
66+
if(0 != std::system(s.c_str())){
67+
std::cout << "'std::system " << s.c_str() << "FAILED!" << std::endl;
6768
return 1;
69+
}
6870

6971
//Wait until child locks the mutexes and dies
7072
spin_wait swait;
@@ -79,8 +81,10 @@ int robust_mutex_test(int argc, char *argv[])
7981
//Done, now try to lock it to see if robust
8082
//mutex recovery works
8183
instance[0].lock();
82-
if(!instance[0].previous_owner_dead())
84+
if(!instance[0].previous_owner_dead()){
85+
std::cout << "instance[0].previous_owner_dead() FAILED!" << std::endl;
8386
return 1;
87+
}
8488
instance[0].consistent();
8589
instance[0].unlock();
8690
//Since it's consistent, locking is possible again
@@ -94,8 +98,10 @@ int robust_mutex_test(int argc, char *argv[])
9498
//Done, now try to lock it to see if robust
9599
//mutex recovery works
96100
instance[1].lock();
97-
if(!instance[1].previous_owner_dead())
101+
if(!instance[1].previous_owner_dead()){
102+
std::cout << "instance[1].previous_owner_dead() FAILED!" << std::endl;
98103
return 1;
104+
}
99105
//Unlock a recovered mutex without putting it into
100106
//into consistent state marks mutex as unusable.
101107
instance[1].unlock();
@@ -108,6 +114,7 @@ int robust_mutex_test(int argc, char *argv[])
108114
exception_thrown = true;
109115
} BOOST_INTERPROCESS_CATCH_END
110116
if(!exception_thrown){
117+
std::cout << "instance[1].lock() did NOT throw an exception!" << std::endl;
111118
return 1;
112119
}
113120
}
@@ -118,8 +125,10 @@ int robust_mutex_test(int argc, char *argv[])
118125
//Done, now try to lock it to see if robust
119126
//mutex recovery works
120127
instance[2].lock();
121-
if(!instance[2].previous_owner_dead())
128+
if(!instance[2].previous_owner_dead()){
129+
std::cout << "instance[2].previous_owner_dead() FAILED" << std::endl;
122130
return 1;
131+
}
123132
//Unlock a recovered mutex without putting it into
124133
//into consistent state marks mutex as unusable.
125134
instance[2].unlock();
@@ -132,6 +141,7 @@ int robust_mutex_test(int argc, char *argv[])
132141
exception_thrown = true;
133142
} BOOST_INTERPROCESS_CATCH_END
134143
if(!exception_thrown){
144+
std::cout << "instance[2].lock() did not throw an Exception!" << std::endl;
135145
return 1;
136146
}
137147
}
@@ -150,8 +160,10 @@ int robust_mutex_test(int argc, char *argv[])
150160
//Lock, flag and die
151161
bool try_lock_res = instance[0].try_lock() && instance[1].try_lock();
152162
assert(try_lock_res);
153-
if(!try_lock_res)
163+
if(!try_lock_res){
164+
std::cout << "'instance[0].try_lock() && instance[1].try_lock()' FAILED!" << std::endl;
154165
return 1;
166+
}
155167

156168
bool *go_ahead2 = segment.construct<bool>("go ahead2")(false);
157169
assert(go_ahead2);
@@ -174,6 +186,7 @@ int robust_mutex_test(int argc, char *argv[])
174186
//mutex recovery works
175187
instance[2].lock();
176188
if(!instance[2].previous_owner_dead()){
189+
std::cout << "instance[2].previous_owner_dead() FAILED!" << std::endl;
177190
return 1;
178191
}
179192
*go_ahead = true;
@@ -187,6 +200,7 @@ int robust_mutex_test(int argc, char *argv[])
187200
bool try_lock_res = instance[2].try_lock();
188201
assert(try_lock_res);
189202
if(!try_lock_res){
203+
std::cout << "instance[2].try_lock() FAILED!" << std::endl;
190204
return 1;
191205
}
192206
*go_ahead2 = true;

0 commit comments

Comments
 (0)