Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / EventServices / RTEC_Federated / run_test.pl
blob572ac4bdf9ee4c91d2d30239b1ac39be44390681
2 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
3 & eval 'exec perl -S $0 $argv:q'
4 if 0;
6 use lib "$ENV{ACE_ROOT}/bin";
7 use PerlACE::TestTarget;
9 $status = 0;
10 $debug_level = '0';
12 foreach $i (@ARGV) {
13 if ($i eq '-debug') {
14 $debug_level = '10';
18 my $ns = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
19 my $s1 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
20 my $s2 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
21 my $c1 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
22 my $c2 = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 my $nsiorfile = "ns.ior";
25 my $ec1iorfile = "ec1.ior";
26 my $ec2iorfile = "ec2.ior";
27 my $supplier_conf_file = "";
28 if ( -e "supplier.conf" ) {
29 $supplier_conf_file = "supplier.conf";
31 else{
32 $supplier_conf_file = "../supplier.conf";
35 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
36 my $s1_ec1iorfile = $s1->LocalFile ($ec1iorfile);
37 my $s2_ec2iorfile = $s2->LocalFile ($ec2iorfile);
38 my $s1_nsiorfile = $s1->LocalFile ($nsiorfile);
39 my $s2_nsiorfile = $s2->LocalFile ($nsiorfile);
40 my $c1_nsiorfile = $c1->LocalFile ($nsiorfile);
41 my $c2_nsiorfile = $c2->LocalFile ($nsiorfile);
42 $ns->DeleteFile ($nsiorfile);
43 $s1->DeleteFile ($ec1iorfile);
44 $s2->DeleteFile ($ec2iorfile);
45 $s1->DeleteFile ($nsiorfile);
46 $s2->DeleteFile ($nsiorfile);
47 $c1->DeleteFile ($nsiorfile);
48 $c2->DeleteFile ($nsiorfile);
50 $NameService = "$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming";
51 $NS = $ns->CreateProcess ($NameService, "-ORBdebuglevel $debug_level ".
52 " -o $ns_nsiorfile");
53 $args1 = "-ORBSvcConf $supplier_conf_file -ecname ec1 -gateway ec2";
54 $S1 = $s1->CreateProcess ("EchoEventSupplier", "-ORBInitRef NameService=file://$s1_nsiorfile ".
55 "$args1 ".
56 "-iorfile $s1_ec1iorfile");
57 $args2 = "-ORBSvcConf $supplier_conf_file -ecname ec2 -gateway ec1";
58 $S2 = $s2->CreateProcess ("EchoEventSupplier", "-ORBInitRef NameService=file://$s2_nsiorfile ".
59 "$args2 ".
60 "-iorfile $s2_ec2iorfile");
61 $args3 = "-ecname ec1";
62 $C1 = $c1->CreateProcess ("EchoEventConsumer", "-ORBInitRef NameService=file://$c1_nsiorfile ".
63 "$args3");
64 $args4 = "-ecname ec2";
65 $C2 = $c2->CreateProcess ("EchoEventConsumer", "-ORBInitRef NameService=file://$c2_nsiorfile ".
66 "$args4");
69 # start Naming Service
70 $NS_status = $NS->Spawn ();
72 if ($NS_status != 0) {
73 print STDERR "ERROR: Name Service returned $NS_status\n";
74 exit 1;
77 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
78 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
79 $NS->Kill (); $NS->TimedWait (1);
80 exit 1;
83 if ($ns->GetFile ($nsiorfile) == -1) {
84 print STDERR "ERROR: cannot retrieve file <$ns_nsiorfile>\n";
85 $NS->Kill (); $NS->TimedWait (1);
86 exit 1;
88 if ($s1->PutFile ($nsiorfile) == -1) {
89 print STDERR "ERROR: cannot set file <$s1_nsiorfile>\n";
90 $NS->Kill (); $NS->TimedWait (1);
91 exit 1;
93 if ($s2->PutFile ($nsiorfile) == -1) {
94 print STDERR "ERROR: cannot set file <$s2_nsiorfile>\n";
95 $NS->Kill (); $NS->TimedWait (1);
96 exit 1;
98 if ($c1->PutFile ($nsiorfile) == -1) {
99 print STDERR "ERROR: cannot set file <$c1_nsiorfile>\n";
100 $NS->Kill (); $NS->TimedWait (1);
101 exit 1;
103 if ($c2->PutFile ($nsiorfile) == -1) {
104 print STDERR "ERROR: cannot set file <$c2_nsiorfile>\n";
105 $NS->Kill (); $NS->TimedWait (1);
106 exit 1;
109 # start Supplier
110 $S1_status = $S1->Spawn ();
112 if ($S1_status != 0) {
113 print STDERR "ERROR: Supplier1 returned $S1_status\n";
114 exit 1;
117 $S2_status = $S2->Spawn ();
119 if ($S2_status != 0) {
120 print STDERR "ERROR: Supplier2 returned $S2_status\n";
121 exit 1;
124 if ($s1->WaitForFileTimed ($ec1iorfile, $s1->ProcessStartWaitInterval()+60) == -1) {
125 print STDERR "ERROR: cannot find file <$s1_ec1iorfile>\n";
126 $NS->Kill (); $NS->TimedWait (1);
127 $S1->Kill (); $S1->TimedWait (1);
128 exit 1;
131 if ($s2->WaitForFileTimed ($ec2iorfile, $s2->ProcessStartWaitInterval()) == -1) {
132 print STDERR "ERROR: cannot find file <$s2_ec2iorfile>\n";
133 $NS->Kill (); $NS->TimedWait (1);
134 $S1->Kill (); $S1->TimedWait (1);
135 $S2->Kill (); $S2->TimedWait (1);
136 exit 1;
139 $C1_status = $C1->Spawn ();
141 if ($C1_status != 0) {
142 print STDERR "ERROR: Consumer returned $C1_status\n";
143 exit 1;
146 $C2_status = $C2->Spawn ();
148 if ($C2_status != 0) {
149 print STDERR "ERROR: Consumer returned $C2_status\n";
150 exit 1;
153 $C1_status = $C1->WaitKill ($c1->ProcessStopWaitInterval()+45);
155 if ($C1_status != 0) {
156 print STDERR "ERROR: Consumer1 returned $C1_status\n";
157 $status = 1;
160 $C2_status = $C2->WaitKill ($c2->ProcessStopWaitInterval());
162 if ($C2_status != 0) {
163 print STDERR "ERROR: Consumer2 returned $C2_status\n";
164 $status = 1;
167 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
169 if ($NS_status != 0) {
170 print STDERR "ERROR: Name Service returned $NS_status\n";
171 $status = 1;
174 $S1_status = $S1->TerminateWaitKill ($s1->ProcessStopWaitInterval());
176 if ($S1_status != 0) {
177 print STDERR "ERROR: Supplier1 returned $S1_status\n";
178 $status = 1;
181 $S2_status = $S2->TerminateWaitKill ($s2->ProcessStopWaitInterval());
183 if ($S2_status != 0) {
184 print STDERR "ERROR: Supplier2 returned $S2_status\n";
185 $status = 1;
188 $ns->DeleteFile ($nsiorfile);
189 $s1->DeleteFile ($ec1iorfile);
190 $s2->DeleteFile ($ec2iorfile);
191 $s1->DeleteFile ($nsiorfile);
192 $s2->DeleteFile ($nsiorfile);
193 $c1->DeleteFile ($nsiorfile);
194 $c2->DeleteFile ($nsiorfile);
196 exit $status;