2 //=============================================================================
4 * @file Reference_Counted_Event_Handler_Test.cpp
6 * This test is used to check reference counting of the Event
7 * Handler when it interacts with the Reactor.
9 * @author Irfan Pyarali <irfan@oomworks.com>
11 //=============================================================================
14 #include "test_config.h"
15 #include "ace/Reactor.h"
16 #include "ace/Select_Reactor.h"
17 #include "ace/TP_Reactor.h"
18 #include "ace/WFMO_Reactor.h"
19 #include "ace/Dev_Poll_Reactor.h"
20 #include "ace/Get_Opt.h"
23 static const char message
[] = "abcdefghijklmnopqrstuvwxyz";
24 static const int message_size
= 26;
25 static int test_select_reactor
= 1;
26 static int test_tp_reactor
= 1;
27 static int test_wfmo_reactor
= 1;
28 static int test_dev_poll_reactor
= 1;
29 static int test_io
= 1;
30 static int test_timers
= 1;
31 static int test_find
= 1;
32 static int test_simple_event_handler
= 1;
33 static int test_reference_counted_event_handler_1
= 1;
34 static int test_reference_counted_event_handler_2
= 1;
35 static int test_closed_in_upcall_event_handler
= 1;
37 static const char *one_second_timeout
= "one second timeout";
38 static const char *two_second_timeout
= "two second timeout";
40 class Reference_Counted_Event_Handler
: public ACE_Event_Handler
43 Reference_Counted_Event_Handler (int &events
);
45 ~Reference_Counted_Event_Handler () override
;
47 int handle_input (ACE_HANDLE
) override
;
49 int handle_output (ACE_HANDLE
) override
;
51 int handle_timeout (const ACE_Time_Value
&,
52 const void *) override
;
54 int handle_signal (int, siginfo_t
*, ucontext_t
*) override
;
56 int handle_close (ACE_HANDLE
,
57 ACE_Reactor_Mask
) override
;
59 ACE_Event_Handler::Reference_Count
add_reference () override
;
61 ACE_Event_Handler::Reference_Count
remove_reference () override
;
68 Reference_Counted_Event_Handler::Reference_Counted_Event_Handler (int &events
)
71 if (this->pipe_
.open () != 0)
72 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"), ACE_TEXT ("ctor: pipe open")));
74 this->reference_counting_policy ().value
75 (ACE_Event_Handler::Reference_Counting_Policy::ENABLED
);
78 "Reference count in Reference_Counted_Event_Handler() is %d\n",
79 this->reference_count_
.load ()));
82 Reference_Counted_Event_Handler::~Reference_Counted_Event_Handler ()
85 "Reference count in ~Reference_Counted_Event_Handler() is %d\n",
86 this->reference_count_
.load ()));
92 Reference_Counted_Event_Handler::handle_input (ACE_HANDLE
)
95 "Reference count in Reference_Counted_Event_Handler::handle_input() is %d\n",
96 this->reference_count_
.load ()));
100 char buf
[message_size
+ 1];
103 ACE::recv_n (this->pipe_
.read_handle (),
107 if (result
!= message_size
)
108 ACE_ERROR ((LM_ERROR
,
109 ACE_TEXT ("recv_n expected %d bytes; got %b\n"),
113 buf
[message_size
] = '\0';
115 ACE_DEBUG ((LM_DEBUG
,
116 "Message received: %C\n",
123 Reference_Counted_Event_Handler::handle_output (ACE_HANDLE
)
125 ACE_DEBUG ((LM_DEBUG
,
126 "Reference count in Reference_Counted_Event_Handler::handle_output() is %d\n",
127 this->reference_count_
.load ()));
132 ACE::send_n (this->pipe_
.write_handle (),
136 if (result
!= message_size
)
137 ACE_ERROR ((LM_ERROR
,
138 ACE_TEXT ("send_n sent %b bytes; should be %d\n"),
142 // No longer interested in output.
147 Reference_Counted_Event_Handler::handle_timeout (const ACE_Time_Value
&,
150 ACE_DEBUG ((LM_DEBUG
,
151 "Reference count in Reference_Counted_Event_Handler::handle_timeout() for arg = %C is %d\n",
153 this->reference_count_
.load ()));
161 Reference_Counted_Event_Handler::handle_signal (int,
169 Reference_Counted_Event_Handler::handle_close (ACE_HANDLE handle
,
170 ACE_Reactor_Mask masks
)
172 ACE_DEBUG ((LM_DEBUG
,
173 "Reference_Counted_Event_Handler::handle_close() called with handle = %d and masks = %d. "
174 "Reference count is %d\n",
177 this->reference_count_
.load ()));
182 ACE_Event_Handler::Reference_Count
183 Reference_Counted_Event_Handler::add_reference ()
185 ACE_Event_Handler::Reference_Count reference_count
=
186 this->ACE_Event_Handler::add_reference ();
188 ACE_DEBUG ((LM_DEBUG
,
189 "Reference count after add_reference() is %d\n",
190 this->reference_count_
.load ()));
192 return reference_count
;
195 ACE_Event_Handler::Reference_Count
196 Reference_Counted_Event_Handler::remove_reference ()
198 ACE_Event_Handler::Reference_Count reference_count
=
199 this->ACE_Event_Handler::remove_reference ();
201 ACE_DEBUG ((LM_DEBUG
,
202 "Reference count after remove_reference() is %d\n",
205 return reference_count
;
209 reference_counted_event_handler_test_1 (ACE_Reactor
*reactor
)
214 Reference_Counted_Event_Handler
*handler
=
215 new Reference_Counted_Event_Handler (events
);
217 ACE_Event_Handler_var
safe_handler (handler
);
221 if (-1 == reactor
->register_handler (handler
->pipe_
.read_handle (),
223 ACE_Event_Handler::READ_MASK
))
224 ACE_ERROR ((LM_ERROR
,
225 ACE_TEXT ("line %l %p\n"),
226 ACE_TEXT ("register pipe read")));
230 if (-1 == reactor
->register_handler (handler
->pipe_
.write_handle (),
232 ACE_Event_Handler::WRITE_MASK
))
233 ACE_ERROR ((LM_ERROR
,
234 ACE_TEXT ("line %l %p\n"),
235 ACE_TEXT ("register pipe write")));
242 ACE_Time_Value
const one_second (1);
244 reactor
->schedule_timer (handler
,
249 ACE_ERROR ((LM_ERROR
,
250 ACE_TEXT ("line %l %p\n"),
251 ACE_TEXT ("schedule_timer")));
253 if ((result
= reactor
->cancel_timer (timer_id
, 0, 0)) != 1)
254 ACE_ERROR ((LM_ERROR
,
255 ACE_TEXT ("cancel_timer returned %d; should be 1\n"),
259 reactor
->schedule_timer (handler
,
264 ACE_ERROR ((LM_ERROR
,
265 ACE_TEXT ("line %l %p\n"),
266 ACE_TEXT ("schedule_timer")));
268 events
+= 2; // Wait for the scheduled and one repeating
270 ACE_Time_Value
const two_second (2);
272 reactor
->schedule_timer (handler
,
276 ACE_ERROR ((LM_ERROR
,
277 ACE_TEXT ("line %l %p\n"),
278 ACE_TEXT ("schedule_timer")));
286 reactor
->handle_events ();
291 reference_counted_event_handler_test_2 (ACE_Reactor
*reactor
)
295 ACE_Time_Value
const one_second (1);
299 Reference_Counted_Event_Handler
*handler
=
300 new Reference_Counted_Event_Handler (events
);
302 ACE_Event_Handler_var
safe_handler (handler
);
305 reactor
->register_handler (handler
->pipe_
.read_handle (),
307 ACE_Event_Handler::READ_MASK
);
309 ACE_ERROR ((LM_ERROR
,
310 ACE_TEXT ("line %l %p\n"),
311 ACE_TEXT ("register pipe handler read")));
314 ACE_Event_Handler
*result_handler
= 0;
317 reactor
->handler (handler
->pipe_
.read_handle (),
318 ACE_Event_Handler::READ_MASK
,
320 ACE_Event_Handler_var
safe_result_handler (result_handler
);
323 ACE_ERROR ((LM_ERROR
,
325 ACE_TEXT ("Looking up pipe read handler")));
327 if (result_handler
!= handler
)
328 ACE_ERROR ((LM_ERROR
,
329 ACE_TEXT ("Mismatch: result_handler %@ should be %@\n"),
330 result_handler
, handler
));
334 ACE_Event_Handler
*result_handler
= 0;
337 reactor
->handler (handler
->pipe_
.read_handle (),
338 ACE_Event_Handler::WRITE_MASK
,
340 ACE_Event_Handler_var
safe_result_handler (result_handler
);
343 ACE_ERROR ((LM_ERROR
,
344 ACE_TEXT ("Pipe write handler succeeded but shouldn't")));
348 ACE_Event_Handler_var result_handler
=
349 reactor
->find_handler (handler
->pipe_
.read_handle ());
351 if (result_handler
.handler () != handler
)
352 ACE_ERROR ((LM_ERROR
,
353 ACE_TEXT ("Mismatch 2: result_handler %@ should be %@\n"),
354 result_handler
.handler (), handler
));
360 Reference_Counted_Event_Handler
*handler
=
361 new Reference_Counted_Event_Handler (events
);
363 ACE_Event_Handler_var
safe_handler (handler
);
365 if (-1 == reactor
->register_handler (handler
->pipe_
.read_handle (),
367 ACE_Event_Handler::READ_MASK
))
368 ACE_ERROR ((LM_ERROR
,
369 ACE_TEXT ("line %l %p\n"),
370 ACE_TEXT ("register pipe read")));
374 if (-1 == reactor
->register_handler (handler
->pipe_
.write_handle (),
376 ACE_Event_Handler::WRITE_MASK
))
377 ACE_ERROR ((LM_ERROR
,
378 ACE_TEXT ("line %l %p\n"),
379 ACE_TEXT ("register pipe write")));
386 Reference_Counted_Event_Handler
*handler
=
387 new Reference_Counted_Event_Handler (events
);
389 ACE_Event_Handler_var
safe_handler (handler
);
392 reactor
->schedule_timer (handler
,
397 ACE_ERROR ((LM_ERROR
,
398 ACE_TEXT ("line %l %p\n"),
399 ACE_TEXT ("schedule_timer")));
401 if ((result
= reactor
->cancel_timer (timer_id
, 0, 0)) != 1)
402 ACE_ERROR ((LM_ERROR
,
403 ACE_TEXT ("cancel_timer returned %d; should be 1\n"),
409 Reference_Counted_Event_Handler
*handler
=
410 new Reference_Counted_Event_Handler (events
);
412 ACE_Event_Handler_var
safe_handler (handler
);
415 reactor
->schedule_timer (handler
,
420 ACE_ERROR ((LM_ERROR
,
421 ACE_TEXT ("line %l %p\n"),
422 ACE_TEXT ("schedule_timer")));
424 events
+= 2; // Wait for the scheduled and one repeating
426 ACE_Time_Value
const two_second (2);
428 reactor
->schedule_timer (handler
,
432 ACE_ERROR ((LM_ERROR
,
433 ACE_TEXT ("line %l %p\n"),
434 ACE_TEXT ("schedule_timer")));
442 reactor
->handle_events ();
447 reference_count_1 (ACE_Reactor_Impl
*impl
)
449 ACE_Reactor
reactor (impl
, 1);
451 ACE_DEBUG ((LM_DEBUG
,
452 "\nTesting Reference Counted Event Handler Test 1....\n\n"));
454 reference_counted_event_handler_test_1 (&reactor
);
458 reference_count_2 (ACE_Reactor_Impl
*impl
)
460 ACE_Reactor
reactor (impl
, 1);
462 ACE_DEBUG ((LM_DEBUG
,
463 "\nTesting Reference Counted Event Handler Test 2....\n\n"));
465 reference_counted_event_handler_test_2 (&reactor
);
468 class Simple_Event_Handler
: public ACE_Event_Handler
471 Simple_Event_Handler (int &events
,
474 ~Simple_Event_Handler () override
;
476 int handle_input (ACE_HANDLE
) override
;
478 int handle_output (ACE_HANDLE
) override
;
480 int handle_timeout (const ACE_Time_Value
&,
481 const void *) override
;
483 int handle_signal (int, siginfo_t
*, ucontext_t
*) override
;
485 int handle_close (ACE_HANDLE
, ACE_Reactor_Mask
) override
;
494 Simple_Event_Handler::Simple_Event_Handler (int &events
,
497 close_count_ (close_count
)
499 if (-1 == this->pipe_
.open ())
500 ACE_ERROR ((LM_ERROR
,
502 ACE_TEXT ("Simple_Event_Handler pipe open")));
504 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Simple_Event_Handler()\n")));
507 Simple_Event_Handler::~Simple_Event_Handler ()
509 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("~Simple_Event_Handler()\n")));
511 this->pipe_
.close ();
515 Simple_Event_Handler::handle_input (ACE_HANDLE
)
517 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Simple_Event_Handler::handle_input()\n")));
521 char buf
[message_size
+ 1];
524 ACE::recv_n (this->pipe_
.read_handle (),
527 if (result
!= message_size
)
528 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("line %l recv_n got %b; should be %d\n"),
529 result
, message_size
));
530 buf
[message_size
] = '\0';
532 ACE_DEBUG ((LM_DEBUG
,
533 ACE_TEXT ("Message received: %C\n"),
540 Simple_Event_Handler::handle_output (ACE_HANDLE
)
542 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Simple_Event_Handler::handle_output()\n")));
547 ACE::send_n (this->pipe_
.write_handle (),
550 if (result
!= message_size
)
551 ACE_ERROR ((LM_ERROR
,
552 ACE_TEXT ("line %l send_n sent %b; should be %d\n"),
553 result
, message_size
));
555 // No longer interested in output.
560 Simple_Event_Handler::handle_timeout (const ACE_Time_Value
&,
563 ACE_DEBUG ((LM_DEBUG
,
564 ACE_TEXT ("Simple_Event_Handler::handle_timeout() for arg = %C\n"),
565 (const char *) arg
));
573 Simple_Event_Handler::handle_signal (int,
581 Simple_Event_Handler::handle_close (ACE_HANDLE handle
,
582 ACE_Reactor_Mask masks
)
584 ACE_DEBUG ((LM_DEBUG
,
585 ACE_TEXT ("Simple_Event_Handler::handle_close() called with ")
586 ACE_TEXT ("handle = %d and masks = %d with close count = %d.\n"),
589 --this->close_count_
));
591 if (this->close_count_
== 0)
598 simple_event_handler (ACE_Reactor
*reactor
)
602 ACE_Time_Value
const one_second (1);
606 Simple_Event_Handler
handler (events
,
610 reactor
->register_handler (handler
.pipe_
.read_handle (),
612 ACE_Event_Handler::READ_MASK
);
614 ACE_ERROR ((LM_ERROR
,
615 ACE_TEXT ("line %l %p\n"),
616 ACE_TEXT ("register pipe handler read")));
619 ACE_Event_Handler
*result_handler
= 0;
622 reactor
->handler (handler
.pipe_
.read_handle (),
623 ACE_Event_Handler::READ_MASK
,
625 ACE_Event_Handler_var
safe_result_handler (result_handler
);
627 ACE_ERROR ((LM_ERROR
,
629 ACE_TEXT ("Looking up pipe read handler")));
631 if (result_handler
!= &handler
)
632 ACE_ERROR ((LM_ERROR
,
633 ACE_TEXT ("Mismatch: result_handler %@ should be %@\n"),
634 result_handler
, &handler
));
638 ACE_Event_Handler
*result_handler
= 0;
641 reactor
->handler (handler
.pipe_
.read_handle (),
642 ACE_Event_Handler::WRITE_MASK
,
644 ACE_Event_Handler_var
safe_result_handler (result_handler
);
646 ACE_ERROR ((LM_ERROR
,
647 ACE_TEXT ("line %l handler() suceeded but shouldn't\n")));
651 ACE_Event_Handler_var result_handler
=
652 reactor
->find_handler (handler
.pipe_
.read_handle ());
653 if (result_handler
.handler () != &handler
)
654 ACE_ERROR ((LM_ERROR
,
655 ACE_TEXT ("Mismatch: line %l: result_handler.handler %@ ")
656 ACE_TEXT ("should be %@\n"),
657 result_handler
.handler (), &handler
));
661 reactor
->remove_handler (handler
.pipe_
.read_handle (),
662 ACE_Event_Handler::ALL_EVENTS_MASK
| ACE_Event_Handler::DONT_CALL
);
664 ACE_ERROR ((LM_ERROR
,
665 ACE_TEXT ("line %l: %p\n"),
666 ACE_TEXT ("remove_handler")));
671 Simple_Event_Handler
*handler
=
672 new Simple_Event_Handler (events
,
675 if (-1 == reactor
->register_handler (handler
->pipe_
.read_handle (),
677 ACE_Event_Handler::READ_MASK
))
678 ACE_ERROR ((LM_ERROR
,
679 ACE_TEXT ("line %l %p\n"),
680 ACE_TEXT ("register pipe read")));
684 if (-1 == reactor
->register_handler (handler
->pipe_
.write_handle (),
686 ACE_Event_Handler::WRITE_MASK
))
687 ACE_ERROR ((LM_ERROR
,
688 ACE_TEXT ("line %l %p\n"),
689 ACE_TEXT ("register pipe write")));
696 Simple_Event_Handler
*handler
=
697 new Simple_Event_Handler (events
,
701 reactor
->schedule_timer (handler
,
706 ACE_ERROR ((LM_ERROR
,
707 ACE_TEXT ("line %l %p\n"),
708 ACE_TEXT ("schedule_timer")));
710 if ((result
= reactor
->cancel_timer (timer_id
, 0, 0)) != 1)
711 ACE_ERROR ((LM_ERROR
,
712 ACE_TEXT ("cancel_timer returned %d; should be 1\n"),
718 Simple_Event_Handler
*handler
=
719 new Simple_Event_Handler (events
,
723 reactor
->schedule_timer (handler
,
728 ACE_ERROR ((LM_ERROR
,
729 ACE_TEXT ("line %l %p\n"),
730 ACE_TEXT ("schedule_timer")));
732 events
+= 2; // Wait for the scheduled and one repeating
734 ACE_Time_Value
const two_second (2);
736 reactor
->schedule_timer (handler
,
740 ACE_ERROR ((LM_ERROR
,
741 ACE_TEXT ("line %l %p\n"),
742 ACE_TEXT ("schedule_timer")));
750 reactor
->handle_events ();
755 simple (ACE_Reactor_Impl
*impl
)
757 ACE_Reactor
reactor (impl
, 1);
759 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\nTesting Simple Event Handler....\n\n")));
761 simple_event_handler (&reactor
);
764 class Closed_In_Upcall_Event_Handler
: public ACE_Event_Handler
767 Closed_In_Upcall_Event_Handler (int &events
);
769 ~Closed_In_Upcall_Event_Handler () override
;
771 int handle_input (ACE_HANDLE
) override
;
773 int handle_close (ACE_HANDLE
,
774 ACE_Reactor_Mask
) override
;
776 ACE_Event_Handler::Reference_Count
add_reference () override
;
778 ACE_Event_Handler::Reference_Count
remove_reference () override
;
785 Closed_In_Upcall_Event_Handler::Closed_In_Upcall_Event_Handler (int &events
)
788 if (-1 == this->pipe_
.open ())
789 ACE_ERROR ((LM_ERROR
,
791 ACE_TEXT ("Closed_In_Upcall_Event_Handler pipe open")));
793 this->reference_counting_policy ().value
794 (ACE_Event_Handler::Reference_Counting_Policy::ENABLED
);
796 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Closed_In_Upcall_Event_Handler()\n")));
799 Closed_In_Upcall_Event_Handler::~Closed_In_Upcall_Event_Handler ()
801 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("~Closed_In_Upcall_Event_Handler()\n")));
803 this->pipe_
.close ();
807 Closed_In_Upcall_Event_Handler::handle_input (ACE_HANDLE
)
809 ACE_DEBUG ((LM_DEBUG
,
810 ACE_TEXT ("Closed_In_Upcall_Event_Handler::handle_input()\n")));
814 if (0 != this->reactor ()->remove_handler (this->pipe_
.read_handle (),
815 ACE_Event_Handler::ALL_EVENTS_MASK
))
816 ACE_ERROR ((LM_ERROR
,
817 ACE_TEXT ("line %l %p\n"),
818 ACE_TEXT ("remove_handler")));
820 char buf
[message_size
+ 1];
822 ssize_t recv_result
=
823 ACE::recv_n (this->pipe_
.read_handle (),
827 if (recv_result
!= message_size
)
828 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("line %l recv_n got %b; should be %d\n"),
829 recv_result
, message_size
));
831 buf
[message_size
] = '\0';
833 ACE_DEBUG ((LM_DEBUG
,
834 ACE_TEXT ("Message received: %C\n"),
841 Closed_In_Upcall_Event_Handler::handle_close (ACE_HANDLE handle
,
842 ACE_Reactor_Mask masks
)
844 ACE_DEBUG ((LM_DEBUG
,
845 ACE_TEXT ("Closed_In_Upcall_Event_Handler::handle_close() ")
846 ACE_TEXT ("called with handle = %d and masks = %d. ")
847 ACE_TEXT ("Reference count is %d\n"),
850 this->reference_count_
.load ()));
855 ACE_Event_Handler::Reference_Count
856 Closed_In_Upcall_Event_Handler::add_reference ()
858 ACE_Event_Handler::Reference_Count reference_count
=
859 this->ACE_Event_Handler::add_reference ();
861 ACE_DEBUG ((LM_DEBUG
,
862 ACE_TEXT ("Reference count after add_reference() is %d\n"),
863 this->reference_count_
.load ()));
865 return reference_count
;
868 ACE_Event_Handler::Reference_Count
869 Closed_In_Upcall_Event_Handler::remove_reference ()
871 ACE_Event_Handler::Reference_Count reference_count
=
872 this->ACE_Event_Handler::remove_reference ();
874 ACE_DEBUG ((LM_DEBUG
,
875 ACE_TEXT ("Reference count after remove_reference() is %d\n"),
878 return reference_count
;
882 closed_in_upcall_event_handler (ACE_Reactor
*reactor
)
888 Closed_In_Upcall_Event_Handler
*handler
= 0;
889 ACE_NEW (handler
, Closed_In_Upcall_Event_Handler (events
));
891 ACE_Event_Handler_var
safe_handler (handler
);
893 ssize_t send_n_result
=
894 ACE::send_n (handler
->pipe_
.write_handle (),
898 if (send_n_result
!= message_size
)
899 ACE_ERROR ((LM_ERROR
,
900 ACE_TEXT ("line %l send_n sent %b; should be %d\n"),
901 send_n_result
, message_size
));
903 if (-1 == reactor
->register_handler (handler
->pipe_
.read_handle (),
905 ACE_Event_Handler::READ_MASK
))
906 ACE_ERROR ((LM_ERROR
,
907 ACE_TEXT ("line %l %p\n"),
908 ACE_TEXT ("register_handler")));
915 int handle_events_result
=
916 reactor
->handle_events ();
917 ACE_UNUSED_ARG (handle_events_result
);
922 closed_in_upcall (ACE_Reactor_Impl
*impl
)
924 ACE_Reactor
reactor (impl
, 1);
926 ACE_DEBUG ((LM_DEBUG
,
927 ACE_TEXT ("\nTesting Closed in Upcall Event Handler....\n\n")));
929 closed_in_upcall_event_handler (&reactor
);
932 template <class REACTOR_IMPLEMENTATION
>
939 template <class REACTOR_IMPLEMENTATION
>
940 test
<REACTOR_IMPLEMENTATION
>::test ()
942 if (test_simple_event_handler
)
943 simple (new REACTOR_IMPLEMENTATION
);
945 if (test_reference_counted_event_handler_1
)
946 reference_count_1 (new REACTOR_IMPLEMENTATION
);
948 if (test_reference_counted_event_handler_2
)
949 reference_count_2 (new REACTOR_IMPLEMENTATION
);
951 if (test_closed_in_upcall_event_handler
)
952 closed_in_upcall (new REACTOR_IMPLEMENTATION
);
956 parse_args (int argc
, ACE_TCHAR
*argv
[])
958 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT ("a:b:c:d:f:g:h:i:k:l:m:z:"));
961 while ((cc
= get_opt ()) != -1)
966 test_select_reactor
= ACE_OS::atoi (get_opt
.opt_arg ());
969 test_tp_reactor
= ACE_OS::atoi (get_opt
.opt_arg ());
972 test_wfmo_reactor
= ACE_OS::atoi (get_opt
.opt_arg ());
975 test_dev_poll_reactor
= ACE_OS::atoi (get_opt
.opt_arg ());
978 test_simple_event_handler
= ACE_OS::atoi (get_opt
.opt_arg ());
981 test_reference_counted_event_handler_1
= ACE_OS::atoi (get_opt
.opt_arg ());
984 test_reference_counted_event_handler_2
= ACE_OS::atoi (get_opt
.opt_arg ());
987 test_closed_in_upcall_event_handler
= ACE_OS::atoi (get_opt
.opt_arg ());
990 test_io
= ACE_OS::atoi (get_opt
.opt_arg ());
993 test_timers
= ACE_OS::atoi (get_opt
.opt_arg ());
996 test_find
= ACE_OS::atoi (get_opt
.opt_arg ());
999 debug
= ACE_OS::atoi (get_opt
.opt_arg ());
1003 ACE_ERROR ((LM_ERROR
,
1004 ACE_TEXT ("\nusage: %s \n\n")
1005 ACE_TEXT ("\t[-a test Select Reactor] (defaults to %d)\n")
1006 ACE_TEXT ("\t[-b test TP Reactor] (defaults to %d)\n")
1007 ACE_TEXT ("\t[-c test WFMO Reactor] (defaults to %d)\n")
1008 ACE_TEXT ("\t[-d test Dev Poll Reactor] (defaults to %d)\n")
1009 ACE_TEXT ("\t[-f test simple event handler] (defaults to %d)\n")
1010 ACE_TEXT ("\t[-g test reference counted event handler (first test)] (defaults to %d)\n")
1011 ACE_TEXT ("\t[-h test reference counted event handler (second test)] (defaults to %d)\n")
1012 ACE_TEXT ("\t[-i test closed in upcall event handler] (defaults to %d)\n")
1013 ACE_TEXT ("\t[-k test io] (defaults to %d)\n")
1014 ACE_TEXT ("\t[-l test timers] (defaults to %d)\n")
1015 ACE_TEXT ("\t[-m test find] (defaults to %d)\n")
1016 ACE_TEXT ("\t[-z debug] (defaults to %d)\n")
1019 test_select_reactor
,
1022 test_dev_poll_reactor
,
1023 test_simple_event_handler
,
1024 test_reference_counted_event_handler_1
,
1025 test_reference_counted_event_handler_2
,
1026 test_closed_in_upcall_event_handler
,
1039 run_main (int argc
, ACE_TCHAR
*argv
[])
1041 ACE_START_TEST (ACE_TEXT ("Reference_Counted_Event_Handler_Test"));
1043 // Validate options.
1045 parse_args (argc
, argv
);
1049 if (test_select_reactor
)
1051 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n\nTesting Select Reactor....\n\n")));
1053 test
<ACE_Select_Reactor
> test
;
1054 ACE_UNUSED_ARG (test
);
1057 if (test_tp_reactor
)
1059 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n\nTesting TP Reactor....\n\n")));
1061 test
<ACE_TP_Reactor
> test
;
1062 ACE_UNUSED_ARG (test
);
1065 #if defined (ACE_WIN32) && \
1066 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
1068 if (test_wfmo_reactor
)
1070 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n\nTesting WFMO Reactor....\n\n")));
1072 test
<ACE_WFMO_Reactor
> test
;
1073 ACE_UNUSED_ARG (test
);
1076 #endif /* ACE_WIN32 && ACE_HAS_WINSOCK2 */
1078 #if defined (ACE_HAS_DEV_POLL) || defined (ACE_HAS_EVENT_POLL)
1080 if (test_dev_poll_reactor
)
1082 ACE_DEBUG ((LM_DEBUG
,
1083 ACE_TEXT ("\n\nTesting ACE_Dev_Poll_Reactor....\n\n")));
1085 test
<ACE_Dev_Poll_Reactor
> test
;
1086 ACE_UNUSED_ARG (test
);
1089 #endif /* ACE_HAS_DEV_POLL || ACE_HAS_EVENT_POLL */