Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / examples / Quoter / run_test.pl
blobdb66b060116f17d3f174b0eb57832b3d73354d68
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 # number of threads to use for multithreaded clients or servers
15 $num_threads = 4;
17 # amount of delay between running the servers
19 $sleeptime = 15;
21 # other variables
23 $n = 1;
24 $debug = "";
25 $cm = "";
26 $sm = "";
28 # Parse the arguments
30 for ($i = 0; $i <= $#ARGV; $i++) {
31 if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") {
32 print "run_test [-n num] [-d level] [-h] [-nt] [-cm] [-sm]\n";
33 print "\n";
34 print "-n num -- runs the client num times\n";
35 print "-d level -- runs each at debug level <level>\n";
36 print "-h -- prints this information\n";
37 print "-nt num -- number of threads in the client (twice for server)\n";
38 print " make sure this is before any -cm or -sm\n";
39 print "-cm -- use more than one thread in the client\n";
40 print "-sm -- use more than one thread in the server\n";
41 print "-debug -- runs server with -ORBDebugLevel 10\n";
42 exit;
44 elsif ($ARGV[$i] eq "-n") {
45 $n = $ARGV[$i + 1];
46 $i++;
48 elsif ($ARGV[$i] eq "-nt") {
49 $num_threads = $ARGV[$i + 1];
50 $i++;
52 elsif ($ARGV[$i] eq "-debug") {
53 $debug = $debug." -d $ARGV[$i + 1]";
54 $i++;
56 elsif ($ARGV[$i] eq "-cm") {
57 $cm = "-n ".$num_threads;
59 elsif ($ARGV[$i] eq "-sm") {
60 $sm = "-n ".($num_threads * 3);
62 elsif ($ARGV[$i] eq "-debug") {
63 $debug_level = '10';
67 my $nstarget = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
68 my $lctarget = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
69 my $svtarget = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
70 my $fftarget = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
71 my $gftarget = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
72 my $cltarget = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
74 my $nsiorbase = "ns.ior";
75 my $nstarget_nsiorfile = $nstarget->LocalFile ($nsiorbase);
76 my $lctarget_nsiorfile = $lctarget->LocalFile ($nsiorbase);
77 my $svtarget_nsiorfile = $svtarget->LocalFile ($nsiorbase);
78 my $fftarget_nsiorfile = $fftarget->LocalFile ($nsiorbase);
79 my $gftarget_nsiorfile = $gftarget->LocalFile ($nsiorbase);
80 my $cltarget_nsiorfile = $cltarget->LocalFile ($nsiorbase);
81 $nstarget->DeleteFile($nsiorbase);
82 $lctarget->DeleteFile($nsiorbase);
83 $svtarget->DeleteFile($nsiorbase);
84 $fftarget->DeleteFile($nsiorbase);
85 $gftarget->DeleteFile($nsiorbase);
86 $cltarget->DeleteFile($nsiorbase);
88 # Programs that are run
90 $NS = $nstarget->CreateProcess (
91 "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
92 "-o $nstarget_nsiorfile");
93 $LC = $lctarget->CreateProcess (
94 "$ENV{TAO_ROOT}/orbsvcs/LifeCycle_Service/tao_coslifecycle",
95 "$debug -ORBInitRef NameService=file://$lctarget_nsiorfile");
97 $SV = $svtarget->CreateProcess (
98 "server",
99 "$debug $sm -ORBDebugLevel $debug_level ".
100 "-ORBInitRef NameService=file://$svtarget_nsiorfile");
101 $FF = $fftarget->CreateProcess (
102 "Factory_Finder",
103 "$debug -ORBInitRef NameService=file://$fftarget_nsiorfile");
104 $GF = $gftarget->CreateProcess (
105 "Generic_Factory",
106 "-l $debug -ORBInitRef NameService=file://$gftarget_nsiorfile");
107 $CL = $cltarget->CreateProcess (
108 "client",
109 "-l $debug $cm -ORBInitRef NameService=file://$cltarget_nsiorfile");
111 $ns_status = $NS->Spawn ();
113 if ($ns_status != 0) {
114 print STDERR "ERROR: tao_cosnaming returned $ns_status\n";
115 exit 1;
118 if ($nstarget->WaitForFileTimed ($nsiorbase,
119 $nstarget->ProcessStartWaitInterval()) == -1) {
120 print STDERR "ERROR: cannot find file <$nstarget_nsiorfile>\n";
121 $NS->Kill (); $NS->TimedWait (1);
122 exit 1;
124 if ($nstarget->GetFile ($nsiorbase) == -1) {
125 print STDERR "ERROR: cannot retrieve file <$nstarget_nsiorfile>\n";
126 $NS->Kill (); $NS->TimedWait (1);
127 exit 1;
129 if ($lctarget->PutFile ($nsiorbase) == -1) {
130 print STDERR "ERROR: cannot set file <$lctarget_nsiorfile>\n";
131 $NS->Kill (); $NS->TimedWait (1);
132 exit 1;
134 if ($svtarget->PutFile ($nsiorbase) == -1) {
135 print STDERR "ERROR: cannot set file <$svtarget_nsiorfile>\n";
136 $NS->Kill (); $NS->TimedWait (1);
137 exit 1;
139 if ($fftarget->PutFile ($nsiorbase) == -1) {
140 print STDERR "ERROR: cannot set file <$fftarget_nsiorfile>\n";
141 $NS->Kill (); $NS->TimedWait (1);
142 exit 1;
144 if ($gftarget->PutFile ($nsiorbase) == -1) {
145 print STDERR "ERROR: cannot set file <$gftarget_nsiorfile>\n";
146 $NS->Kill (); $NS->TimedWait (1);
147 exit 1;
149 if ($cltarget->PutFile ($nsiorbase) == -1) {
150 print STDERR "ERROR: cannot set file <$cltarget_nsiorfile>\n";
151 $NS->Kill (); $NS->TimedWait (1);
152 exit 1;
155 $lc_status = $LC->Spawn ();
157 if ($lc_status != 0) {
158 print STDERR "ERROR: tao_coslifecycle returned $lc_status\n";
159 $NS->Kill (); $NS->TimedWait (1);
160 exit 1;
162 sleep $sleeptime;
164 $sv_status = $SV->Spawn ();
166 if ($sv_status != 0) {
167 print STDERR "ERROR: server returned $sv_status\n";
168 $NS->Kill (); $NS->TimedWait (1);
169 $LC->Kill (); $LC->TimedWait (1);
170 exit 1;
172 sleep $sleeptime;
174 $ff_status = $FF->Spawn ();
176 if ($ff_status != 0) {
177 print STDERR "ERROR: Factory_Finder returned $ff_status\n";
178 $NS->Kill (); $NS->TimedWait (1);
179 $LC->Kill (); $LC->TimedWait (1);
180 $SV->Kill (); $SV->TimedWait (1);
181 exit 1;
183 sleep $sleeptime;
185 $gf_status = $GF->Spawn ();
187 if ($gf_status != 0) {
188 print STDERR "ERROR: Generic_Factory returned $gf_status\n";
189 $NS->Kill (); $NS->TimedWait (1);
190 $LC->Kill (); $LC->TimedWait (1);
191 $SV->Kill (); $SV->TimedWait (1);
192 $FF->Kill (); $FF->TimedWait (1);
193 exit 1;
195 sleep $sleeptime;
197 for ($j = 1; $j <= $n; ++$j) {
198 $cl_status =
199 $CL->SpawnWaitKill ($cltarget->ProcessStartWaitInterval() + 45);
201 if ($cl_status != 0) {
202 print STDERR "ERROR: client returned $cl_status\n";
203 $NS->Kill (); $NS->TimedWait (1);
204 $LC->Kill (); $LC->TimedWait (1);
205 $SV->Kill (); $SV->TimedWait (1);
206 $FF->Kill (); $FF->TimedWait (1);
207 $GF->Kill (); $GF->TimedWait (1);
208 exit 1;
212 $gf_status = $GF->TerminateWaitKill ($gftarget->ProcessStopWaitInterval());
214 if ($gf_status != 0) {
215 print STDERR "ERROR: Generic_Factory returned $gf_status\n";
216 $status = 1;
219 $ff_status = $FF->TerminateWaitKill ($fftarget->ProcessStopWaitInterval());
221 if ($ff_status != 0) {
222 print STDERR "ERROR: Factory_Finder returned $ff_status\n";
223 $status = 1;
226 $sv_status = $SV->TerminateWaitKill ($svtarget->ProcessStopWaitInterval());
228 if ($sv_status != 0) {
229 print STDERR "ERROR: server returned $sv_status\n";
230 $status = 1;
233 $lc_status = $LC->TerminateWaitKill ($lctarget->ProcessStopWaitInterval());
235 if ($lc_status != 0) {
236 print STDERR "ERROR: tao_coslifecycle returned $lc_status\n";
237 $status = 1;
240 $ns_status = $NS->TerminateWaitKill ($nstarget->ProcessStopWaitInterval());
242 if ($ns_status != 0) {
243 print STDERR "ERROR: tao_cosnaming returned $ns_status\n";
244 $status = 1;
247 $nstarget->DeleteFile($nsiorbase);
248 $lctarget->DeleteFile($nsiorbase);
249 $svtarget->DeleteFile($nsiorbase);
250 $fftarget->DeleteFile($nsiorbase);
251 $gftarget->DeleteFile($nsiorbase);
252 $cltarget->DeleteFile($nsiorbase);
254 exit $status;