@@ -47,13 +47,13 @@ void simple_func(void *p) {
47
47
}
48
48
49
49
struct indirect {
50
- bool * touched ;
50
+ int * touched ;
51
51
uint8_t buffer [7 ];
52
52
};
53
53
54
54
void indirect_func (void * p ) {
55
55
struct indirect * i = (struct indirect * )p ;
56
- * i -> touched = true ;
56
+ ( * i -> touched ) ++ ;
57
57
}
58
58
59
59
struct timing {
@@ -142,7 +142,7 @@ void simple_post_test(void) {
142
142
int err = equeue_create (& q , 2048 );
143
143
test_assert (!err );
144
144
145
- bool touched = false;
145
+ int touched = false;
146
146
struct indirect * i = equeue_alloc (& q , sizeof (struct indirect ));
147
147
test_assert (i );
148
148
@@ -162,29 +162,53 @@ void destructor_test(void) {
162
162
int err = equeue_create (& q , 2048 );
163
163
test_assert (!err );
164
164
165
- bool touched = false ;
166
- struct indirect * i = equeue_alloc ( & q , sizeof ( struct indirect )) ;
167
- test_assert ( i ) ;
165
+ int touched ;
166
+ struct indirect * e ;
167
+ int ids [ 3 ] ;
168
168
169
- i -> touched = & touched ;
170
- equeue_event_dtor (i , indirect_func );
171
- int id = equeue_post (& q , pass_func , i );
172
- test_assert (id );
169
+ touched = 0 ;
170
+ for (int i = 0 ; i < 3 ; i ++ ) {
171
+ e = equeue_alloc (& q , sizeof (struct indirect ));
172
+ test_assert (e );
173
+
174
+ e -> touched = & touched ;
175
+ equeue_event_dtor (e , indirect_func );
176
+ int id = equeue_post (& q , pass_func , e );
177
+ test_assert (id );
178
+ }
173
179
174
180
equeue_dispatch (& q , 0 );
175
- test_assert (touched );
181
+ test_assert (touched == 3 );
176
182
177
- touched = false;
178
- i = equeue_alloc (& q , sizeof (struct indirect ));
179
- test_assert (i );
183
+ touched = 0 ;
184
+ for (int i = 0 ; i < 3 ; i ++ ) {
185
+ e = equeue_alloc (& q , sizeof (struct indirect ));
186
+ test_assert (e );
180
187
181
- i -> touched = & touched ;
182
- equeue_event_dtor (i , indirect_func );
183
- id = equeue_post (& q , pass_func , i );
184
- test_assert (id );
188
+ e -> touched = & touched ;
189
+ equeue_event_dtor (e , indirect_func );
190
+ ids [i ] = equeue_post (& q , pass_func , e );
191
+ test_assert (ids [i ]);
192
+ }
193
+
194
+ for (int i = 0 ; i < 3 ; i ++ ) {
195
+ equeue_cancel (& q , ids [i ]);
196
+ }
197
+ test_assert (touched == 3 );
198
+
199
+ touched = 0 ;
200
+ for (int i = 0 ; i < 3 ; i ++ ) {
201
+ e = equeue_alloc (& q , sizeof (struct indirect ));
202
+ test_assert (e );
203
+
204
+ e -> touched = & touched ;
205
+ equeue_event_dtor (e , indirect_func );
206
+ int id = equeue_post (& q , pass_func , e );
207
+ test_assert (id );
208
+ }
185
209
186
210
equeue_destroy (& q );
187
- test_assert (touched );
211
+ test_assert (touched == 3 );
188
212
}
189
213
190
214
void allocation_failure_test (void ) {
0 commit comments