16 #include <my_global.h>
17 #include <my_pthread.h>
24 #include "stub_server_misc.h"
26 void test_no_registration()
42 ok(rc == 0,
"zero init (sync)");
44 ok(rc == 0,
"zero init (thread)");
46 ok(rc == 0,
"zero init (file)");
48 ok(rc == 0,
"zero init (socket)");
50 ok(rc == 0,
"zero init (table)");
53 ok(key == 0,
"no mutex registered");
55 ok(key == 0,
"no mutex registered");
57 ok(key == 0,
"no mutex registered");
60 ok(key == 0,
"no rwlock registered");
62 ok(key == 0,
"no rwlock registered");
64 ok(key == 0,
"no rwlock registered");
67 ok(key == 0,
"no cond registered");
69 ok(key == 0,
"no cond registered");
71 ok(key == 0,
"no cond registered");
74 ok(thread_key == 0,
"no thread registered");
76 ok(thread_key == 0,
"no thread registered");
78 ok(thread_key == 0,
"no thread registered");
81 ok(file_key == 0,
"no file registered");
83 ok(file_key == 0,
"no file registered");
85 ok(file_key == 0,
"no file registered");
88 ok(socket_key == 0,
"no socket registered");
90 ok(socket_key == 0,
"no socket registered");
92 ok(socket_key == 0,
"no socket registered");
99 ok(
table == NULL,
"not created");
101 ok(
table == NULL,
"not created");
103 ok(
table == NULL,
"not created");
107 ok(mutex == NULL,
"no mutex key 0");
109 ok(mutex == NULL,
"no mutex key 1");
111 ok(mutex == NULL,
"no mutex key 9999");
114 ok(rwlock == NULL,
"no rwlock key 0");
116 ok(rwlock == NULL,
"no rwlock key 1");
118 ok(rwlock == NULL,
"no rwlock key 9999");
121 ok(cond == NULL,
"no cond key 0");
123 ok(cond == NULL,
"no cond key 1");
125 ok(cond == NULL,
"no cond key 9999");
128 ok(thread == NULL,
"no thread key 0");
130 ok(thread == NULL,
"no thread key 1");
132 ok(thread == NULL,
"no thread key 9999");
135 ok(file == NULL,
"no file key 0");
137 ok(file == NULL,
"no file key 1");
139 ok(file == NULL,
"no file key 9999");
142 ok(socket == NULL,
"no socket key 0");
144 ok(socket == NULL,
"no socket key 1");
146 ok(socket == NULL,
"no socket key 9999");
155 void test_mutex_registration()
162 ok(rc == 0,
"room for 5 mutex");
165 ok(key == 1,
"foo registered");
167 ok(key == 2,
"bar registered");
169 ok(key == 1,
"foo re registered");
171 ok(key == 3,
"M-3 registered");
173 ok(key == 4,
"M-4 registered");
175 ok(key == 5,
"M-5 registered");
178 ok(key == 0,
"M-6 not registered");
181 ok(key == 0,
"M-7 not registered");
184 ok(key == 3,
"M-3 re registered");
187 ok(key == 5,
"M-5 re registered");
191 ok(mutex == NULL,
"no key 0");
193 ok(mutex != NULL,
"found key 3");
194 ok(strncmp(mutex->
m_name,
"M-3", 3) == 0,
"key 3 is M-3");
197 ok(mutex == NULL,
"no key 9999");
202 void test_rwlock_registration()
209 ok(rc == 0,
"room for 5 rwlock");
212 ok(key == 1,
"foo registered");
214 ok(key == 2,
"bar registered");
216 ok(key == 1,
"foo re registered");
218 ok(key == 3,
"RW-3 registered");
220 ok(key == 4,
"RW-4 registered");
222 ok(key == 5,
"RW-5 registered");
224 ok(key == 0,
"RW-6 not registered");
226 ok(key == 0,
"RW-7 not registered");
228 ok(key == 3,
"RW-3 re registered");
230 ok(key == 5,
"RW-5 re registered");
233 ok(rwlock == NULL,
"no key 0");
235 ok(rwlock != NULL,
"found key 3");
236 ok(strncmp(rwlock->
m_name,
"RW-3", 4) == 0,
"key 3 is RW-3");
239 ok(rwlock == NULL,
"no key 9999");
244 void test_cond_registration()
251 ok(rc == 0,
"room for 5 cond");
254 ok(key == 1,
"foo registered");
256 ok(key == 2,
"bar registered");
258 ok(key == 1,
"foo re registered");
260 ok(key == 3,
"C-3 registered");
262 ok(key == 4,
"C-4 registered");
264 ok(key == 5,
"C-5 registered");
266 ok(key == 0,
"C-6 not registered");
268 ok(key == 0,
"C-7 not registered");
270 ok(key == 3,
"C-3 re registered");
272 ok(key == 5,
"C-5 re registered");
275 ok(cond == NULL,
"no key 0");
277 ok(cond != NULL,
"found key 3");
278 ok(strncmp(cond->
m_name,
"C-3", 3) == 0,
"key 3 is C-3");
281 ok(cond == NULL,
"no key 9999");
286 void test_thread_registration()
293 ok(rc == 0,
"room for 5 thread");
296 ok(key == 1,
"foo registered");
298 ok(key == 2,
"bar registered");
300 ok(key == 1,
"foo re registered");
302 ok(key == 3,
"Thread-3 registered");
304 ok(key == 4,
"Thread-4 registered");
306 ok(key == 5,
"Thread-5 registered");
308 ok(key == 0,
"Thread-6 not registered");
310 ok(key == 0,
"Thread-7 not registered");
312 ok(key == 3,
"Thread-3 re registered");
314 ok(key == 5,
"Thread-5 re registered");
317 ok(thread == NULL,
"no key 0");
319 ok(thread != NULL,
"found key 3");
320 ok(strncmp(thread->
m_name,
"Thread-3", 8) == 0,
"key 3 is Thread-3");
323 ok(thread == NULL,
"no key 9999");
328 void test_file_registration()
335 ok(rc == 0,
"room for 5 file");
338 ok(key == 1,
"foo registered");
340 ok(key == 2,
"bar registered");
342 ok(key == 1,
"foo re registered");
344 ok(key == 3,
"File-3 registered");
346 ok(key == 4,
"File-4 registered");
348 ok(key == 5,
"File-5 registered");
350 ok(key == 0,
"File-6 not registered");
352 ok(key == 0,
"File-7 not registered");
354 ok(key == 3,
"File-3 re registered");
356 ok(key == 5,
"File-5 re registered");
359 ok(file == NULL,
"no key 0");
361 ok(file != NULL,
"found key 3");
362 ok(strncmp(file->
m_name,
"File-3", 6) == 0,
"key 3 is File-3");
365 ok(file == NULL,
"no key 9999");
370 void test_socket_registration()
377 ok(rc == 0,
"room for 5 socket");
380 ok(key == 1,
"foo registered");
382 ok(key == 2,
"bar registered");
384 ok(key == 1,
"foo re registered");
386 ok(key == 3,
"Socket-3 registered");
388 ok(key == 4,
"Socket-4 registered");
390 ok(key == 5,
"Socket-5 registered");
393 ok(key == 0,
"Socket-6 not registered");
396 ok(key == 0,
"Socket-7 not registered");
399 ok(key == 3,
"Socket-3 re registered");
402 ok(key == 5,
"Socket-5 re registered");
406 ok(socket == NULL,
"no key 0");
408 ok(socket != NULL,
"found key 3");
409 ok(strncmp(socket->
m_name,
"Socket-3", 8) == 0,
"key 3 is Socket-3");
412 ok(socket == NULL,
"no key 9999");
417 void test_table_registration()
428 ok(table_share == NULL,
"not created");
436 ok(table_share != NULL,
"created db1.t1");
440 ok(table_share_2 != NULL,
"found db1.t1");
442 ok(table_share == table_share_2,
"same table");
445 ok(table_share_2 != NULL,
"created db1.t2");
449 ok(table_share_2 != NULL,
"created db2.t1");
453 ok(table_share_2 != NULL,
"created db2.t2");
457 ok(table_share_2 != NULL,
"created db3.t3");
461 ok(table_share_2 == NULL,
"lost db4.t4");
466 ok(table_share_2 != NULL,
"found db1.t2");
468 ok(strncmp(table_share_2->
m_schema_name,
"db1", 3) == 0 ,
"schema db1");
470 ok(strncmp(table_share_2->
m_table_name,
"t2", 2) == 0 ,
"table t2");
497 if (stat->
m_min != (ulonglong) -1)
499 if (stat->
m_max != 0)
501 if (stat->
m_sum != 0)
507 void test_instruments_reset()
530 ok(rc == 0,
"init (sync)");
532 ok(rc == 0,
"init (thread)");
534 ok(rc == 0,
"init (file)");
536 ok(rc == 0,
"init (socket)");
539 ok(key == 1,
"mutex registered");
541 ok(key == 2,
"mutex registered");
543 ok(key == 3,
"mutex registered");
546 ok(key == 1,
"rwlock registered");
548 ok(key == 2,
"rwlock registered");
550 ok(key == 3,
"rwlock registered");
553 ok(key == 1,
"cond registered");
555 ok(key == 2,
"cond registered");
557 ok(key == 3,
"cond registered");
560 ok(file_key == 1,
"file registered");
562 ok(file_key == 2,
"file registered");
564 ok(file_key == 3,
"file registered");
567 ok(socket_key == 1,
"socket registered");
569 ok(socket_key == 2,
"socket registered");
571 ok(socket_key == 3,
"socket registered");
574 ok(mutex_1 != NULL,
"mutex key 1");
576 ok(mutex_2 != NULL,
"mutex key 2");
578 ok(mutex_3 != NULL,
"mutex key 3");
581 ok(rwlock_1 != NULL,
"rwlock key 1");
583 ok(rwlock_2 != NULL,
"rwlock key 2");
585 ok(rwlock_3 != NULL,
"rwlock key 3");
588 ok(cond_1 != NULL,
"cond key 1");
590 ok(cond_2 != NULL,
"cond key 2");
592 ok(cond_3 != NULL,
"cond key 3");
595 ok(file_1 != NULL,
"file key 1");
597 ok(file_2 != NULL,
"file key 2");
599 ok(file_3 != NULL,
"file key 3");
602 ok(socket_1 != NULL,
"socket key 1");
604 ok(socket_2 != NULL,
"socket key 2");
606 ok(socket_3 != NULL,
"socket key 3");
609 set_wait_stat(mutex_1);
610 set_wait_stat(mutex_2);
611 set_wait_stat(mutex_3);
612 set_wait_stat(rwlock_1);
613 set_wait_stat(rwlock_2);
614 set_wait_stat(rwlock_3);
615 set_wait_stat(cond_1);
616 set_wait_stat(cond_2);
617 set_wait_stat(cond_3);
618 set_wait_stat(file_1);
619 set_wait_stat(file_2);
620 set_wait_stat(file_3);
622 ok(! is_empty_stat(mutex_1),
"mutex_1 stat is populated");
623 ok(! is_empty_stat(mutex_2),
"mutex_2 stat is populated");
624 ok(! is_empty_stat(mutex_3),
"mutex_3 stat is populated");
625 ok(! is_empty_stat(rwlock_1),
"rwlock_1 stat is populated");
626 ok(! is_empty_stat(rwlock_2),
"rwlock_2 stat is populated");
627 ok(! is_empty_stat(rwlock_3),
"rwlock_3 stat is populated");
628 ok(! is_empty_stat(cond_1),
"cond_1 stat is populated");
629 ok(! is_empty_stat(cond_2),
"cond_2 stat is populated");
630 ok(! is_empty_stat(cond_3),
"cond_3 stat is populated");
631 ok(! is_empty_stat(file_1),
"file_1 stat is populated");
632 ok(! is_empty_stat(file_2),
"file_2 stat is populated");
633 ok(! is_empty_stat(file_3),
"file_3 stat is populated");
635 reset_global_wait_stat();
637 ok(is_empty_stat(mutex_1),
"mutex_1 stat is cleared");
638 ok(is_empty_stat(mutex_2),
"mutex_2 stat is cleared");
639 ok(is_empty_stat(mutex_3),
"mutex_3 stat is cleared");
640 ok(is_empty_stat(rwlock_1),
"rwlock_1 stat is cleared");
641 ok(is_empty_stat(rwlock_2),
"rwlock_2 stat is cleared");
642 ok(is_empty_stat(rwlock_3),
"rwlock_3 stat is cleared");
643 ok(is_empty_stat(cond_1),
"cond_1 stat is cleared");
644 ok(is_empty_stat(cond_2),
"cond_2 stat is cleared");
645 ok(is_empty_stat(cond_3),
"cond_3 stat is cleared");
646 ok(is_empty_stat(file_1),
"file_1 stat is cleared");
647 ok(is_empty_stat(file_2),
"file_2 stat is cleared");
648 ok(is_empty_stat(file_3),
"file_3 stat is cleared");
660 test_no_registration();
661 test_mutex_registration();
662 test_rwlock_registration();
663 test_cond_registration();
664 test_thread_registration();
665 test_file_registration();
666 test_socket_registration();
667 test_table_registration();
668 test_instruments_reset();
673 int main(
int,
char **)
676 MY_INIT(
"pfs_instr_info-t");