1/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software Foundation,
14 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15
16#include <my_global.h>
17#include <my_pthread.h>
18#include <string.h> // strncpy
19#include <pfs_instr_class.h>
20#include <pfs_instr.h>
21#include <pfs_global.h>
22#include <tap.h>
23
24void test_no_registration()
25{
26 int rc;
27 PFS_sync_key key;
28 PFS_thread_key thread_key;
29 PFS_file_key file_key;
30 PFS_socket_key socket_key;
31 PFS_mutex_class *mutex;
32 PFS_rwlock_class *rwlock;
33 PFS_cond_class *cond;
34 PFS_thread_class *thread;
35 PFS_file_class *file;
36 PFS_socket_class *socket;
37 /* PFS_table_share *table; */
38
39 rc= init_sync_class(0, 0, 0);
40 ok(rc == 0, "zero init (sync)");
41 rc= init_thread_class(0);
42 ok(rc == 0, "zero init (thread)");
43 rc= init_file_class(0);
44 ok(rc == 0, "zero init (file)");
45 rc= init_socket_class(0);
46 ok(rc == 0, "zero init (socket)");
47 rc= init_table_share(0);
48 ok(rc == 0, "zero init (table)");
49
50 key= register_mutex_class("FOO", 3, 0);
51 ok(key == 0, "no mutex registered");
52 key= register_mutex_class("BAR", 3, 0);
53 ok(key == 0, "no mutex registered");
54 key= register_mutex_class("FOO", 3, 0);
55 ok(key == 0, "no mutex registered");
56
57 key= register_rwlock_class("FOO", 3, 0);
58 ok(key == 0, "no rwlock registered");
59 key= register_rwlock_class("BAR", 3, 0);
60 ok(key == 0, "no rwlock registered");
61 key= register_rwlock_class("FOO", 3, 0);
62 ok(key == 0, "no rwlock registered");
63
64 key= register_cond_class("FOO", 3, 0);
65 ok(key == 0, "no cond registered");
66 key= register_cond_class("BAR", 3, 0);
67 ok(key == 0, "no cond registered");
68 key= register_cond_class("FOO", 3, 0);
69 ok(key == 0, "no cond registered");
70
71 thread_key= register_thread_class("FOO", 3, 0);
72 ok(thread_key == 0, "no thread registered");
73 thread_key= register_thread_class("BAR", 3, 0);
74 ok(thread_key == 0, "no thread registered");
75 thread_key= register_thread_class("FOO", 3, 0);
76 ok(thread_key == 0, "no thread registered");
77
78 file_key= register_file_class("FOO", 3, 0);
79 ok(file_key == 0, "no file registered");
80 file_key= register_file_class("BAR", 3, 0);
81 ok(file_key == 0, "no file registered");
82 file_key= register_file_class("FOO", 3, 0);
83 ok(file_key == 0, "no file registered");
84
85 socket_key= register_socket_class("FOO", 3, 0);
86 ok(socket_key == 0, "no socket registered");
87 socket_key= register_socket_class("BAR", 3, 0);
88 ok(socket_key == 0, "no socket registered");
89 socket_key= register_socket_class("FOO", 3, 0);
90 ok(socket_key == 0, "no socket registered");
91
92#ifdef LATER
93 PFS_thread fake_thread;
94 fake_thread.m_table_share_hash_pins= NULL;
95
96 table= find_or_create_table_share(& fake_thread, false, "foo_db", 6, "foo_table", 9);
97 ok(table == NULL, "not created");
98 table= find_or_create_table_share(& fake_thread, false, "bar_db", 6, "bar_table", 9);
99 ok(table == NULL, "not created");
100 table= find_or_create_table_share(& fake_thread, false, "foo_db", 6, "foo_table", 9);
101 ok(table == NULL, "not created");
102#endif
103
104 mutex= find_mutex_class(0);
105 ok(mutex == NULL, "no mutex key 0");
106 mutex= find_mutex_class(1);
107 ok(mutex == NULL, "no mutex key 1");
108 mutex= find_mutex_class(9999);
109 ok(mutex == NULL, "no mutex key 9999");
110
111 rwlock= find_rwlock_class(0);
112 ok(rwlock == NULL, "no rwlock key 0");
113 rwlock= find_rwlock_class(1);
114 ok(rwlock == NULL, "no rwlock key 1");
115 rwlock= find_rwlock_class(9999);
116 ok(rwlock == NULL, "no rwlock key 9999");
117
118 cond= find_cond_class(0);
119 ok(cond == NULL, "no cond key 0");
120 cond= find_cond_class(1);
121 ok(cond == NULL, "no cond key 1");
122 cond= find_cond_class(9999);
123 ok(cond == NULL, "no cond key 9999");
124
125 thread= find_thread_class(0);
126 ok(thread == NULL, "no thread key 0");
127 thread= find_thread_class(1);
128 ok(thread == NULL, "no thread key 1");
129 thread= find_thread_class(9999);
130 ok(thread == NULL, "no thread key 9999");
131
132 file= find_file_class(0);
133 ok(file == NULL, "no file key 0");
134 file= find_file_class(1);
135 ok(file == NULL, "no file key 1");
136 file= find_file_class(9999);
137 ok(file == NULL, "no file key 9999");
138
139 socket= find_socket_class(0);
140 ok(socket == NULL, "no socket key 0");
141 socket= find_socket_class(1);
142 ok(socket == NULL, "no socket key 1");
143 socket= find_socket_class(9999);
144 ok(socket == NULL, "no socket key 9999");
145
146 cleanup_sync_class();
147 cleanup_thread_class();
148 cleanup_file_class();
149 cleanup_socket_class();
150 cleanup_table_share();
151}
152
153void test_mutex_registration()
154{
155 int rc;
156 PFS_sync_key key;
157 PFS_mutex_class *mutex;
158
159 rc= init_sync_class(5, 0, 0);
160 ok(rc == 0, "room for 5 mutex");
161
162 key= register_mutex_class("FOO", 3, 0);
163 ok(key == 1, "foo registered");
164 key= register_mutex_class("BAR", 3, 0);
165 ok(key == 2, "bar registered");
166 key= register_mutex_class("FOO", 3, 0);
167 ok(key == 1, "foo re registered");
168 key= register_mutex_class("M-3", 3, 0);
169 ok(key == 3, "M-3 registered");
170 key= register_mutex_class("M-4", 3, 0);
171 ok(key == 4, "M-4 registered");
172 key= register_mutex_class("M-5", 3, 0);
173 ok(key == 5, "M-5 registered");
174 ok(mutex_class_lost == 0, "lost nothing");
175 key= register_mutex_class("M-6", 3, 0);
176 ok(key == 0, "M-6 not registered");
177 ok(mutex_class_lost == 1, "lost 1 mutex");
178 key= register_mutex_class("M-7", 3, 0);
179 ok(key == 0, "M-7 not registered");
180 ok(mutex_class_lost == 2, "lost 2 mutex");
181 key= register_mutex_class("M-3", 3, 0);
182 ok(key == 3, "M-3 re registered");
183 ok(mutex_class_lost == 2, "lost 2 mutex");
184 key= register_mutex_class("M-5", 3, 0);
185 ok(key == 5, "M-5 re registered");
186 ok(mutex_class_lost == 2, "lost 2 mutex");
187
188 mutex= find_mutex_class(0);
189 ok(mutex == NULL, "no key 0");
190 mutex= find_mutex_class(3);
191 ok(mutex != NULL, "found key 3");
192 ok(strncmp(mutex->m_name, "M-3", 3) == 0, "key 3 is M-3");
193 ok(mutex->m_name_length == 3, "name length 3");
194 mutex= find_mutex_class(9999);
195 ok(mutex == NULL, "no key 9999");
196
197 cleanup_sync_class();
198}
199
200void test_rwlock_registration()
201{
202 int rc;
203 PFS_sync_key key;
204 PFS_rwlock_class *rwlock;
205
206 rc= init_sync_class(0, 5, 0);
207 ok(rc == 0, "room for 5 rwlock");
208
209 key= register_rwlock_class("FOO", 3, 0);
210 ok(key == 1, "foo registered");
211 key= register_rwlock_class("BAR", 3, 0);
212 ok(key == 2, "bar registered");
213 key= register_rwlock_class("FOO", 3, 0);
214 ok(key == 1, "foo re registered");
215 key= register_rwlock_class("RW-3", 4, 0);
216 ok(key == 3, "RW-3 registered");
217 key= register_rwlock_class("RW-4", 4, 0);
218 ok(key == 4, "RW-4 registered");
219 key= register_rwlock_class("RW-5", 4, 0);
220 ok(key == 5, "RW-5 registered");
221 key= register_rwlock_class("RW-6", 4, 0);
222 ok(key == 0, "RW-6 not registered");
223 key= register_rwlock_class("RW-7", 4, 0);
224 ok(key == 0, "RW-7 not registered");
225 key= register_rwlock_class("RW-3", 4, 0);
226 ok(key == 3, "RW-3 re registered");
227 key= register_rwlock_class("RW-5", 4, 0);
228 ok(key == 5, "RW-5 re registered");
229
230 rwlock= find_rwlock_class(0);
231 ok(rwlock == NULL, "no key 0");
232 rwlock= find_rwlock_class(3);
233 ok(rwlock != NULL, "found key 3");
234 ok(strncmp(rwlock->m_name, "RW-3", 4) == 0, "key 3 is RW-3");
235 ok(rwlock->m_name_length == 4, "name length 4");
236 rwlock= find_rwlock_class(9999);
237 ok(rwlock == NULL, "no key 9999");
238
239 cleanup_sync_class();
240}
241
242void test_cond_registration()
243{
244 int rc;
245 PFS_sync_key key;
246 PFS_cond_class *cond;
247
248 rc= init_sync_class(0, 0, 5);
249 ok(rc == 0, "room for 5 cond");
250
251 key= register_cond_class("FOO", 3, 0);
252 ok(key == 1, "foo registered");
253 key= register_cond_class("BAR", 3, 0);
254 ok(key == 2, "bar registered");
255 key= register_cond_class("FOO", 3, 0);
256 ok(key == 1, "foo re registered");
257 key= register_cond_class("C-3", 3, 0);
258 ok(key == 3, "C-3 registered");
259 key= register_cond_class("C-4", 3, 0);
260 ok(key == 4, "C-4 registered");
261 key= register_cond_class("C-5", 3, 0);
262 ok(key == 5, "C-5 registered");
263 key= register_cond_class("C-6", 3, 0);
264 ok(key == 0, "C-6 not registered");
265 key= register_cond_class("C-7", 3, 0);
266 ok(key == 0, "C-7 not registered");
267 key= register_cond_class("C-3", 3, 0);
268 ok(key == 3, "C-3 re registered");
269 key= register_cond_class("C-5", 3, 0);
270 ok(key == 5, "C-5 re registered");
271
272 cond= find_cond_class(0);
273 ok(cond == NULL, "no key 0");
274 cond= find_cond_class(3);
275 ok(cond != NULL, "found key 3");
276 ok(strncmp(cond->m_name, "C-3", 3) == 0, "key 3 is C-3");
277 ok(cond->m_name_length == 3, "name length 3");
278 cond= find_cond_class(9999);
279 ok(cond == NULL, "no key 9999");
280
281 cleanup_sync_class();
282}
283
284void test_thread_registration()
285{
286 int rc;
287 PFS_thread_key key;
288 PFS_thread_class *thread;
289
290 rc= init_thread_class(5);
291 ok(rc == 0, "room for 5 thread");
292
293 key= register_thread_class("FOO", 3, 0);
294 ok(key == 1, "foo registered");
295 key= register_thread_class("BAR", 3, 0);
296 ok(key == 2, "bar registered");
297 key= register_thread_class("FOO", 3, 0);
298 ok(key == 1, "foo re registered");
299 key= register_thread_class("Thread-3", 8, 0);
300 ok(key == 3, "Thread-3 registered");
301 key= register_thread_class("Thread-4", 8, 0);
302 ok(key == 4, "Thread-4 registered");
303 key= register_thread_class("Thread-5", 8, 0);
304 ok(key == 5, "Thread-5 registered");
305 key= register_thread_class("Thread-6", 8, 0);
306 ok(key == 0, "Thread-6 not registered");
307 key= register_thread_class("Thread-7", 8, 0);
308 ok(key == 0, "Thread-7 not registered");
309 key= register_thread_class("Thread-3", 8, 0);
310 ok(key == 3, "Thread-3 re registered");
311 key= register_thread_class("Thread-5", 8, 0);
312 ok(key == 5, "Thread-5 re registered");
313
314 thread= find_thread_class(0);
315 ok(thread == NULL, "no key 0");
316 thread= find_thread_class(3);
317 ok(thread != NULL, "found key 3");
318 ok(strncmp(thread->m_name, "Thread-3", 8) == 0, "key 3 is Thread-3");
319 ok(thread->m_name_length == 8, "name length 8");
320 thread= find_thread_class(9999);
321 ok(thread == NULL, "no key 9999");
322
323 cleanup_thread_class();
324}
325
326void test_file_registration()
327{
328 int rc;
329 PFS_file_key key;
330 PFS_file_class *file;
331
332 rc= init_file_class(5);
333 ok(rc == 0, "room for 5 file");
334
335 key= register_file_class("FOO", 3, 0);
336 ok(key == 1, "foo registered");
337 key= register_file_class("BAR", 3, 0);
338 ok(key == 2, "bar registered");
339 key= register_file_class("FOO", 3, 0);
340 ok(key == 1, "foo re registered");
341 key= register_file_class("File-3", 6, 0);
342 ok(key == 3, "File-3 registered");
343 key= register_file_class("File-4", 6, 0);
344 ok(key == 4, "File-4 registered");
345 key= register_file_class("File-5", 6, 0);
346 ok(key == 5, "File-5 registered");
347 key= register_file_class("File-6", 6, 0);
348 ok(key == 0, "File-6 not registered");
349 key= register_file_class("File-7", 6, 0);
350 ok(key == 0, "File-7 not registered");
351 key= register_file_class("File-3", 6, 0);
352 ok(key == 3, "File-3 re registered");
353 key= register_file_class("File-5", 6, 0);
354 ok(key == 5, "File-5 re registered");
355
356 file= find_file_class(0);
357 ok(file == NULL, "no key 0");
358 file= find_file_class(3);
359 ok(file != NULL, "found key 3");
360 ok(strncmp(file->m_name, "File-3", 6) == 0, "key 3 is File-3");
361 ok(file->m_name_length == 6, "name length 6");
362 file= find_file_class(9999);
363 ok(file == NULL, "no key 9999");
364
365 cleanup_file_class();
366}
367
368void test_socket_registration()
369{
370 int rc;
371 PFS_socket_key key;
372 PFS_socket_class *socket;
373
374 rc= init_socket_class(5);
375 ok(rc == 0, "room for 5 socket");
376
377 key= register_socket_class("FOO", 3, 0);
378 ok(key == 1, "foo registered");
379 key= register_socket_class("BAR", 3, 0);
380 ok(key == 2, "bar registered");
381 key= register_socket_class("FOO", 3, 0);
382 ok(key == 1, "foo re registered");
383 key= register_socket_class("Socket-3", 8, 0);
384 ok(key == 3, "Socket-3 registered");
385 key= register_socket_class("Socket-4", 8, 0);
386 ok(key == 4, "Socket-4 registered");
387 key= register_socket_class("Socket-5", 8, 0);
388 ok(key == 5, "Socket-5 registered");
389 ok(socket_class_lost == 0, "lost nothing");
390 key= register_socket_class("Socket-6", 8, 0);
391 ok(key == 0, "Socket-6 not registered");
392 ok(socket_class_lost == 1, "lost 1 socket");
393 key= register_socket_class("Socket-7", 8, 0);
394 ok(key == 0, "Socket-7 not registered");
395 ok(socket_class_lost == 2, "lost 2 socket");
396 key= register_socket_class("Socket-3", 8, 0);
397 ok(key == 3, "Socket-3 re registered");
398 ok(socket_class_lost == 2, "lost 2 socket");
399 key= register_socket_class("Socket-5", 8, 0);
400 ok(key == 5, "Socket-5 re registered");
401 ok(socket_class_lost == 2, "lost 2 socket");
402
403 socket= find_socket_class(0);
404 ok(socket == NULL, "no key 0");
405 socket= find_socket_class(3);
406 ok(socket != NULL, "found key 3");
407 ok(strncmp(socket->m_name, "Socket-3", 8) == 0, "key 3 is Socket-3");
408 ok(socket->m_name_length == 8, "name length 3");
409 socket= find_socket_class(9999);
410 ok(socket == NULL, "no key 9999");
411
412 cleanup_socket_class();
413}
414
415void test_table_registration()
416{
417#ifdef LATER
418 PFS_table_share *table_share;
419 PFS_table_share *table_share_2;
420
421 PFS_thread fake_thread;
422 fake_thread.m_table_share_hash_pins= NULL;
423
424 table_share_lost= 0;
425 table_share= find_or_create_table_share(& fake_thread, false, "db1", 3, "t1", 2);
426 ok(table_share == NULL, "not created");
427 ok(table_share_lost == 1, "lost the table");
428
429 table_share_lost= 0;
430 init_table_share(5);
431 init_table_share_hash();
432
433 table_share= find_or_create_table_share(& fake_thread, false, "db1", 3, "t1", 2);
434 ok(table_share != NULL, "created db1.t1");
435 ok(table_share_lost == 0, "not lost");
436
437 table_share_2= find_or_create_table_share(& fake_thread, false, "db1", 3, "t1", 2);
438 ok(table_share_2 != NULL, "found db1.t1");
439 ok(table_share_lost == 0, "not lost");
440 ok(table_share == table_share_2, "same table");
441
442 table_share_2= find_or_create_table_share(& fake_thread, false, "db1", 3, "t2", 2);
443 ok(table_share_2 != NULL, "created db1.t2");
444 ok(table_share_lost == 0, "not lost");
445
446 table_share_2= find_or_create_table_share(& fake_thread, false, "db2", 3, "t1", 2);
447 ok(table_share_2 != NULL, "created db2.t1");
448 ok(table_share_lost == 0, "not lost");
449
450 table_share_2= find_or_create_table_share(& fake_thread, false, "db2", 3, "t2", 2);
451 ok(table_share_2 != NULL, "created db2.t2");
452 ok(table_share_lost == 0, "not lost");
453
454 table_share_2= find_or_create_table_share(& fake_thread, false, "db3", 3, "t3", 2);
455 ok(table_share_2 != NULL, "created db3.t3");
456 ok(table_share_lost == 0, "not lost");
457
458 table_share_2= find_or_create_table_share(& fake_thread, false, "db4", 3, "t4", 2);
459 ok(table_share_2 == NULL, "lost db4.t4");
460 ok(table_share_lost == 1, "lost");
461
462 table_share_lost= 0;
463 table_share_2= find_or_create_table_share(& fake_thread, false, "db1", 3, "t2", 2);
464 ok(table_share_2 != NULL, "found db1.t2");
465 ok(table_share_lost == 0, "not lost");
466 ok(strncmp(table_share_2->m_schema_name, "db1", 3) == 0 , "schema db1");
467 ok(table_share_2->m_schema_name_length == 3, "length 3");
468 ok(strncmp(table_share_2->m_table_name, "t2", 2) == 0 , "table t2");
469 ok(table_share_2->m_table_name_length == 2, "length 2");
470
471 cleanup_table_share_hash();
472 cleanup_table_share();
473#endif
474}
475
476#ifdef LATER
477void set_wait_stat(PFS_instr_class *klass)
478{
479 PFS_single_stat *stat;
480 stat= & global_instr_class_waits_array[klass->m_event_name_index];
481
482 stat->m_count= 12;
483 stat->m_min= 5;
484 stat->m_max= 120;
485 stat->m_sum= 999;
486}
487
488bool is_empty_stat(PFS_instr_class *klass)
489{
490 PFS_single_stat *stat;
491 stat= & global_instr_class_waits_array[klass->m_event_name_index];
492
493 if (stat->m_count != 0)
494 return false;
495 if (stat->m_min != (ulonglong) -1)
496 return false;
497 if (stat->m_max != 0)
498 return false;
499 if (stat->m_sum != 0)
500 return false;
501 return true;
502}
503#endif
504
505void test_instruments_reset()
506{
507 int rc;
508 PFS_sync_key key;
509 PFS_file_key file_key;
510 PFS_socket_key socket_key;
511 PFS_mutex_class *mutex_1;
512 PFS_mutex_class *mutex_2;
513 PFS_mutex_class *mutex_3;
514 PFS_rwlock_class *rwlock_1;
515 PFS_rwlock_class *rwlock_2;
516 PFS_rwlock_class *rwlock_3;
517 PFS_cond_class *cond_1;
518 PFS_cond_class *cond_2;
519 PFS_cond_class *cond_3;
520 PFS_file_class *file_1;
521 PFS_file_class *file_2;
522 PFS_file_class *file_3;
523 PFS_socket_class *socket_1;
524 PFS_socket_class *socket_2;
525 PFS_socket_class *socket_3;
526
527 rc= init_sync_class(3, 3, 3);
528 ok(rc == 0, "init (sync)");
529 rc= init_thread_class(3);
530 ok(rc == 0, "init (thread)");
531 rc= init_file_class(3);
532 ok(rc == 0, "init (file)");
533 rc= init_socket_class(3);
534 ok(rc == 0, "init (socket)");
535
536 key= register_mutex_class("M-1", 3, 0);
537 ok(key == 1, "mutex registered");
538 key= register_mutex_class("M-2", 3, 0);
539 ok(key == 2, "mutex registered");
540 key= register_mutex_class("M-3", 3, 0);
541 ok(key == 3, "mutex registered");
542
543 key= register_rwlock_class("RW-1", 4, 0);
544 ok(key == 1, "rwlock registered");
545 key= register_rwlock_class("RW-2", 4, 0);
546 ok(key == 2, "rwlock registered");
547 key= register_rwlock_class("RW-3", 4, 0);
548 ok(key == 3, "rwlock registered");
549
550 key= register_cond_class("C-1", 3, 0);
551 ok(key == 1, "cond registered");
552 key= register_cond_class("C-2", 3, 0);
553 ok(key == 2, "cond registered");
554 key= register_cond_class("C-3", 3, 0);
555 ok(key == 3, "cond registered");
556
557 file_key= register_file_class("F-1", 3, 0);
558 ok(file_key == 1, "file registered");
559 file_key= register_file_class("F-2", 3, 0);
560 ok(file_key == 2, "file registered");
561 file_key= register_file_class("F-3", 3, 0);
562 ok(file_key == 3, "file registered");
563
564 socket_key= register_socket_class("S-1", 3, 0);
565 ok(socket_key == 1, "socket registered");
566 socket_key= register_socket_class("S-2", 3, 0);
567 ok(socket_key == 2, "socket registered");
568 socket_key= register_socket_class("S-3", 3, 0);
569 ok(socket_key == 3, "socket registered");
570
571 mutex_1= find_mutex_class(1);
572 ok(mutex_1 != NULL, "mutex key 1");
573 mutex_2= find_mutex_class(2);
574 ok(mutex_2 != NULL, "mutex key 2");
575 mutex_3= find_mutex_class(3);
576 ok(mutex_3 != NULL, "mutex key 3");
577
578 rwlock_1= find_rwlock_class(1);
579 ok(rwlock_1 != NULL, "rwlock key 1");
580 rwlock_2= find_rwlock_class(2);
581 ok(rwlock_2 != NULL, "rwlock key 2");
582 rwlock_3= find_rwlock_class(3);
583 ok(rwlock_3 != NULL, "rwlock key 3");
584
585 cond_1= find_cond_class(1);
586 ok(cond_1 != NULL, "cond key 1");
587 cond_2= find_cond_class(2);
588 ok(cond_2 != NULL, "cond key 2");
589 cond_3= find_cond_class(3);
590 ok(cond_3 != NULL, "cond key 3");
591
592 file_1= find_file_class(1);
593 ok(file_1 != NULL, "file key 1");
594 file_2= find_file_class(2);
595 ok(file_2 != NULL, "file key 2");
596 file_3= find_file_class(3);
597 ok(file_3 != NULL, "file key 3");
598
599 socket_1= find_socket_class(1);
600 ok(socket_1 != NULL, "socket key 1");
601 socket_2= find_socket_class(2);
602 ok(socket_2 != NULL, "socket key 2");
603 socket_3= find_socket_class(3);
604 ok(socket_3 != NULL, "socket key 3");
605
606#ifdef LATER
607 set_wait_stat(mutex_1);
608 set_wait_stat(mutex_2);
609 set_wait_stat(mutex_3);
610 set_wait_stat(rwlock_1);
611 set_wait_stat(rwlock_2);
612 set_wait_stat(rwlock_3);
613 set_wait_stat(cond_1);
614 set_wait_stat(cond_2);
615 set_wait_stat(cond_3);
616 set_wait_stat(file_1);
617 set_wait_stat(file_2);
618 set_wait_stat(file_3);
619
620 ok(! is_empty_stat(mutex_1), "mutex_1 stat is populated");
621 ok(! is_empty_stat(mutex_2), "mutex_2 stat is populated");
622 ok(! is_empty_stat(mutex_3), "mutex_3 stat is populated");
623 ok(! is_empty_stat(rwlock_1), "rwlock_1 stat is populated");
624 ok(! is_empty_stat(rwlock_2), "rwlock_2 stat is populated");
625 ok(! is_empty_stat(rwlock_3), "rwlock_3 stat is populated");
626 ok(! is_empty_stat(cond_1), "cond_1 stat is populated");
627 ok(! is_empty_stat(cond_2), "cond_2 stat is populated");
628 ok(! is_empty_stat(cond_3), "cond_3 stat is populated");
629 ok(! is_empty_stat(file_1), "file_1 stat is populated");
630 ok(! is_empty_stat(file_2), "file_2 stat is populated");
631 ok(! is_empty_stat(file_3), "file_3 stat is populated");
632
633 reset_global_wait_stat();
634
635 ok(is_empty_stat(mutex_1), "mutex_1 stat is cleared");
636 ok(is_empty_stat(mutex_2), "mutex_2 stat is cleared");
637 ok(is_empty_stat(mutex_3), "mutex_3 stat is cleared");
638 ok(is_empty_stat(rwlock_1), "rwlock_1 stat is cleared");
639 ok(is_empty_stat(rwlock_2), "rwlock_2 stat is cleared");
640 ok(is_empty_stat(rwlock_3), "rwlock_3 stat is cleared");
641 ok(is_empty_stat(cond_1), "cond_1 stat is cleared");
642 ok(is_empty_stat(cond_2), "cond_2 stat is cleared");
643 ok(is_empty_stat(cond_3), "cond_3 stat is cleared");
644 ok(is_empty_stat(file_1), "file_1 stat is cleared");
645 ok(is_empty_stat(file_2), "file_2 stat is cleared");
646 ok(is_empty_stat(file_3), "file_3 stat is cleared");
647#endif
648
649 cleanup_sync_class();
650 cleanup_file_class();
651 cleanup_socket_class();
652}
653
654void do_all_tests()
655{
656 test_no_registration();
657 test_mutex_registration();
658 test_rwlock_registration();
659 test_cond_registration();
660 test_thread_registration();
661 test_file_registration();
662 test_socket_registration();
663 test_table_registration();
664 test_instruments_reset();
665}
666
667int main(int argc, char **argv)
668{
669 plan(181);
670 MY_INIT(argv[0]);
671 do_all_tests();
672 my_end(0);
673 return (exit_status());
674}
675