Mercurial > hg > freeDiameter
annotate tests/testfifo.c @ 862:226f5957186a 1.1.5-rc2
Updated nightly tests to include a pass in Debug configuration
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sun, 21 Oct 2012 23:21:43 +0200 |
parents | a5a82d50c25e |
children | 901526bc034c |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
740
4a9f08d6b6ba
Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
716
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
0 | 4 * * |
662
2e94ef0515d7
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
658
diff
changeset
|
5 * Copyright (c) 2011, WIDE Project and NICT * |
0 | 6 * All rights reserved. * |
7 * * | |
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
9 * permitted provided that the following conditions are met: * | |
10 * * | |
11 * * Redistributions of source code must retain the above * | |
12 * copyright notice, this list of conditions and the * | |
13 * following disclaimer. * | |
14 * * | |
15 * * Redistributions in binary form must reproduce the above * | |
16 * copyright notice, this list of conditions and the * | |
17 * following disclaimer in the documentation and/or other * | |
18 * materials provided with the distribution. * | |
19 * * | |
20 * * Neither the name of the WIDE Project or NICT nor the * | |
21 * names of its contributors may be used to endorse or * | |
22 * promote products derived from this software without * | |
23 * specific prior written permission of WIDE Project and * | |
24 * NICT. * | |
25 * * | |
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
34 *********************************************************************************************************/ | |
35 | |
36 #include "tests.h" | |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
37 #include <unistd.h> |
716
4784f2cf325f
Fix missing include for limit (should fix test for OpenSUSE)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
38 #include <limits.h> |
0 | 39 |
1
bafb831ba688
Fix names to proper case for freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
40 /* Structure for testing threshold function */ |
0 | 41 static struct thrh_test { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
42 struct fifo * queue; /* pointer to the queue */ |
0 | 43 int h_calls; /* number of calls of h_cb */ |
44 int l_calls; /* number of calls of l_cb */ | |
45 } thrh_td; | |
46 | |
47 /* Callbacks for threasholds test */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
48 void thrh_cb_h(struct fifo *queue, void **data) |
0 | 49 { |
50 if (thrh_td.h_calls == thrh_td.l_calls) { | |
51 CHECK( NULL, *data ); | |
52 *data = &thrh_td; | |
53 } else { | |
54 CHECK( *data, &thrh_td ); | |
55 } | |
56 CHECK( queue, thrh_td.queue ); | |
57 | |
58 /* Update the count */ | |
59 thrh_td.h_calls ++; | |
60 } | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
61 void thrh_cb_l(struct fifo *queue, void **data) |
0 | 62 { |
63 CHECK( 1, data ? 1 : 0 ); | |
64 CHECK( *data, &thrh_td ); | |
65 | |
66 /* Check the queue parameter is correct */ | |
67 CHECK( queue, thrh_td.queue ); | |
68 | |
69 /* Update the count */ | |
70 thrh_td.l_calls ++; | |
71 /* Cleanup the data ptr if needed */ | |
72 if (thrh_td.l_calls == thrh_td.h_calls) | |
73 *data = NULL; | |
74 /* done */ | |
75 } | |
76 | |
77 | |
78 /* Structure that is passed to the test function */ | |
79 struct test_data { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
80 struct fifo * queue; /* pointer to the queue */ |
0 | 81 pthread_barrier_t * bar; /* if not NULL, barrier to synchronize before getting messages */ |
82 struct timespec * ts; /* if not NULL, use a timedget instead of a get */ | |
83 int nbr; /* number of messages to retrieve from the queue */ | |
84 }; | |
85 | |
86 /* The test function, to be threaded */ | |
87 static void * test_fct(void * data) | |
88 { | |
89 int ret = 0, i; | |
90 struct msg * msg = NULL; | |
91 struct test_data * td = (struct test_data *) data; | |
92 | |
93 if (td->bar != NULL) { | |
94 ret = pthread_barrier_wait(td->bar); | |
95 if (ret != PTHREAD_BARRIER_SERIAL_THREAD) { | |
96 CHECK( 0, ret); | |
97 } else { | |
98 CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret); /* just for the traces */ | |
99 } | |
100 } | |
101 | |
102 for (i=0; i< td->nbr; i++) { | |
103 if (td->ts != NULL) { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
104 CHECK( 0, fd_fifo_timedget(td->queue, &msg, td->ts) ); |
0 | 105 } else { |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
106 CHECK( 0, fd_fifo_get(td->queue, &msg) ); |
0 | 107 } |
108 } | |
109 | |
110 return NULL; | |
111 } | |
112 | |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
113 /* The test function, to be threaded */ |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
114 static int iter = 0; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
115 static void * test_fct2(void * data) |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
116 { |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
117 int i; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
118 int * item; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
119 struct test_data * td = (struct test_data *) data; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
120 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
121 for (i=0; i< td->nbr; i++) { |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
122 item = malloc(sizeof(int)); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
123 CHECK( 1, item ? 1 : 0 ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
124 *item = i; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
125 CHECK( 0, fd_fifo_post(td->queue, &item) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
126 iter++; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
127 } |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
128 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
129 return NULL; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
130 } |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
131 |
0 | 132 |
133 /* Main test routine */ | |
134 int main(int argc, char *argv[]) | |
135 { | |
136 struct timespec ts; | |
137 | |
138 struct msg * msg1 = NULL; | |
139 struct msg * msg2 = NULL; | |
140 struct msg * msg3 = NULL; | |
141 | |
142 /* First, initialize the daemon modules */ | |
143 INIT_FD(); | |
144 | |
145 /* Prolog: create the messages */ | |
146 { | |
147 struct dict_object * acr_model = NULL; | |
148 struct dict_object * cer_model = NULL; | |
149 struct dict_object * dwr_model = NULL; | |
150 | |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
151 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
152 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) ); |
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
153 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) ); |
0 | 154 CHECK( 0, fd_msg_new ( acr_model, 0, &msg1 ) ); |
155 CHECK( 0, fd_msg_new ( cer_model, 0, &msg2 ) ); | |
156 CHECK( 0, fd_msg_new ( dwr_model, 0, &msg3 ) ); | |
157 } | |
158 | |
159 /* Basic operation */ | |
160 { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
161 struct fifo * queue = NULL; |
0 | 162 int count; |
163 struct msg * msg = NULL; | |
164 | |
165 /* Create the queue */ | |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
166 CHECK( 0, fd_fifo_new(&queue, 0) ); |
0 | 167 |
168 /* Check the count is 0 */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
169 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 170 CHECK( 0, count); |
171 | |
172 /* Now enqueue */ | |
173 msg = msg1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
174 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 175 msg = msg2; |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
176 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 177 msg = msg3; |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
178 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 179 |
180 /* Check the count is 3 */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
181 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 182 CHECK( 3, count); |
183 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
184 /* Retrieve the first message using fd_fifo_get */ |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
185 CHECK( 0, fd_fifo_get(queue, &msg) ); |
0 | 186 CHECK( msg1, msg); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
187 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 188 CHECK( 2, count); |
189 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
190 /* Retrieve the second message using fd_fifo_timedget */ |
0 | 191 CHECK(0, clock_gettime(CLOCK_REALTIME, &ts)); |
192 ts.tv_sec += 1; /* Set the timeout to 1 second */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
193 CHECK( 0, fd_fifo_timedget(queue, &msg, &ts) ); |
0 | 194 CHECK( msg2, msg); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
195 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 196 CHECK( 1, count); |
197 | |
198 /* Retrieve the third message using meq_tryget */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
199 CHECK( 0, fd_fifo_tryget(queue, &msg) ); |
0 | 200 CHECK( msg3, msg); |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
201 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 202 CHECK( 0, count); |
203 | |
204 /* Check that another meq_tryget does not block */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
205 CHECK( EWOULDBLOCK, fd_fifo_tryget(queue, &msg) ); |
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
206 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 207 CHECK( 0, count); |
208 | |
751
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
209 /* Check the timedget actually timesout */ |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
210 CHECK(0, clock_gettime(CLOCK_REALTIME, &ts)); |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
211 ts.tv_nsec += 1000000; /* 1 millisecond */ |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
212 if (ts.tv_nsec >= 1000000000L) { |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
213 ts.tv_nsec -= 1000000000L; |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
214 ts.tv_sec += 1; |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
215 } |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
216 CHECK( ETIMEDOUT, fd_fifo_timedget(queue, &msg, &ts) ); |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
217 CHECK( 0, fd_fifo_length(queue, &count) ); |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
218 CHECK( 0, count); |
c7d9c5477d2f
Add a test for timeout on fifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
740
diff
changeset
|
219 |
0 | 220 /* We're done for basic tests */ |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
221 CHECK( 0, fd_fifo_del(&queue) ); |
0 | 222 } |
223 | |
224 /* Test robustness, ensure no messages are lost */ | |
225 { | |
226 #define NBR_MSG 200 | |
227 #define NBR_THREADS 60 | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
228 struct fifo *queue = NULL; |
0 | 229 pthread_barrier_t bar; |
230 struct test_data td_1; | |
231 struct test_data td_2; | |
232 struct msg *msgs[NBR_MSG * NBR_THREADS * 2], *msg; | |
233 pthread_t thr [NBR_THREADS * 2]; | |
234 struct dict_object *dwr_model = NULL; | |
235 int count; | |
236 int i; | |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
237 int nbr_threads; |
619
45a63d6448ea
Fix wrong operator in testfifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
615
diff
changeset
|
238 #ifdef _POSIX_THREAD_THREADS_MAX |
45a63d6448ea
Fix wrong operator in testfifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
615
diff
changeset
|
239 nbr_threads = _POSIX_THREAD_THREADS_MAX; |
45a63d6448ea
Fix wrong operator in testfifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
615
diff
changeset
|
240 #else /* _POSIX_THREAD_THREADS_MAX */ |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
241 nbr_threads = sysconf(_SC_THREAD_THREADS_MAX); |
619
45a63d6448ea
Fix wrong operator in testfifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
615
diff
changeset
|
242 #endif /* _POSIX_THREAD_THREADS_MAX */ |
45a63d6448ea
Fix wrong operator in testfifo
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
615
diff
changeset
|
243 if ((nbr_threads <= 0) || (nbr_threads > NBR_THREADS * 2)) { |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
244 nbr_threads = NBR_THREADS; |
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
245 } else { |
716
4784f2cf325f
Fix missing include for limit (should fix test for OpenSUSE)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
246 TRACE_DEBUG(INFO, "Local limit on number of threads: %d", nbr_threads); |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
247 /* The local limit is bellow NBR_THREADS */ |
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
248 nbr_threads = (nbr_threads / 2) - 1; |
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
249 /* Ensure we create at least a few threads! */ |
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
250 CHECK( 1, nbr_threads >= 10 ? 1 : 0 ); |
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
251 } |
0 | 252 |
253 /* Create the queue */ | |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
254 CHECK( 0, fd_fifo_new(&queue, 0) ); |
0 | 255 |
256 /* Create the barrier */ | |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
257 CHECK( 0, pthread_barrier_init(&bar, NULL, nbr_threads * 2 + 1) ); |
0 | 258 |
259 /* Initialize the ts */ | |
260 CHECK(0, clock_gettime(CLOCK_REALTIME, &ts)); | |
494
6e9c1ea44262
Increase timer for the test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
261 ts.tv_sec += 20; /* Set the timeout to 20 second */ |
0 | 262 |
263 /* Create the messages */ | |
10
c5c99c73c2bf
Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
8
diff
changeset
|
264 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) ); |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
265 for (i = 0; i < NBR_MSG * nbr_threads * 2; i++) { |
0 | 266 CHECK( 0, fd_msg_new ( dwr_model, 0, &msgs[i] ) ); |
267 } | |
268 | |
269 /* Initialize the test data structures */ | |
270 td_1.queue = queue; | |
271 td_1.bar = &bar; | |
272 td_1.ts = &ts; | |
273 td_1.nbr = NBR_MSG; | |
274 td_2.queue = queue; | |
275 td_2.bar = &bar; | |
276 td_2.ts = NULL; | |
277 td_2.nbr = NBR_MSG; | |
278 | |
279 /* Create the threads */ | |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
280 for (i=0; i < nbr_threads * 2; i++) { |
0 | 281 CHECK( 0, pthread_create( &thr[i], NULL, test_fct, (i & 1) ? &td_1 : &td_2 ) ); |
282 } | |
283 | |
284 /* Synchronize everyone */ | |
285 { | |
286 int ret = pthread_barrier_wait(&bar); | |
287 if (ret != PTHREAD_BARRIER_SERIAL_THREAD) { | |
288 CHECK( 0, ret); | |
289 } else { | |
290 CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret); /* for trace only */ | |
291 } | |
292 } | |
293 | |
294 /* Now post all the messages */ | |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
295 for (i=0; i < NBR_MSG * nbr_threads * 2; i++) { |
0 | 296 msg = msgs[i]; |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
297 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 298 } |
299 | |
300 /* Join all threads. This blocks if messages are lost... */ | |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
301 for (i=0; i < nbr_threads * 2; i++) { |
0 | 302 CHECK( 0, pthread_join( thr[i], NULL ) ); |
303 } | |
304 | |
305 /* Check the count of the queue is back to 0 */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
306 CHECK( 0, fd_fifo_length(queue, &count) ); |
0 | 307 CHECK( 0, count); |
308 | |
309 /* Destroy this queue and the messages */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
310 CHECK( 0, fd_fifo_del(&queue) ); |
615
8abafd66a617
Adapt test for systems that cannot create many threads per process, such as OpenSUSE (bouuuuh)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
494
diff
changeset
|
311 for (i=0; i < NBR_MSG * nbr_threads * 2; i++) { |
0 | 312 CHECK( 0, fd_msg_free( msgs[i] ) ); |
313 } | |
314 } | |
315 | |
316 /* Test thread cancelation */ | |
317 { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
318 struct fifo *queue = NULL; |
0 | 319 pthread_barrier_t bar; |
320 struct test_data td; | |
321 pthread_t th; | |
322 | |
323 /* Create the queue */ | |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
324 CHECK( 0, fd_fifo_new(&queue, 0) ); |
0 | 325 |
326 /* Create the barrier */ | |
327 CHECK( 0, pthread_barrier_init(&bar, NULL, 2) ); | |
328 | |
329 /* Initialize the ts */ | |
330 CHECK(0, clock_gettime(CLOCK_REALTIME, &ts)); | |
494
6e9c1ea44262
Increase timer for the test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
331 ts.tv_sec += 10; /* Set the timeout to 10 second */ |
0 | 332 |
333 /* Initialize the test data structures */ | |
334 td.queue = queue; | |
335 td.bar = &bar; | |
336 td.ts = &ts; | |
337 td.nbr = 1; | |
338 | |
339 /* Create the thread */ | |
340 CHECK( 0, pthread_create( &th, NULL, test_fct, &td ) ); | |
341 | |
342 /* Wait for the thread to be running */ | |
343 { | |
344 int ret = pthread_barrier_wait(&bar); | |
345 if (ret != PTHREAD_BARRIER_SERIAL_THREAD) { | |
346 CHECK( 0, ret); | |
347 } else { | |
348 CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret ); | |
349 } | |
350 } | |
351 | |
352 /* Now cancel the thread */ | |
353 CHECK( 0, pthread_cancel( th ) ); | |
354 | |
355 /* Join it */ | |
356 CHECK( 0, pthread_join( th, NULL ) ); | |
357 | |
358 /* Do the same with the other function */ | |
359 td.ts = NULL; | |
360 | |
361 /* Create the thread */ | |
362 CHECK( 0, pthread_create( &th, NULL, test_fct, &td ) ); | |
363 | |
364 /* Wait for the thread to be running */ | |
365 { | |
366 int ret = pthread_barrier_wait(&bar); | |
367 if (ret != PTHREAD_BARRIER_SERIAL_THREAD) { | |
368 CHECK( 0, ret); | |
369 } else { | |
370 CHECK( PTHREAD_BARRIER_SERIAL_THREAD, ret ); | |
371 } | |
372 } | |
373 | |
374 /* Now cancel the thread */ | |
375 CHECK( 0, pthread_cancel( th ) ); | |
376 | |
377 /* Join it */ | |
378 CHECK( 0, pthread_join( th, NULL ) ); | |
379 | |
380 /* Destroy the queue */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
381 CHECK( 0, fd_fifo_del(&queue) ); |
0 | 382 } |
383 | |
384 /* Test the threashold function */ | |
385 { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
386 struct fifo * queue = NULL; |
0 | 387 int i; |
388 struct msg * msg = NULL; | |
389 | |
390 /* Create the queue */ | |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
391 CHECK( 0, fd_fifo_new(&queue, 0) ); |
0 | 392 |
393 /* Prepare the test data */ | |
394 memset(&thrh_td, 0, sizeof(thrh_td)); | |
395 thrh_td.queue = queue; | |
396 | |
397 /* Set the thresholds for the queue */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
398 CHECK( 0, fd_fifo_setthrhd ( queue, NULL, 6, thrh_cb_h, 4, thrh_cb_l ) ); |
0 | 399 |
400 /* Post 5 messages, no cb must be called. */ | |
401 for (i=0; i<5; i++) { | |
402 msg = msg1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
403 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 404 } /* 5 msg in queue */ |
405 CHECK( 0, thrh_td.h_calls ); | |
406 CHECK( 0, thrh_td.l_calls ); | |
407 | |
408 /* Get all these messages, and check again */ | |
409 for (i=0; i<5; i++) { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
410 CHECK( 0, fd_fifo_get(queue, &msg) ); |
0 | 411 } /* 0 msg in queue */ |
412 CHECK( 0, thrh_td.h_calls ); | |
413 CHECK( 0, thrh_td.l_calls ); | |
414 | |
415 /* Now, post 6 messages, the high threashold */ | |
416 for (i=0; i<6; i++) { | |
417 msg = msg1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
418 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 419 } /* 6 msg in queue */ |
420 CHECK( 1, thrh_td.h_calls ); | |
421 CHECK( 0, thrh_td.l_calls ); | |
422 | |
423 /* Remove 2 messages, to reach the low threshold */ | |
424 for (i=0; i<2; i++) { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
425 CHECK( 0, fd_fifo_get(queue, &msg) ); |
0 | 426 } /* 4 msg in queue */ |
427 CHECK( 1, thrh_td.h_calls ); | |
428 CHECK( 1, thrh_td.l_calls ); | |
429 | |
430 /* Come again at the high threshold */ | |
431 for (i=0; i<2; i++) { | |
432 msg = msg1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
433 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 434 } /* 6 msg in queue */ |
435 CHECK( 2, thrh_td.h_calls ); | |
436 CHECK( 1, thrh_td.l_calls ); | |
437 | |
438 /* Suppose the queue continues to grow */ | |
439 for (i=0; i<6; i++) { | |
440 msg = msg1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
441 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 442 } /* 12 msg in queue */ |
443 CHECK( 3, thrh_td.h_calls ); | |
444 CHECK( 1, thrh_td.l_calls ); | |
445 for (i=0; i<5; i++) { | |
446 msg = msg1; | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
447 CHECK( 0, fd_fifo_post(queue, &msg) ); |
0 | 448 } /* 17 msg in queue */ |
449 CHECK( 3, thrh_td.h_calls ); | |
450 CHECK( 1, thrh_td.l_calls ); | |
451 | |
452 /* Now the queue goes back to 0 messages */ | |
453 for (i=0; i<17; i++) { | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
454 CHECK( 0, fd_fifo_get(queue, &msg) ); |
0 | 455 } /* 0 msg in queue */ |
456 CHECK( 3, thrh_td.h_calls ); | |
457 CHECK( 3, thrh_td.l_calls ); | |
458 | |
459 /* We're done for this test */ | |
8
3e143f047f78
Backup for the week-end
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
460 CHECK( 0, fd_fifo_del(&queue) ); |
0 | 461 } |
462 | |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
463 /* Test max queue limit */ |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
464 { |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
465 struct fifo *queue = NULL; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
466 struct test_data td; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
467 pthread_t th; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
468 int * item, i; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
469 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
470 /* Create the queue */ |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
471 CHECK( 0, fd_fifo_new(&queue, 10) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
472 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
473 /* Initialize the test data structures */ |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
474 td.queue = queue; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
475 td.nbr = 15; |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
476 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
477 CHECK( 0, pthread_create( &th, NULL, test_fct2, &td ) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
478 |
768
a5a82d50c25e
Increased delay so that the test has more chances to pass. Wow, Fedora IS slow to create threads...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
767
diff
changeset
|
479 usleep(100000); /* 100 millisec */ |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
480 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
481 CHECK( 10, iter ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
482 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
483 CHECK( 0, fd_fifo_tryget(queue, &item) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
484 CHECK( 0, *item); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
485 free(item); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
486 |
768
a5a82d50c25e
Increased delay so that the test has more chances to pass. Wow, Fedora IS slow to create threads...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
767
diff
changeset
|
487 usleep(100000); /* 100 millisec */ |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
488 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
489 CHECK( 11, iter ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
490 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
491 for (i=1; i<4; i++) { |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
492 CHECK( 0, fd_fifo_get(queue, &item) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
493 CHECK( i, *item); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
494 free(item); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
495 } |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
496 |
768
a5a82d50c25e
Increased delay so that the test has more chances to pass. Wow, Fedora IS slow to create threads...
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
767
diff
changeset
|
497 usleep(100000); /* 100 millisec */ |
767
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
498 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
499 CHECK( 14, iter ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
500 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
501 /* fd_fifo_dump(0, "test", queue, NULL); */ |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
502 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
503 for (; i < td.nbr; i++) { |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
504 CHECK( 0, fd_fifo_tryget(queue, &item) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
505 CHECK( i, *item); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
506 free(item); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
507 } |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
508 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
509 CHECK( 0, pthread_join( th, NULL ) ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
510 CHECK( 15, iter ); |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
511 |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
512 } |
c47c16436f71
Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
751
diff
changeset
|
513 |
0 | 514 /* Delete the messages */ |
515 CHECK( 0, fd_msg_free( msg1 ) ); | |
516 CHECK( 0, fd_msg_free( msg2 ) ); | |
517 CHECK( 0, fd_msg_free( msg3 ) ); | |
518 | |
519 /* That's all for the tests yet */ | |
520 PASSTEST(); | |
521 } |