Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_3387_Regression / run_test.pl
blobdc22f9760268b2b1c271430a8e2c1d089539c8b3
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
6 use Env (ACE_ROOT);
7 use lib "$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 $nm_service = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
20 my $nt_service = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
21 my $server = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $client = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 my $consumer1 = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 my $consumer2 = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
26 my $consumer_orb_port = 12345;
27 my $endpoint = "-ORBEndPoint iiop://localhost:$consumer_orb_port";
29 my $svc_conf = "NotSvc.conf";
30 my $ns_ior = "ns.ior";
31 my $nt_ior = "notify.ior";
32 my $msngr_ior = "Messenger.ior";
34 my $nt_svc_conf = $nt_service->LocalFile ($svc_conf);
36 my $nm_ns_ior = $nm_service->LocalFile ($ns_ior);
37 my $nt_ns_ior = $nt_service->LocalFile ($ns_ior);
38 my $server_ns_ior = $server->LocalFile ($ns_ior);
39 my $client_ns_ior = $client->LocalFile ($ns_ior);
40 my $consumer1_ns_ior = $consumer1->LocalFile ($ns_ior);
41 my $consumer2_ns_ior = $consumer2->LocalFile ($ns_ior);
42 my $nt_nt_ior = $nt_service->LocalFile ($nt_ior);
43 my $server_msngr_ior = $server->LocalFile ($msngr_ior);
44 $nm_service->DeleteFile ($ns_ior);
45 $nt_service->DeleteFile ($ns_ior);
46 $server->DeleteFile ($ns_ior);
47 $client->DeleteFile ($ns_ior);
48 $consumer1->DeleteFile ($ns_ior);
49 $consumer2->DeleteFile ($ns_ior);
50 $nt_service->DeleteFile ($nt_ior);
51 $server->DeleteFile ($msngr_ior);
53 $NMS = $nm_service->CreateProcess("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
54 "-ORBdebuglevel $debug_level -o $nm_ns_ior");
55 $NFS = $nt_service->CreateProcess("$ENV{TAO_ROOT}/orbsvcs/Notify_Service/tao_cosnotification",
56 "-ORBdebuglevel $debug_level -ORBInitRef NameService=file://$nt_ns_ior ".
57 "-IORoutput $nt_nt_ior -UseSeparateDispatchingORB 1 ".
58 "-ORBSvcConf $nt_svc_conf");
59 $SV = $server->CreateProcess("MessengerServer", "-ORBInitRef NameService=file://$server_ns_ior");
60 $MC1 = $consumer1->CreateProcess("MessengerConsumer", "-ORBInitRef NameService=file://$consumer1_ns_ior ".
61 "$endpoint -p 1");
62 $MC2 = $consumer2->CreateProcess("MessengerConsumer", "-ORBInitRef NameService=file://$consumer2_ns_ior ".
63 "$endpoint -p 2");
64 $CL = $client->CreateProcess("MessengerClient", "-ORBInitRef NameService=file://$client_ns_ior");
66 # start Naming Service
67 $result = $NMS->Spawn();
69 if ($result != 0) {
70 print STDERR "ERROR: naming service returned $result\n";
71 exit 1;
74 if ($nm_service->WaitForFileTimed ($ns_ior,
75 $nm_service->ProcessStartWaitInterval()) == -1) {
76 print STDERR "ERROR: cannot find file $nm_ns_ior\n";
77 $NMS->Kill(); $NMS->TimedWait (1);
78 exit 1;
81 if ($nm_service->GetFile ($ns_ior) == -1) {
82 print STDERR "ERROR: cannot retrieve file <$nm_ns_ior>\n";
83 $NMS->Kill (); $NMS->TimedWait (1);
84 exit 1;
87 if ($nt_service->PutFile ($ns_ior) == -1) {
88 print STDERR "ERROR: cannot set file <$nt_ns_ior>\n";
89 $NMS->Kill (); $NMS->TimedWait (1);
90 exit 1;
93 if ($server->PutFile ($ns_ior) == -1) {
94 print STDERR "ERROR: cannot set file <$server_ns_ior>\n";
95 $NMS->Kill (); $NMS->TimedWait (1);
96 exit 1;
99 if ($client->PutFile ($ns_ior) == -1) {
100 print STDERR "ERROR: cannot set file <$client_ns_ior>\n";
101 $NMS->Kill (); $NMS->TimedWait (1);
102 exit 1;
105 if ($consumer1->PutFile ($ns_ior) == -1) {
106 print STDERR "ERROR: cannot set file <$consumer1_ns_ior>\n";
107 $NMS->Kill (); $NMS->TimedWait (1);
108 exit 1;
111 if ($consumer2->PutFile ($ns_ior) == -1) {
112 print STDERR "ERROR: cannot set file <$consumer2_ns_ior>\n";
113 $NMS->Kill (); $NMS->TimedWait (1);
114 exit 1;
117 # start Notification Service
118 $result = $NFS->Spawn();
120 if ($result != 0) {
121 print STDERR "ERROR: notify service returned $result\n";
122 $NMS->Kill (); $NMS->TimedWait (1);
123 exit 1;
126 # the ior file is only used to wait for the service to start
127 if ($nt_service->WaitForFileTimed ($nt_ior,
128 $nt_service->ProcessStartWaitInterval()) == -1) {
129 print STDERR "ERROR: cannot find file $nt_nt_ior\n";
130 $NMS->Kill (); $NMS->TimedWait (1);
131 $NFS->Kill (); $NFS->TimedWait (1);
132 exit 1;
135 # start MessengerServer
136 $result = $SV->Spawn();
138 if ($result != 0) {
139 $NMS->Kill (); $NMS->TimedWait (1);
140 $NFS->Kill (); $NFS->TimedWait (1);
141 exit 1;
144 # Wait for the MessengerServer
145 if ($server->WaitForFileTimed ($msngr_ior, $server->ProcessStartWaitInterval()) == -1) {
146 print STDERR "ERROR: Timed out waiting for $server_msngr_ior\n";
147 $SV->Kill(); $SV->TimedWait (1);
148 $NMS->Kill (); $NMS->TimedWait (1);
149 $NFS->Kill (); $NFS->TimedWait (1);
150 exit 1;
153 # start first MessengerConsumer
154 $result = $MC1->Spawn();
155 if ($result != 0) {
156 print STDERR "ERROR: Consumer 1 returned $result\n";
157 $status = 1;
160 # start MessengerClient
161 $result = $CL->Spawn();
162 if ($result != 0) {
163 print STDERR "ERROR: Client returned $result\n";
164 $status = 1;
167 # wait for first MessengerConsumer to end
168 $result = $MC1->WaitKill ($consumer1->ProcessStopWaitInterval());
169 if ($result != 0) {
170 print STDERR "ERROR: Consumer 1 returned $result\n";
171 $status = 1;
174 # start second MessengerConsumer
175 $result = $MC2->SpawnWaitKill ($consumer2->ProcessStartWaitInterval());
176 if ($result != 0) {
177 print STDERR "ERROR: Consumer 2 returned $result\n";
178 $status = 1;
181 $CL->Kill(); $CL->TimedWait (1);
182 $SV->Kill(); $SV->TimedWait (1);
183 $NMS->Kill (); $NMS->TimedWait (1);
184 $NFS->Kill (); $NFS->TimedWait (1);
186 $nm_service->DeleteFile ($ns_ior);
187 $nt_service->DeleteFile ($ns_ior);
188 $server->DeleteFile ($ns_ior);
189 $client->DeleteFile ($ns_ior);
190 $consumer1->DeleteFile ($ns_ior);
191 $consumer2->DeleteFile ($ns_ior);
192 $nt_service->DeleteFile ($nt_ior);
193 $server->DeleteFile ($msngr_ior);
195 exit $status;