Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Leader_Followers / run_test.pl
blob5a59eb4078b44c8e7df5e8255e222e04e31f11ad
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
5 # -*- perl -*-
7 use lib "$ENV{ACE_ROOT}/bin";
8 use PerlACE::TestTarget;
10 $status = 0;
11 $debug_level = '0';
13 foreach $i (@ARGV) {
14 if ($i eq '-debug') {
15 $debug_level = '10';
19 my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
22 my $iorbase = "lf.ior";
23 my $tp_conf_base = "tp$PerlACE::svcconf_ext";
24 my $select_mt_conf_base = "select_mt$PerlACE::svcconf_ext";
26 # init server configuration files
27 my $server_tp_conf_file = $server->LocalFile ($tp_conf_base);
28 my $server_select_mt_conf_file = $server->LocalFile ($select_mt_conf_base);
30 # init client configuration files
31 my $client_tp_conf_file = $client->LocalFile ($tp_conf_base);
32 my $client_select_mt_conf_file = $client->LocalFile ($select_mt_conf_base);
34 # init ior files
35 my $server_iorfile = $server->LocalFile ($iorbase);
36 my $client_iorfile = $client->LocalFile ($iorbase);
37 $server->DeleteFile($iorbase);
38 $client->DeleteFile($iorbase);
40 $SV = $server->CreateProcess ("server");
41 $CL = $client->CreateProcess ("client");
43 sub run_client ($)
45 my $args = shift;
47 $CL->Arguments ("-k file://$client_iorfile " . $args);
49 my $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 185);
51 if ($client_status != 0) {
52 my $time = localtime;
53 print STDERR "ERROR: client returned $client_status at $time\n";
54 $status = 1;
58 sub run_clients ()
60 print STDERR "\n\n*** No event loop threads ***\n\n\n";
62 print STDERR "\nSelect Reactor\n\n";
64 run_client ("-ORBsvcconf $client_select_mt_conf_file -e 0");
66 print STDERR "\nTP Reactor\n\n";
68 run_client ("-ORBsvcconf $client_tp_conf_file -e 0");
70 print STDERR "\n\n*** Single-threaded client event loop: Select Reactor ***\n\n\n";
72 print STDERR "\nSingle-threaded client running event loop for 3 seconds\n\n";
74 run_client ("-ORBsvcconf $client_select_mt_conf_file -e 1 -t 3000");
76 print STDERR "\nSingle-threaded client running event loop for 10 seconds\n\n";
78 run_client ("-ORBsvcconf $client_select_mt_conf_file -e 1 -t 10000");
80 print STDERR "\nSingle-threaded client running event loop for 20 seconds\n\n";
82 run_client ("-ORBsvcconf $client_select_mt_conf_file -e 1 -t 20000");
84 print STDERR "\n\n*** Single-threaded client event loop: TP Reactor ***\n\n\n";
86 print STDERR "\nSingle-threaded client running event loop for 3 seconds\n\n";
88 run_client ("-ORBsvcconf $client_tp_conf_file -e 1 -t 3000");
90 print STDERR "\nSingle-threaded client running event loop for 10 seconds\n\n";
92 run_client ("-ORBsvcconf $client_tp_conf_file -e 1 -t 10000");
94 print STDERR "\nSingle-threaded client running event loop for 20 seconds\n\n";
96 run_client ("-ORBsvcconf $client_tp_conf_file -e 1 -t 20000");
98 print STDERR "\n\n*** Multi-threaded client event loop: TP Reactor ***\n\n\n";
100 print STDERR "\nMulti-threaded client running event loop for 3 seconds\n\n";
102 run_client ("-ORBsvcconf $client_tp_conf_file -e 5 -t 3000");
104 print STDERR "\nMulti-threaded client running event loop for 10 seconds\n\n";
106 run_client ("-ORBsvcconf $client_tp_conf_file -e 5 -t 10000");
108 print STDERR "\nMulti-threaded client running event loop for 20 seconds\n\n";
110 run_client ("-ORBsvcconf $client_tp_conf_file -e 5 -t 20000 -x");
113 sub run_server ($)
115 my $args = shift;
117 $server->DeleteFile($iorbase);
118 $client->DeleteFile($iorbase);
120 $SV->Arguments ("-o $server_iorfile " . $args);
122 my $server_status = $SV->Spawn ();
124 if ($server_status != 0) {
125 print STDERR "ERROR: server returned $server_status\n";
126 return 1;
129 if ($server->WaitForFileTimed ($iorbase,
130 $server->ProcessStartWaitInterval()) == -1) {
131 print STDERR "ERROR: cannot find file <$server_iorfile>\n";
132 $SV->Kill (); $SV->TimedWait (1);
133 return 1;
136 if ($server->GetFile ($iorbase) == -1) {
137 print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
138 $SV->Kill (); $SV->TimedWait (1);
139 return 1;
142 if ($client->PutFile ($iorbase) == -1) {
143 print STDERR "ERROR: cannot set file <$client_iorfile>\n";
144 $SV->Kill (); $SV->TimedWait (1);
145 return 1;
148 run_clients ();
150 $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 85);
152 if ($server_status != 0) {
153 my $time = localtime;
154 print STDERR "ERROR: server returned $server_status at $time\n";
155 $status = 1;
158 $server->DeleteFile($iorbase);
159 $client->DeleteFile($iorbase);
162 my $single = 1;
163 my $multi = 0;
165 for ($i = 0; $i <= $#ARGV; $i++) {
166 if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") {
167 print "run_test [-m] -[a]\n";
168 print "\n";
169 print "-m -- tests the multithreaded server (default is single)\n";
170 print "-a -- tests both multi and single threaded servers\n";
171 exit 0;
173 elsif ($ARGV[$i] eq "-m") {
174 $multi = 1;
175 $single = 0;
177 elsif ($ARGV[$i] eq "-a") {
178 $multi = 1;
179 $single = 1;
183 # Copy configuration files to the targets
184 if ($server->PutFile ($tp_conf_base) == -1) {
185 print STDERR "ERROR: cannot set file <$server_tp_conf_file>\n";
186 $SV->Kill (); $SV->TimedWait (1);
187 return 1;
189 if ($server->PutFile ($select_mt_conf_base) == -1) {
190 print STDERR "ERROR: cannot set file <$server_select_mt_conf_file>\n";
191 $SV->Kill (); $SV->TimedWait (1);
192 return 1;
195 if ($client->PutFile ($tp_conf_base) == -1) {
196 print STDERR "ERROR: cannot set file <$client_tp_conf_file>\n";
197 $SV->Kill (); $SV->TimedWait (1);
198 return 1;
200 if ($client->PutFile ($select_mt_conf_base) == -1) {
201 print STDERR "ERROR: cannot set file <$client_select_mt_conf_file>\n";
202 $SV->Kill (); $SV->TimedWait (1);
203 return 1;
206 if ($single == 1) {
207 print STDERR "\n\n*** Single threaded server ***\n\n\n";
208 $run_status = run_server("-ORBsvcconf $server_select_mt_conf_file");
209 if ($run_status != 0) {
210 exit 1;
214 if ($multi == 1) {
215 print STDERR "\n\n*** Thread-Pool server ***\n\n\n";
216 $run_status = run_server("-e 5 -ORBsvcconf $server_tp_conf_file");
217 if ($run_status != 0) {
218 exit 1;
222 exit $status;