Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / MC / run_test.pl
blob0c94da066bddb20aa9b784e8407cfb3600a0906d
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 $nfs = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
21 my $mon = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $sup = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 my $con = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
25 $mon->AddLibPath ('../lib');
26 $sup->AddLibPath ('../lib');
27 $con->AddLibPath ('../lib');
29 # define the following as necessary to customize the test
30 my $static_build = 0;
31 my $port = $ns->RandomPort ();
32 my $host = $ns->HostName ();
33 my $nscorbaloc = "-ORBInitRef NameService=corbaloc:iiop:$host:$port/NameService";
34 $static_build = new PerlACE::ConfigList->check_config('STATIC');
36 my $testmonior = "test_monitor.ior";
37 my $monitorior = "monitor.ior";
38 my $nsiorfile = "naming.ior";
39 my $nfsiorfile = "notify.ior";
40 my $readyfile = "ready.txt";
41 my $notify_conf = "notify$PerlACE::svcconf_ext";
43 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
44 my $nfs_nfsiorfile = $nfs->LocalFile ($nfsiorfile);
45 my $nfs_notify_conf = $nfs->LocalFile ($notify_conf);
46 my $nfs_monitorior = $nfs->LocalFile ($monitorior);
47 my $mon_monitorior = $mon->LocalFile ($monitorior);
48 my $mon_testmonior = $mon->LocalFile ($testmonior);
49 my $sup_testmonior = $sup->LocalFile ($testmonior);
50 my $con_testmonior = $con->LocalFile ($testmonior);
51 my $con_readyfile = $con->LocalFile ($readyfile);
52 $ns->DeleteFile ($nsiorfile);
53 $nfs->DeleteFile ($nfsiorfile);
54 $nfs->DeleteFile ($notify_conf);
55 $nfs->DeleteFile ($monitorior);
56 $mon->DeleteFile ($monitorior);
57 $mon->DeleteFile ($testmonior);
58 $sup->DeleteFile ($testmonior);
59 $con->DeleteFile ($testmonior);
60 $con->DeleteFile ($readyfile);
62 die "oops" if not open(FH, ">$notify_conf");
63 if($static_build){
64 print FH "static TAO_MonitorAndControl \"-o $nfs_monitorior " .
65 "-ORBArg -ORBInitRef " .
66 "-ORBArg NameService=corbaloc:iiop:$host:$port/NameService\"\n";
67 print FH "static TAO_MC_Notify_Service \"-DispatchingThreads 1 \"\n";
68 } else {
69 print FH "dynamic TAO_MC_Notify_Service Service_Object * " .
70 "TAO_CosNotification_MC_Ext:_make_TAO_MC_Notify_Service () \"\"\n";
71 print FH "static Notify_Default_Event_Manager_Objects_Factory \"-DispatchingThreads 1\"\n";
72 print FH "dynamic TAO_MonitorAndControl Service_Object * ".
73 "TAO_CosNotification_MC:_make_TAO_MonitorAndControl () \"" .
74 "-o $nfs_monitorior " .
75 "-ORBArg -ORBInitRef ".
76 "-ORBArg NameService=corbaloc:iiop:$host:$port/NameService" .
77 "\"\n";
79 close(FH);
81 if ($nfs->PutFile ($notify_conf) == -1) {
82 print STDERR "ERROR: cannot set file <$nfs_notify_conf>\n";
83 exit 1;
86 my $NS = $ns->CreateProcess("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
87 "-ORBEndpoint iiop://$host:$port -o $nsiorfile");
88 my $NFS = $nfs->CreateProcess("$ENV{TAO_ROOT}/orbsvcs/Notify_Service/tao_cosnotification",
89 "-ORBDebugLevel $debug_level ".
90 "$nscorbaloc " .
91 "-IORoutput $nfs_nfsiorfile " .
92 "-ORBSvcConf $nfs_notify_conf ");
93 my $MON = $mon->CreateProcess("test_monitor",
94 "-k file://$mon_monitorior -o $mon_testmonior");
95 my $SUP = $sup->CreateProcess("Structured_Supplier",
96 "$nscorbaloc ".
97 "-k file://$sup_testmonior");
98 my $CON = $con->CreateProcess("Structured_Consumer",
99 "$nscorbaloc ".
100 "-k file://$con_testmonior -o $con_readyfile");
102 print $NS->CommandLine()."\n";
103 $NS_status = $NS->Spawn ();
104 if ($NS_status != 0) {
105 print STDERR "ERROR: Name Service returned $NS_status\n";
106 exit 1;
108 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
109 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
110 $NS->Kill (); $NS->TimedWait (1);
111 exit 1;
114 print $NFS->CommandLine()."\n";
115 $NFS_status = $NFS->Spawn ();
116 if ($NFS_status != 0) {
117 print STDERR "ERROR: Notify Service returned $NFS_status\n";
118 exit 1;
120 if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()*2) == -1) {
121 print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
122 $NS->Kill (); $NS->TimedWait (1);
123 $NFS->Kill (); $NFS->TimedWait (1);
124 exit 1;
126 if ($nfs->WaitForFileTimed ($monitorior,$nfs->ProcessStartWaitInterval()) == -1) {
127 print STDERR "ERROR: cannot find file <$nfs_monitorior>\n";
128 $NS->Kill (); $NS->TimedWait (1);
129 $NFS->Kill (); $NFS->TimedWait (1);
130 exit 1;
132 if ($nfs->GetFile ($monitorior) == -1) {
133 print STDERR "ERROR: cannot retrieve file <$nfs_monitorior>\n";
134 $NS->Kill (); $NS->TimedWait (1);
135 $NFS->Kill (); $NFS->TimedWait (1);
136 exit 1;
138 if ($mon->PutFile ($monitorior) == -1) {
139 print STDERR "ERROR: cannot set file <$mon_monitorior>\n";
140 $NS->Kill (); $NS->TimedWait (1);
141 $NFS->Kill (); $NFS->TimedWait (1);
142 exit 1;
146 print $MON->CommandLine()."\n";
147 $MON_status = $MON->Spawn ();
148 if ($MON_status != 0) {
149 print STDERR "ERROR: Monitor returned $MON_status\n";
150 $MON->Kill (); $MON->TimedWait (1);
151 $NS->Kill (); $NS->TimedWait (1);
152 $NFS->Kill (); $NFS->TimedWait (1);
153 exit 1;
155 if ($mon->WaitForFileTimed ($testmonior,$mon->ProcessStartWaitInterval()) == -1) {
156 print STDERR "ERROR: cannot find file <$mon_testmonior>\n";
157 $MON->Kill (); $MON->TimedWait (1);
158 $NS->Kill (); $NS->TimedWait (1);
159 $NFS->Kill (); $NFS->TimedWait (1);
160 exit 1;
162 if ($mon->GetFile ($testmonior) == -1) {
163 print STDERR "ERROR: cannot retrieve file <$mon_testmonior>\n";
164 $MON->Kill (); $MON->TimedWait (1);
165 $NS->Kill (); $NS->TimedWait (1);
166 $NFS->Kill (); $NFS->TimedWait (1);
167 exit 1;
169 if ($sup->PutFile ($testmonior) == -1) {
170 print STDERR "ERROR: cannot set file <$sup_testmonior>\n";
171 $MON->Kill (); $MON->TimedWait (1);
172 $NS->Kill (); $NS->TimedWait (1);
173 $NFS->Kill (); $NFS->TimedWait (1);
174 exit 1;
176 if ($con->PutFile ($testmonior) == -1) {
177 print STDERR "ERROR: cannot set file <$con_testmonior>\n";
178 $MON->Kill (); $MON->TimedWait (1);
179 $NS->Kill (); $NS->TimedWait (1);
180 $NFS->Kill (); $NFS->TimedWait (1);
181 exit 1;
184 print $CON->CommandLine()."\n";
185 $CON_status = $CON->Spawn ();
186 if ($CON_status != 0) {
187 print STDERR "ERROR: Consumer returned $CON_status\n";
188 $CON->Kill (); $CON->TimedWait (1);
189 $MON->Kill (); $MON->TimedWait (1);
190 $NS->Kill (); $NS->TimedWait (1);
191 $NFS->Kill (); $NFS->TimedWait (1);
192 exit 1;
195 ## Wait for the consumer to create the event channel in
196 ## the Notify_Service and register it with the Name Service
197 if ($con->WaitForFileTimed ($readyfile,$con->ProcessStartWaitInterval()) == -1) {
198 print STDERR "ERROR: cannot find file <$con_readyfile>\n";
199 $CON->Kill (); $CON->TimedWait (1);
200 $MON->Kill (); $MON->TimedWait (1);
201 $NS->Kill (); $NS->TimedWait (1);
202 $NFS->Kill (); $NFS->TimedWait (1);
203 exit 1;
206 print $SUP->CommandLine()."\n";
207 $SUP_status = $SUP->SpawnWaitKill ($sup->ProcessStartWaitInterval()+15);
208 if ($SUP_status != 0) {
209 print STDERR "ERROR: Supplier returned $SUP_status\n";
210 $status = 1;
213 $CON_status = $CON->WaitKill ($con->ProcessStartWaitInterval()+45);
214 if ($CON_status != 0) {
215 print STDERR "ERROR: Consumer returned $CON_status\n";
216 $status = 1;
219 $MON_status = $MON->TerminateWaitKill ($mon->ProcessStopWaitInterval());
220 if ($MON_status != 0) {
221 print STDERR "ERROR: Monitor returned $MON_status\n";
222 $status = 1;
225 $NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
226 if ($NFS_status != 0) {
227 print STDERR "ERROR: Notification Service returned $NFS_status\n";
228 $status = 1;
231 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
232 if ($NS_status != 0) {
233 print STDERR "ERROR: Name Service returned $NS_status\n";
234 $status = 1;
237 $ns->DeleteFile ($nsiorfile);
238 $nfs->DeleteFile ($nfsiorfile);
239 $nfs->DeleteFile ($notify_conf);
240 $nfs->DeleteFile ($monitorior);
241 $mon->DeleteFile ($monitorior);
242 $mon->DeleteFile ($testmonior);
243 $sup->DeleteFile ($testmonior);
244 $con->DeleteFile ($testmonior);
245 $con->DeleteFile ($readyfile);
247 exit $status;