1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 use lib
"$ENV{ACE_ROOT}/bin";
8 use PerlACE
::TestTarget
;
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);
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");
47 $CL->Arguments ("-k file://$client_iorfile " . $args);
49 my $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 185);
51 if ($client_status != 0) {
53 print STDERR
"ERROR: client returned $client_status at $time\n";
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");
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";
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);
136 if ($server->GetFile ($iorbase) == -1) {
137 print STDERR
"ERROR: cannot retrieve file <$server_iorfile>\n";
138 $SV->Kill (); $SV->TimedWait (1);
142 if ($client->PutFile ($iorbase) == -1) {
143 print STDERR
"ERROR: cannot set file <$client_iorfile>\n";
144 $SV->Kill (); $SV->TimedWait (1);
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";
158 $server->DeleteFile($iorbase);
159 $client->DeleteFile($iorbase);
165 for ($i = 0; $i <= $#ARGV; $i++) {
166 if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") {
167 print "run_test [-m] -[a]\n";
169 print "-m -- tests the multithreaded server (default is single)\n";
170 print "-a -- tests both multi and single threaded servers\n";
173 elsif ($ARGV[$i] eq "-m") {
177 elsif ($ARGV[$i] eq "-a") {
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);
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);
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);
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);
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) {
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) {