GCC Code Coverage Report


Directory: ./
File: tests/support/tests_executable.cpp
Date: 2022-06-30 06:29:57
Exec Total Coverage
Lines: 154 168 91.7%
Branches: 185 332 55.7%

Line Branch Exec Source
1 /**
2 * @file tests_executable.cpp
3 * @author Maximilien Naveau (maximilien.naveau@gmail.com)
4 * @license License BSD-3-Clause
5 * @copyright Copyright (c) 2019, New York University and Max Planck
6 * Gesellschaft.
7 * @date 2019-05-22
8 *
9 * @brief Used to generate or read data from the shared memory.
10 */
11 #include <iostream>
12
13 #include "shared_memory/condition_variable.hpp"
14 #include "shared_memory/demos/four_int_values.hpp"
15 #include "shared_memory/exchange_manager_consumer.hpp"
16 #include "shared_memory/lock.hpp"
17 #include "shared_memory/locked_condition_variable.hpp"
18 #include "shared_memory/mutex.hpp"
19 #include "shared_memory/shared_memory.hpp"
20 #include "shared_memory/tests/tests.h"
21
22 26 int main(int, char *argv[])
23 {
24 26 int command = atoi(argv[1]);
25
26
1/2
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
26 shared_memory::set_verbose(false);
27
28
1/2
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
52 std::string segment = shared_memory_test::segment_id;
29
1/2
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
52 std::string object = shared_memory_test::object_id;
30
31
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_double)
32 {
33
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, shared_memory_test::test_double);
34 }
35
36
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_int)
37 {
38
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, shared_memory_test::test_int);
39 }
40
41
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_float)
42 {
43
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, shared_memory_test::test_float);
44 }
45
46
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_string)
47 {
48
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, shared_memory_test::test_string);
49 }
50
51
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 23 times.
26 if (command == shared_memory_test::Actions::set_vector)
52 {
53 6 std::vector<double> v;
54
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
55 {
56
1/2
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
12 v.push_back(shared_memory_test::test_array[i]);
57 }
58
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 shared_memory::set(segment, object, v);
59 }
60
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if (command == shared_memory_test::Actions::set_eigen_vector)
62 {
63 Eigen::VectorXd v(shared_memory_test::test_array_size);
64 for (int i = 0; i < v.size(); i++)
65 {
66 v(i) = shared_memory_test::test_array[i];
67 }
68 shared_memory::set(segment, object, v);
69 }
70
71
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_int_double_map)
72 {
73 2 std::map<int, double> m;
74
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m[shared_memory_test::map_int_keys1] = shared_memory_test::map_value_1;
75
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m[shared_memory_test::map_int_keys2] = shared_memory_test::map_value_2;
76
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, m);
77 }
78
79
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_string_double_map)
80 {
81 2 std::map<std::string, double> m;
82
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m[shared_memory_test::map_string_keys1] =
83 shared_memory_test::map_value_1;
84
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 m[shared_memory_test::map_string_keys2] =
85 shared_memory_test::map_value_2;
86
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, m);
87 }
88
89
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_double_array)
90 {
91
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment,
92 object,
93 shared_memory_test::test_array,
94 shared_memory_test::test_array_size);
95 }
96
97
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_string_vector_double_map)
98 {
99 2 std::map<std::string, std::vector<double>> m;
100
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 std::vector<double> v1(2);
101 1 v1[0] = shared_memory_test::map_value_1;
102 1 v1[1] = shared_memory_test::map_value_2;
103
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 std::vector<double> v2(2);
104 1 v2[0] = shared_memory_test::map_value_2;
105 1 v2[1] = shared_memory_test::map_value_1;
106
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 m[shared_memory_test::map_string_keys1] = v1;
107
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 m[shared_memory_test::map_string_keys2] = v2;
108
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, m);
109 }
110
111
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::set_string_vector_eigen_map)
112 {
113 2 std::map<std::string, Eigen::VectorXd> m;
114
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Eigen::VectorXd v1(2);
115
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 v1[0] = shared_memory_test::map_value_1;
116
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 v1[1] = shared_memory_test::map_value_2;
117
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 Eigen::VectorXd v2(2);
118
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 v2[0] = shared_memory_test::map_value_2;
119
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 v2[1] = shared_memory_test::map_value_1;
120
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 m[shared_memory_test::map_string_keys1] = v1;
121
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 m[shared_memory_test::map_string_keys2] = v2;
122
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(segment, object, m);
123 }
124
125
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::concurrent_1)
126 {
127
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 std::stringstream cond_var_name;
128
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 cond_var_name << shared_memory_test::segment_id << "_"
129
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 << shared_memory_test::concurrent_1;
130
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 shared_memory::LockedConditionVariable cond_var(cond_var_name.str());
131
132
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(shared_memory_test::segment_id,
133 shared_memory_test::concurrent_proc1_ready,
134 true);
135
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.lock_scope();
136
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.wait();
137
138 // Send shared_memory_test::concurrent_value_1
139 double d[shared_memory_test::test_array_size];
140
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
141 {
142 4 d[i] = shared_memory_test::concurrent_value_1;
143 }
144
2/2
✓ Branch 0 taken 5000 times.
✓ Branch 1 taken 1 times.
5001 for (int i = 0; i < 5000; i++)
145 {
146
1/2
✓ Branch 1 taken 5000 times.
✗ Branch 2 not taken.
5000 shared_memory::set(
147 segment, object, d, shared_memory_test::test_array_size);
148
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4999 times.
5000 if (i == 0)
149 {
150
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.unlock_scope();
151
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.notify_all();
152 }
153
1/2
✓ Branch 1 taken 5000 times.
✗ Branch 2 not taken.
5000 usleep(50);
154 }
155 // Send stop
156
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
157 {
158 4 d[i] = shared_memory_test::concurrent_stop_value;
159 }
160
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(
161 segment, object, d, shared_memory_test::test_array_size);
162 }
163
164
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::concurrent_2)
165 {
166
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 std::stringstream cond_var_name;
167
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 cond_var_name << shared_memory_test::segment_id << "_"
168
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 << shared_memory_test::concurrent_2;
169
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 shared_memory::LockedConditionVariable cond_var(cond_var_name.str());
170
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(shared_memory_test::segment_id,
171 shared_memory_test::concurrent_proc2_ready,
172 true);
173
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.lock_scope();
174
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.wait();
175
176 double d[shared_memory_test::test_array_size];
177
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
178 {
179 4 d[i] = shared_memory_test::concurrent_value_2;
180 }
181
2/2
✓ Branch 0 taken 5000 times.
✓ Branch 1 taken 1 times.
5001 for (int i = 0; i < 5000; i++)
182 {
183
1/2
✓ Branch 1 taken 5000 times.
✗ Branch 2 not taken.
5000 shared_memory::set(
184 segment, object, d, shared_memory_test::test_array_size);
185
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4999 times.
5000 if (i == 0)
186 {
187
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.unlock_scope();
188
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.notify_all();
189 }
190
1/2
✓ Branch 1 taken 5000 times.
✗ Branch 2 not taken.
5000 usleep(50);
191 }
192
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
193 {
194 4 d[i] = shared_memory_test::concurrent_stop_value;
195 }
196
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(
197 segment, object, d, shared_memory_test::test_array_size);
198 }
199
200
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::locked_condition_variable)
201 {
202 // create a data vector
203 double d[shared_memory_test::test_array_size];
204
205
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Get the cond var." << std::endl;
206 shared_memory::LockedConditionVariable cond_var(
207
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 shared_memory_test::segment_id);
208
209 // from here all variables are protected
210
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Lock scope." << std::endl;
211
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.lock_scope();
212
213
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Set ShM." << std::endl;
214 // fill d with a starting value
215
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
216 {
217 4 d[i] = shared_memory_test::concurrent_value_2;
218 }
219 // write d in the shared memory
220
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(
221 segment, object, d, shared_memory_test::test_array_size);
222
223 // we wait that the value are read
224
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: notify." << std::endl;
225
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.notify_all();
226
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: wait." << std::endl;
227
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.wait();
228
229
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Set ShM." << std::endl;
230
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for (unsigned int i = 0; i < shared_memory_test::test_array_size; i++)
231 {
232 4 d[i] = shared_memory_test::concurrent_stop_value;
233 }
234
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 shared_memory::set(
235 segment, object, d, shared_memory_test::test_array_size);
236
237 // we wake the clients and finish
238
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Notify." << std::endl;
239
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.notify_all();
240
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Wait." << std::endl;
241
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.wait();
242
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Unlock scope." << std::endl;
243
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 cond_var.unlock_scope();
244 }
245
246
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
26 if (command == shared_memory_test::Actions::condition_variable)
247 {
248
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "TESTS_EXECUTABLE: Get mutex and cond var." << std::endl;
249
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 std::string segment_mutex(shared_memory_test::segment_mutex_id);
250
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 shared_memory::Mutex mutex(shared_memory_test::segment_mutex_id, false);
251 shared_memory::ConditionVariable condition(
252
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 shared_memory_test::segment_cv_id, false);
253
254 double v[shared_memory_test::test_array_size];
255 1 int value = 2;
256
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 for (int i = 0; i < 10; i++)
257 {
258
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 std::cout << "TESTS_EXECUTABLE: Lock." << std::endl;
259
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 shared_memory::Lock lock(mutex);
260
261
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 std::cout << "TESTS_EXECUTABLE: Set ShM." << std::endl;
262
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10 times.
50 for (unsigned int i = 0; i < shared_memory_test::test_array_size;
263 i++)
264 {
265 40 v[i] = value;
266 }
267
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 shared_memory::set(shared_memory_test::segment_id,
268 shared_memory_test::object_id,
269 v,
270 shared_memory_test::test_array_size);
271
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 std::cout << "TESTS_EXECUTABLE: Notify." << std::endl;
272
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 condition.notify_one();
273
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 std::cout << "TESTS_EXECUTABLE: Wait." << std::endl;
274
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 condition.wait(lock);
275 }
276
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 condition.notify_one();
277 }
278
279
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16 times.
26 if (command == shared_memory_test::Actions::exchange_manager)
280 {
281 10 bool leading = false;
282 10 bool autolock = true;
283
284 shared_memory::Exchange_manager_consumer<shared_memory::Four_int_values,
285 DATA_EXCHANGE_QUEUE_SIZE>
286
3/6
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
20 consumer(segment, object, leading, autolock);
287
288 10 int nb_consumed = 0;
289
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 shared_memory::Four_int_values fiv;
290 10 int max_wait = 1000000; // 1 second
291 10 int waited = 0;
292
293
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 10 times.
2042 while (nb_consumed < shared_memory_test::nb_to_consume)
294 {
295
2/4
✓ Branch 1 taken 1016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1016 times.
✗ Branch 4 not taken.
1016 if (consumer.ready_to_consume())
296 {
297
1/2
✓ Branch 1 taken 1016 times.
✗ Branch 2 not taken.
1016 bool received = consumer.consume(fiv);
298
2/2
✓ Branch 0 taken 1000 times.
✓ Branch 1 taken 16 times.
1016 if (received)
299 {
300 1000 waited = 0;
301 1000 nb_consumed += 1;
302 }
303 else
304 {
305
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 usleep(100);
306 16 waited += 100;
307 }
308 }
309 else
310 {
311 usleep(100);
312 waited += 100;
313 }
314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016 times.
1016 if (waited >= max_wait)
315 {
316 // waiting for too long, exiting
317 shared_memory::set(
318 shared_memory_test::exchange_manager_segment_id,
319 shared_memory_test::exchange_manager_object_id,
320 true);
321 break;
322 }
323
324 // letting a chance for the producer to get the lock
325
1/2
✓ Branch 1 taken 1016 times.
✗ Branch 2 not taken.
1016 usleep(10);
326 }
327
328 // making sure the producer receives all the feedbacks
329 10 waited = 0;
330
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
10 while (!consumer.purge_feedbacks())
331 {
332 usleep(100);
333 waited += 100;
334 if (waited >= max_wait)
335 {
336 // waiting for too long, exiting
337 shared_memory::set(
338 shared_memory_test::exchange_manager_segment_id,
339 shared_memory_test::exchange_manager_object_id,
340 true);
341 break;
342 }
343
344 // letting a chance for the producer to get the lock
345 usleep(10);
346 }
347 }
348
349 26 return 0;
350
2/4
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
78 }
351