testfifo.c 12.8 KB
Newer Older
Sebastien Decugis's avatar
Sebastien Decugis committed
1
2
/*********************************************************************************************************
* Software License Agreement (BSD License)                                                               *
Sebastien Decugis's avatar
Sebastien Decugis committed
3
* Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
Sebastien Decugis's avatar
Sebastien Decugis committed
4
*													 *
5
* Copyright (c) 2011, WIDE Project and NICT								 *
Sebastien Decugis's avatar
Sebastien Decugis committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
* All rights reserved.											 *
* 													 *
* Redistribution and use of this software in source and binary forms, with or without modification, are  *
* permitted provided that the following conditions are met:						 *
* 													 *
* * Redistributions of source code must retain the above 						 *
*   copyright notice, this list of conditions and the 							 *
*   following disclaimer.										 *
*    													 *
* * Redistributions in binary form must reproduce the above 						 *
*   copyright notice, this list of conditions and the 							 *
*   following disclaimer in the documentation and/or other						 *
*   materials provided with the distribution.								 *
* 													 *
* * Neither the name of the WIDE Project or NICT nor the 						 *
*   names of its contributors may be used to endorse or 						 *
*   promote products derived from this software without 						 *
*   specific prior written permission of WIDE Project and 						 *
*   NICT.												 *
* 													 *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
*********************************************************************************************************/

#include "tests.h"
37
#include <unistd.h>
38
#include <limits.h>
Sebastien Decugis's avatar
Sebastien Decugis committed
39

40
/* Structure for testing threshold function */
Sebastien Decugis's avatar
Sebastien Decugis committed
41
static struct thrh_test {
Sebastien Decugis's avatar
Sebastien Decugis committed
42
	struct fifo *   queue; /* pointer to the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
43
44
45
46
47
	int		h_calls; /* number of calls of h_cb */
	int		l_calls; /* number of calls of l_cb */
} thrh_td;

/* Callbacks for threasholds test */
Sebastien Decugis's avatar
Sebastien Decugis committed
48
void thrh_cb_h(struct fifo *queue, void **data)
Sebastien Decugis's avatar
Sebastien Decugis committed
49
50
51
52
53
54
55
56
57
58
59
60
{
	if (thrh_td.h_calls == thrh_td.l_calls) {
		CHECK( NULL, *data );
		*data = &thrh_td;
	} else {
		CHECK( *data, &thrh_td );
	}
	CHECK( queue, thrh_td.queue );
	
	/* Update the count */
	thrh_td.h_calls ++;
}
Sebastien Decugis's avatar
Sebastien Decugis committed
61
void thrh_cb_l(struct fifo *queue, void **data)
Sebastien Decugis's avatar
Sebastien Decugis committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
	CHECK( 1, data ? 1 : 0 );
	CHECK( *data, &thrh_td );

	/* Check the queue parameter is correct */
	CHECK( queue, thrh_td.queue );
	
	/* Update the count */
	thrh_td.l_calls ++;
	/* Cleanup the data ptr if needed */
	if (thrh_td.l_calls == thrh_td.h_calls)
		*data = NULL;
	/* done */
}


/* Structure that is passed to the test function */
struct test_data {
Sebastien Decugis's avatar
Sebastien Decugis committed
80
	struct fifo     * queue; /* pointer to the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
	pthread_barrier_t * bar;   /* if not NULL, barrier to synchronize before getting messages */
	struct timespec   * ts;	   /* if not NULL, use a timedget instead of a get */
	int		    nbr;   /* number of messages to retrieve from the queue */
};

