Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / examples / RtEC / IIOPGateway / consumerec_crash.pl
blob93b5ff39278baf767e23c05978f25ab2ad499b9e
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 $ns = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $t1 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
21 my $t2 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $g = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 my $c = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 my $s = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
26 $nsiorfile = "ns.ior";
27 $conffile = "ec" . "$PerlACE::svcconf_ext";
28 $gconffile = "gateway" . "$PerlACE::svcconf_ext";
30 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
31 my $t1_nsiorfile = $t1->LocalFile ($nsiorfile);
32 my $t2_nsiorfile = $t2->LocalFile ($nsiorfile);
33 my $g_nsiorfile = $g->LocalFile ($nsiorfile);
34 my $c_nsiorfile = $c->LocalFile ($nsiorfile);
35 my $s_nsiorfile = $s->LocalFile ($nsiorfile);
36 my $t1_conffile = $t1->LocalFile ($conffile);
37 my $t2_conffile = $t2->LocalFile ($conffile);
38 my $g_gconffile = $g->LocalFile ($gconffile);
39 $ns->DeleteFile ($nsiorfile);
40 $t1->DeleteFile ($nsiorfile);
41 $t2->DeleteFile ($nsiorfile);
42 $g->DeleteFile ($nsiorfile);
43 $c->DeleteFile ($nsiorfile);
44 $s->DeleteFile ($nsiorfile);
46 $NS = $ns->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
47 " -o $ns_nsiorfile");
49 $T1 = $t1->CreateProcess ("EC",
50 " -ORBInitRef NameService=file://$t1_nsiorfile ".
51 "-ORBsvcconf $t1_conffile ".
52 "-e channel1");
54 $T2 = $t2->CreateProcess ("EC",
55 " -ORBInitRef NameService=file://$t2_nsiorfile ".
56 "-ORBsvcconf $t2_conffile ".
57 "-e channel2");
59 $G = $g->CreateProcess ("Gateway",
60 " -ORBInitRef NameService=file://$g_nsiorfile ".
61 "-ORBSvcconf $g_gconffile ".
62 "-c channel2 ".
63 "-s channel1");
65 $C = $c->CreateProcess ("Consumer",
66 " -ORBInitRef NameService=file://$c_nsiorfile ".
67 "-ORBDebugLevel $debug_level ".
68 "-e channel2");
70 $S = $s->CreateProcess ("Supplier",
71 " -ORBInitRef NameService=file://$s_nsiorfile ".
72 "-e channel1");
74 print STDOUT "Starting name server\n";
75 $NS_status = $NS->Spawn ();
77 if ($NS_status != 0) {
78 print STDERR "ERROR: Name Service returned $NS_status\n";
79 exit 1;
82 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
83 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
84 $NS->Kill (); $NS->TimedWait (1);
85 exit 1;
88 if ($ns->GetFile ($nsiorfile) == -1) {
89 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
90 $NS->Kill (); $NS->TimedWait (1);
91 exit 1;
93 if ($t1->PutFile ($nsiorfile) == -1) {
94 print STDERR "ERROR: cannot set file <$t1_nsiorfile>\n";
95 $NS->Kill (); $NS->TimedWait (1);
96 exit 1;
98 if ($t2->PutFile ($nsiorfile) == -1) {
99 print STDERR "ERROR: cannot set file <$t2_nsiorfile>\n";
100 $NS->Kill (); $NS->TimedWait (1);
101 exit 1;
103 if ($g->PutFile ($nsiorfile) == -1) {
104 print STDERR "ERROR: cannot set file <$g_nsiorfile>\n";
105 $NS->Kill (); $NS->TimedWait (1);
106 exit 1;
108 if ($c->PutFile ($nsiorfile) == -1) {
109 print STDERR "ERROR: cannot set file <$c_nsiorfile>\n";
110 $NS->Kill (); $NS->TimedWait (1);
111 exit 1;
113 if ($s->PutFile ($nsiorfile) == -1) {
114 print STDERR "ERROR: cannot set file <$s_nsiorfile>\n";
115 $NS->Kill (); $NS->TimedWait (1);
116 exit 1;
119 print STDOUT "Starting event channel 1\n";
120 $T1_status = $T1->Spawn ();
122 if ($T1_status != 0) {
123 print STDERR "ERROR: T1 returned $T1_status\n";
124 exit 1;
127 sleep 2;
129 print STDOUT "Starting event channel 2\n";
130 $T2_status = $T2->Spawn ();
132 if ($T2_status != 0) {
133 print STDERR "ERROR: T2 returned $T2_status\n";
134 exit 1;
137 sleep 2;
139 print STDOUT "Starting gateway\n";
140 $G_status = $G->Spawn ();
142 if ($G_status != 0) {
143 print STDERR "ERROR: Gateway returned $G_status\n";
144 exit 1;
147 sleep 2;
149 print STDOUT "Starting consumer\n";
150 $C_status = $C->Spawn ();
152 if ($C_status != 0) {
153 print STDERR "ERROR: Consumer returned $C_status\n";
154 exit 1;
157 sleep 1;
159 print STDOUT "Starting supplier\n";
160 $S_status = $S->Spawn ();
162 if ($S_status != 0) {
163 print STDERR "ERROR: Supplier returned $S_status\n";
164 exit 1;
167 sleep 1;
170 if ($supplier != 0) {
171 print STDERR "ERROR: supplier returned $supplier\n";
172 $status = 1;
175 print STDOUT "Terminating event channel 2 and consumer in 10 seconds...\n";
176 $T2_status = $T2->WaitKill ($t2->ProcessStopWaitInterval());
177 if ($T2_status != 0) {
178 print STDERR "ERROR: service returned $T2_status\n";
179 $status = 1;
181 $C->Kill();
183 sleep 10;
185 print STDOUT "Starting event channel 2 again...\n";
186 $T2_status = $T2->Spawn ();
188 if ($T2_status != 0) {
189 print STDERR "ERROR: T2 returned $T2_status\n";
190 exit 1;
193 sleep 2;
195 print STDOUT "Starting consumer again...\n";
196 $C_status = $C->Spawn ();
198 if ($C_status != 0) {
199 print STDERR "ERROR: Consumer returned $C_status\n";
200 exit 1;
203 print STDOUT "1500 seconds before termination...\n";
204 sleep 1500;
206 print STDOUT "Terminating supplier...\n";
207 $S_status = $S->WaitKill ($s->ProcessStopWaitInterval());
208 if ($S_status != 0) {
209 print STDERR "ERROR: Supplier returned $S_status\n";
210 $status = 1;
213 print STDOUT "Terminating consumer...\n";
214 $C_status = $C->WaitKill ($c->ProcessStopWaitInterval());
215 if ($C_status != 0) {
216 print STDERR "ERROR: Consumer returned $C_status\n";
217 $status = 1;
220 print STDOUT "Terminating gateway...\n";
221 $G_status = $G->TerminateWaitKill ($g->ProcessStopWaitInterval());
223 if ($G_status != 0) {
224 print STDERR "ERROR: Gateway returned $G_status\n";
225 $status = 1;
228 print STDOUT "Terminating event channels...\n";
229 $T1_status = $T1->TerminateWaitKill ($t1->ProcessStopWaitInterval());
231 if ($T1_status != 0) {
232 print STDERR "ERROR: service returned $T1_status\n";
233 $status = 1;
236 $T2_status = $T2->TerminateWaitKill ($t2->ProcessStopWaitInterval());
238 if ($T2_status != 0) {
239 print STDERR "ERROR: service returned $T2_status\n";
240 $status = 1;
243 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
245 if ($NS_status != 0) {
246 print STDERR "ERROR: Name Service returned $NS_status\n";
247 $status = 1;
250 $ns->DeleteFile ($nsiorfile);
251 $t1->DeleteFile ($nsiorfile);
252 $t2->DeleteFile ($nsiorfile);
253 $g->DeleteFile ($nsiorfile);
254 $c->DeleteFile ($nsiorfile);
255 $s->DeleteFile ($nsiorfile);
257 exit $status;