/* The test function, to be threaded */
static void * test_fct(void * data)
{
	int ret = 0, i;
	struct msg * msg = NULL;
	struct test_data * td = (struct test_data *) data;
	
	if (td->bar != NULL) {
		ret = pthread_barrier_wait(td->bar);
		if (ret != PTHREAD_BARRIER_SERIAL_THREAD) {
			CHECK( 0, ret);
		} else {
			CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret); /* just for the traces */
		}
	}
	
	for (i=0; i< td->nbr; i++) {
		if (td->ts != NULL) {
Sebastien Decugis's avatar
Sebastien Decugis committed
104
			CHECK( 0, fd_fifo_timedget(td->queue, &msg, td->ts) );
Sebastien Decugis's avatar
Sebastien Decugis committed
105
		} else {
Sebastien Decugis's avatar
Sebastien Decugis committed
106
			CHECK( 0, fd_fifo_get(td->queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
		}
	}
	
	return NULL;
}


/* Main test routine */
int main(int argc, char *argv[])
{
	struct timespec ts;
	
	struct msg * msg1 = NULL;
	struct msg * msg2 = NULL;
	struct msg * msg3 = NULL;
	
	/* First, initialize the daemon modules */
	INIT_FD();
	
	/* Prolog: create the messages */
	{
		struct dict_object * acr_model = NULL;
		struct dict_object * cer_model = NULL;
		struct dict_object * dwr_model = NULL;

132
133
134
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", 			&acr_model, ENOENT ) );
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", 	&cer_model, ENOENT ) );
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request",		&dwr_model, ENOENT ) );
Sebastien Decugis's avatar
Sebastien Decugis committed
135
136
137
138
139
140
141
		CHECK( 0, fd_msg_new ( acr_model, 0, &msg1 ) );
		CHECK( 0, fd_msg_new ( cer_model, 0, &msg2 ) );
		CHECK( 0, fd_msg_new ( dwr_model, 0, &msg3 ) );
	}
	
	/* Basic operation */
	{
Sebastien Decugis's avatar
Sebastien Decugis committed
142
		struct fifo * queue = NULL;
Sebastien Decugis's avatar
Sebastien Decugis committed
143
144
145
146
		int count;
		struct msg * msg  = NULL;
		
		/* Create the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
147
		CHECK( 0, fd_fifo_new(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
148
149
		
		/* Check the count is 0 */
Sebastien Decugis's avatar
Sebastien Decugis committed
150
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
151
152
153
154
		CHECK( 0, count);
		
		/* Now enqueue */
		msg = msg1;
Sebastien Decugis's avatar
Sebastien Decugis committed
155
		CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
156
		msg = msg2;
Sebastien Decugis's avatar
Sebastien Decugis committed
157
		CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
158
		msg = msg3;
Sebastien Decugis's avatar
Sebastien Decugis committed
159
		CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
160
161
		
		/* Check the count is 3 */
Sebastien Decugis's avatar
Sebastien Decugis committed
162
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
163
164
		CHECK( 3, count);
		
Sebastien Decugis's avatar
Sebastien Decugis committed
165
166
		/* Retrieve the first message using fd_fifo_get */
		CHECK( 0, fd_fifo_get(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
167
		CHECK( msg1, msg);
Sebastien Decugis's avatar
Sebastien Decugis committed
168
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
169
170
		CHECK( 2, count);
		
Sebastien Decugis's avatar
Sebastien Decugis committed
171
		/* Retrieve the second message using fd_fifo_timedget */
Sebastien Decugis's avatar
Sebastien Decugis committed
172
173
		CHECK(0, clock_gettime(CLOCK_REALTIME, &ts));
		ts.tv_sec += 1; /* Set the timeout to 1 second */
Sebastien Decugis's avatar
Sebastien Decugis committed
174
		CHECK( 0, fd_fifo_timedget(queue, &msg, &ts) );
Sebastien Decugis's avatar
Sebastien Decugis committed
175
		CHECK( msg2, msg);
Sebastien Decugis's avatar
Sebastien Decugis committed
176
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
177
178
179
		CHECK( 1, count);
		
		/* Retrieve the third message using meq_tryget */
Sebastien Decugis's avatar
Sebastien Decugis committed
180
		CHECK( 0, fd_fifo_tryget(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
181
		CHECK( msg3, msg);
Sebastien Decugis's avatar
Sebastien Decugis committed
182
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
183
184
185
		CHECK( 0, count);
		
		/* Check that another meq_tryget does not block */
Sebastien Decugis's avatar
Sebastien Decugis committed
186
187
		CHECK( EWOULDBLOCK, fd_fifo_tryget(queue, &msg) );
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
188
189
190
		CHECK( 0, count);
		
		/* We're done for basic tests */
Sebastien Decugis's avatar
Sebastien Decugis committed
191
		CHECK( 0, fd_fifo_del(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
192
193
194
195
196
197
	}
	
	/* Test robustness, ensure no messages are lost */
	{
#define NBR_MSG		200
#define NBR_THREADS	60
Sebastien Decugis's avatar
Sebastien Decugis committed
198
		struct fifo  		*queue = NULL;
Sebastien Decugis's avatar
Sebastien Decugis committed
199
200
201
202
203
204
205
206
		pthread_barrier_t	 bar;
		struct test_data	 td_1;
		struct test_data	 td_2;
		struct msg   		*msgs[NBR_MSG * NBR_THREADS * 2], *msg;
		pthread_t  		 thr [NBR_THREADS * 2];
		struct dict_object	*dwr_model = NULL;
		int 			 count;
		int			 i;
207
		int			 nbr_threads;
208
209
210
#ifdef _POSIX_THREAD_THREADS_MAX
		nbr_threads = _POSIX_THREAD_THREADS_MAX;
#else /* _POSIX_THREAD_THREADS_MAX */
211
		nbr_threads = sysconf(_SC_THREAD_THREADS_MAX);
212
213
#endif /* _POSIX_THREAD_THREADS_MAX */
		if ((nbr_threads <= 0) || (nbr_threads > NBR_THREADS * 2)) {
214
215
			nbr_threads = NBR_THREADS;
		} else {
216
			TRACE_DEBUG(INFO, "Local limit on number of threads: %d", nbr_threads);
217
218
219
220
221
			/* The local limit is bellow NBR_THREADS */
			nbr_threads = (nbr_threads / 2) - 1;
			/* Ensure we create at least a few threads! */
			CHECK( 1, nbr_threads >= 10 ? 1 : 0 );
		}
Sebastien Decugis's avatar
Sebastien Decugis committed
222
223
		
		/* Create the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
224
		CHECK( 0, fd_fifo_new(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
225
226
		
		/* Create the barrier */
227
		CHECK( 0, pthread_barrier_init(&bar, NULL, nbr_threads * 2 + 1) );
Sebastien Decugis's avatar
Sebastien Decugis committed
228
229
230
		
		/* Initialize the ts */
		CHECK(0, clock_gettime(CLOCK_REALTIME, &ts));
231
		ts.tv_sec += 20; /* Set the timeout to 20 second */
Sebastien Decugis's avatar
Sebastien Decugis committed
232
233
		
		/* Create the messages */
234
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request",		&dwr_model, ENOENT ) );
235
		for (i = 0; i < NBR_MSG * nbr_threads * 2; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
236
237
238
239
240
241
242
243
244
245
246
247
248
249
			CHECK( 0, fd_msg_new ( dwr_model, 0, &msgs[i] ) );
		}
		
		/* Initialize the test data structures */
		td_1.queue = queue;
		td_1.bar = &bar;
		td_1.ts  = &ts;
		td_1.nbr = NBR_MSG;
		td_2.queue = queue;
		td_2.bar = &bar;
		td_2.ts  = NULL;
		td_2.nbr = NBR_MSG;
		
		/* Create the threads */
250
		for (i=0; i < nbr_threads * 2; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
251
252
253
254
255
256
257
258
259
260
261
262
263
264
			CHECK( 0, pthread_create( &thr[i], NULL, test_fct, (i & 1) ? &td_1 : &td_2 ) );
		}
		
		/* Synchronize everyone */
		{
			int ret = pthread_barrier_wait(&bar);
			if (ret != PTHREAD_BARRIER_SERIAL_THREAD) {
				CHECK( 0, ret);
			} else {
				CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret); /* for trace only */
			}
		}
		
		/* Now post all the messages */
265
		for (i=0; i < NBR_MSG * nbr_threads * 2; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
266
			msg = msgs[i];
Sebastien Decugis's avatar
Sebastien Decugis committed
267
			CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
268
269
270
		}
		
		/* Join all threads. This blocks if messages are lost... */
271
		for (i=0; i < nbr_threads * 2; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
272
273
274
275
			CHECK( 0, pthread_join( thr[i], NULL ) );
		}
		
		/* Check the count of the queue is back to 0 */
Sebastien Decugis's avatar
Sebastien Decugis committed
276
		CHECK( 0, fd_fifo_length(queue, &count) );
Sebastien Decugis's avatar
Sebastien Decugis committed
277
278
279
		CHECK( 0, count);
		
		/* Destroy this queue and the messages */
Sebastien Decugis's avatar
Sebastien Decugis committed
280
		CHECK( 0, fd_fifo_del(&queue) );
281
		for (i=0; i < NBR_MSG * nbr_threads * 2; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
282
283
284
285
286
287
			CHECK( 0, fd_msg_free(  msgs[i] ) );
		}
	}
	
	/* Test thread cancelation */
	{
Sebastien Decugis's avatar
Sebastien Decugis committed
288
		struct fifo      	*queue = NULL;
Sebastien Decugis's avatar
Sebastien Decugis committed
289
290
291
292
293
		pthread_barrier_t	 bar;
		struct test_data	 td;
		pthread_t		 th;
		
		/* Create the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
294
		CHECK( 0, fd_fifo_new(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
295
296
297
298
299
300
		
		/* Create the barrier */
		CHECK( 0, pthread_barrier_init(&bar, NULL, 2) );
		
		/* Initialize the ts */
		CHECK(0, clock_gettime(CLOCK_REALTIME, &ts));
301
		ts.tv_sec += 10; /* Set the timeout to 10 second */
Sebastien Decugis's avatar
Sebastien Decugis committed
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
		
		/* Initialize the test data structures */
		td.queue = queue;
		td.bar = &bar;
		td.ts  = &ts;
		td.nbr = 1;
		
		/* Create the thread */
		CHECK( 0, pthread_create( &th, NULL, test_fct, &td ) );
		
		/* Wait for the thread to be running */
		{
			int ret = pthread_barrier_wait(&bar);
			if (ret != PTHREAD_BARRIER_SERIAL_THREAD) {
				CHECK( 0, ret);
			} else {
				CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret );
			}
		}
		
		/* Now cancel the thread */
		CHECK( 0, pthread_cancel( th ) );
		
		/* Join it */
		CHECK( 0, pthread_join( th, NULL ) );
		
		/* Do the same with the other function */
		td.ts  = NULL;
		
		/* Create the thread */
		CHECK( 0, pthread_create( &th, NULL, test_fct, &td ) );
		
		/* Wait for the thread to be running */
		{
			int ret = pthread_barrier_wait(&bar);
			if (ret != PTHREAD_BARRIER_SERIAL_THREAD) {
				CHECK( 0, ret);
			} else {
				CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret );
			}
		}
		
		/* Now cancel the thread */
		CHECK( 0, pthread_cancel( th ) );
		
		/* Join it */
		CHECK( 0, pthread_join( th, NULL ) );
		
		/* Destroy the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
351
		CHECK( 0, fd_fifo_del(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
352
353
354
355
	}
	
	/* Test the threashold function */
	{
Sebastien Decugis's avatar
Sebastien Decugis committed
356
		struct fifo * queue = NULL;
Sebastien Decugis's avatar
Sebastien Decugis committed
357
358
359
360
		int i;
		struct msg * msg  = NULL;
		
		/* Create the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
361
		CHECK( 0, fd_fifo_new(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
362
363
364
365
366
367
		
		/* Prepare the test data */
		memset(&thrh_td, 0, sizeof(thrh_td));
		thrh_td.queue = queue;
		
		/* Set the thresholds for the queue */
Sebastien Decugis's avatar
Sebastien Decugis committed
368
		CHECK( 0, fd_fifo_setthrhd ( queue, NULL, 6, thrh_cb_h, 4, thrh_cb_l ) );
Sebastien Decugis's avatar
Sebastien Decugis committed
369
370
371
372
		
		/* Post 5 messages, no cb must be called. */
		for (i=0; i<5; i++) {
			msg = msg1;
Sebastien Decugis's avatar
Sebastien Decugis committed
373
			CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
374
375
376
377
378
379
		} /* 5 msg in queue */
		CHECK( 0, thrh_td.h_calls );
		CHECK( 0, thrh_td.l_calls );
		
		/* Get all these messages, and check again */
		for (i=0; i<5; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
380
			CHECK( 0, fd_fifo_get(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
381
382
383
384
385
386
387
		} /* 0 msg in queue */
		CHECK( 0, thrh_td.h_calls );
		CHECK( 0, thrh_td.l_calls );
		
		/* Now, post 6 messages, the high threashold */
		for (i=0; i<6; i++) {
			msg = msg1;
Sebastien Decugis's avatar
Sebastien Decugis committed
388
			CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
389
390
391
392
393
394
		} /* 6 msg in queue */
		CHECK( 1, thrh_td.h_calls );
		CHECK( 0, thrh_td.l_calls );
		
		/* Remove 2 messages, to reach the low threshold */
		for (i=0; i<2; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
395
			CHECK( 0, fd_fifo_get(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
396
397
398
399
400
401
402
		} /* 4 msg in queue */
		CHECK( 1, thrh_td.h_calls );
		CHECK( 1, thrh_td.l_calls );
		
		/* Come again at the high threshold */
		for (i=0; i<2; i++) {
			msg = msg1;
Sebastien Decugis's avatar
Sebastien Decugis committed
403
			CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
404
405
406
407
408
409
410
		} /* 6 msg in queue */
		CHECK( 2, thrh_td.h_calls );
		CHECK( 1, thrh_td.l_calls );
		
		/* Suppose the queue continues to grow */
		for (i=0; i<6; i++) {
			msg = msg1;
Sebastien Decugis's avatar
Sebastien Decugis committed
411
			CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
412
413
414
415
416
		} /* 12 msg in queue */
		CHECK( 3, thrh_td.h_calls );
		CHECK( 1, thrh_td.l_calls );
		for (i=0; i<5; i++) {
			msg = msg1;
Sebastien Decugis's avatar
Sebastien Decugis committed
417
			CHECK( 0, fd_fifo_post(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
418
419
420
421
422
423
		} /* 17 msg in queue */
		CHECK( 3, thrh_td.h_calls );
		CHECK( 1, thrh_td.l_calls );
		
		/* Now the queue goes back to 0 messages */
		for (i=0; i<17; i++) {
Sebastien Decugis's avatar
Sebastien Decugis committed
424
			CHECK( 0, fd_fifo_get(queue, &msg) );
Sebastien Decugis's avatar
Sebastien Decugis committed
425
426
427
428
429
		} /* 0 msg in queue */
		CHECK( 3, thrh_td.h_calls );
		CHECK( 3, thrh_td.l_calls );
		
		/* We're done for this test */
Sebastien Decugis's avatar
Sebastien Decugis committed
430
		CHECK( 0, fd_fifo_del(&queue) );
Sebastien Decugis's avatar
Sebastien Decugis committed
431
432
433
434
435
436
437
438
439
440
	}
	
	/* Delete the messages */
	CHECK( 0, fd_msg_free( msg1 ) );
	CHECK( 0, fd_msg_free( msg2 ) );
	CHECK( 0, fd_msg_free( msg3 ) );

	/* That's all for the tests yet */
	PASSTEST();
}