Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Discarding / run_test.pl
blob72ee2ef01ec71cfbde12056b0c3f0afa935a2010
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 $sts = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
22 my $stc = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
23 my $ses = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
24 my $sec = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
26 $sts->AddLibPath ('../lib');
27 $stc->AddLibPath ('../lib');
28 $ses->AddLibPath ('../lib');
29 $sec->AddLibPath ('../lib');
31 PerlACE::check_privilege_group();
33 $port = $ns->RandomPort ();
34 $host = $ns->HostName ();
35 $deadline = 0;
37 $iorbase = "supplier.ior";
38 $nfsiorfile = "notify.ior";
39 $nsiorfile = "naming.ior";
40 $nfsconffile = "notify$PerlACE::svcconf_ext";
42 my $ns_nsiorfile = $ns->LocalFile ($nsiorfile);
43 my $nfs_nfsiorfile = $nfs->LocalFile ($nfsiorfile);
44 my $sts_iorfile = $sts->LocalFile ($iorbase);
45 my $stc_iorfile = $stc->LocalFile ($iorbase);
46 my $sec_iorfile = $sec->LocalFile ($iorbase);
47 my $ses_iorfile = $ses->LocalFile ($iorbase);
48 my $nfs_nfsconffile = $nfs->LocalFile ($nfsconffile);
49 $ns->DeleteFile ($nsiorfile);
50 $nfs->DeleteFile ($nfsiorfile);
51 $sts->DeleteFile ($iorbase);
52 $stc->DeleteFile ($iorbase);
53 $sec->DeleteFile ($iorbase);
54 $ses->DeleteFile ($iorbase);
56 foreach my $arg (@ARGV) {
57 if ($arg eq "-d") {
58 $deadline = 1;
60 else {
61 print "Usage: $0 [-d]\n" .
62 " -d specifies that deadline discarding be tested.\n";
63 exit(0);
67 $NS = $ns->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Naming_Service/tao_cosnaming",
68 "-ORBEndpoint iiop://$host:$port -o $ns_nsiorfile");
70 $NFS = $nfs->CreateProcess ("$ENV{TAO_ROOT}/orbsvcs/Notify_Service/tao_cosnotification",
71 "-ORBInitRef NameService=iioploc://" .
72 "$host:$port/NameService " .
73 "-IORoutput $nfs_nfsiorfile -ORBSvcConf " .
74 "$nfs_nfsconffile");
76 $STS = $sts->CreateProcess ("Structured_Supplier",
77 "-ORBDebugLevel $debug_level ".
78 "-ORBInitRef NameService=iioploc://".
79 "$host:$port/NameService ".
80 "-o $sts_iorfile");
82 $STC = $stc->CreateProcess ("Structured_Consumer");
84 $SES = $ses->CreateProcess ("Sequence_Supplier",
85 "-ORBDebugLevel $debug_level ".
86 "-ORBInitRef NameService=iioploc://".
87 "$host:$port/NameService ".
88 "-o $ses_iorfile");
90 $SEC = $sec->CreateProcess ("Sequence_Consumer");
92 $CLI_args = "-ORBInitRef NameService=iioploc://$host:$port/NameService ";
95 $NS_status = $NS->Spawn ();
96 if ($NS_status != 0) {
97 print STDERR "ERROR: Name Service returned $NS_status\n";
98 exit 1;
100 if ($ns->WaitForFileTimed ($nsiorfile,$ns->ProcessStartWaitInterval()) == -1) {
101 print STDERR "ERROR: cannot find file <$ns_nsiorfile>\n";
102 $NS->Kill (); $NS->TimedWait (1);
103 exit 1;
106 $NFS_status = $NFS->Spawn ();
107 if ($NFS_status != 0) {
108 print STDERR "ERROR: Notify Service returned $NFS_status\n";
109 exit 1;
111 if ($nfs->WaitForFileTimed ($nfsiorfile,$nfs->ProcessStartWaitInterval()) == -1) {
112 print STDERR "ERROR: cannot find file <$nfs_nfsiorfile>\n";
113 $NS->Kill (); $NS->TimedWait (1);
114 $NFS->Kill (); $NFS->TimedWait (1);
115 exit 1;
118 @policies = ("fifo", "priority", "lifo");
119 if ($deadline) {
120 push(@policies, "deadline");
123 @server_opts = ("", "", "", " -d");
124 if ($status == 0) {
125 for($i = 0; $i <= $#policies; $i++) {
126 $discard_policy = $policies[$i];
127 print "****** Structured Supplier -> Structured Consumer with the " .
128 "$discard_policy policy ******\n";
130 $STS->Arguments($STS->Arguments() . $server_opts[$i]);
131 $STS_status = $STS->Spawn ();
132 if ($STS_status != 0) {
133 print STDERR "ERROR: Structured Supplier returned $STS_status\n";
134 $status = 1;
135 last;
137 if ($sts->WaitForFileTimed ($iorbase,$sts->ProcessStartWaitInterval()) == -1) {
138 print STDERR "ERROR: cannot1 find file <$sts_iorfile>\n";
139 $STS->Kill (); $STS->TimedWait (1);
140 $status = 1;
141 last;
143 if ($sts->GetFile ($iorbase) == -1) {
144 print STDERR "ERROR: cannot retrieve file <$sts_iorfile>\n";
145 $STS->Kill (); $STS->TimedWait (1);
146 $status = 1;
147 last;
149 if ($stc->PutFile ($iorbase) == -1) {
150 print STDERR "ERROR: cannot set file <$stc_iorfile>\n";
151 $STS->Kill (); $STS->TimedWait (1);
152 $status = 1;
153 last;
155 sleep 2;
157 $STC->Arguments($CLI_args . " -k file://$stc_iorfile -d $discard_policy");
158 $STC_status = $STC->SpawnWaitKill ($stc->ProcessStartWaitInterval()+5);
159 if ($STC_status != 0) {
160 print STDERR "ERROR: Structured Consumer returned $STC_status\n";
161 $STS->Kill (); $STS->TimedWait (1);
162 $status = 1;
163 last;
166 $STS_status = $STS->WaitKill ($sts->ProcessStopWaitInterval());
167 if ($STS_status != 0) {
168 print STDERR "ERROR: Structured Supplier returned $STS_status\n";
169 $status = 1;
170 last;
173 $sts->DeleteFile ($iorbase);
174 $stc->DeleteFile ($iorbase);
177 $sts->DeleteFile ($iorbase);
178 $stc->DeleteFile ($iorbase);
180 if ($status == 0) {
181 for($i = 0; $i <= $#policies; $i++) {
182 $discard_policy = $policies[$i];
183 print "***** Structured Supplier -> Sequence Consumer with the " .
184 "$discard_policy policy *****\n";
186 $STS->Arguments($STS->Arguments() . $server_opts[$i]);
187 $STS_status = $STS->Spawn ();
188 if ($STS_status != 0) {
189 print STDERR "ERROR: Structured Supplier returned $STS_status\n";
190 $status = 1;
191 last;
193 if ($sts->WaitForFileTimed ($iorbase,$sts->ProcessStartWaitInterval()) == -1) {
194 print STDERR "ERROR: cannot find file <$sts_iorfile>\n";
195 $STS->Kill (); $STS->TimedWait (1);
196 $status = 1;
197 last;
199 if ($sts->GetFile ($iorbase) == -1) {
200 print STDERR "ERROR: cannot retrieve file <$sts_iorfile>\n";
201 $STS->Kill (); $STS->TimedWait (1);
202 $status = 1;
203 last;
205 if ($sec->PutFile ($iorbase) == -1) {
206 print STDERR "ERROR: cannot set file <$sec_iorfile>\n";
207 $STS->Kill (); $STS->TimedWait (1);
208 $status = 1;
209 last;
211 sleep 2;
213 $SEC->Arguments($CLI_args . " -k file://$sec_iorfile -d $discard_policy");
214 $SEC_status = $SEC->SpawnWaitKill ($sec->ProcessStartWaitInterval()+5);
215 if ($SEC_status != 0) {
216 print STDERR "ERROR: Sequence Consumer returned $SEC_status\n";
217 $STS->Kill (); $STS->TimedWait (1);
218 $status = 1;
219 last;
222 $STS_status = $STS->WaitKill ($sts->ProcessStopWaitInterval());
223 if ($STS_status != 0) {
224 print STDERR "ERROR: Structured Supplier returned $STS_status\n";
225 $status = 1;
226 last;
229 $sts->DeleteFile ($iorbase);
230 $sec->DeleteFile ($iorbase);
233 $sts->DeleteFile ($iorbase);
234 $sec->DeleteFile ($iorbase);
236 if ($status == 0) {
237 for($i = 0; $i <= $#policies; $i++) {
238 $discard_policy = $policies[$i];
239 print "**** Sequence Supplier -> Sequence Consumer with the " .
240 "$discard_policy policy ****\n";
242 $SES->Arguments($SES->Arguments() . $server_opts[$i]);
243 $SES_status = $SES->Spawn ();
244 if ($SES_status != 0) {
245 print STDERR "ERROR: Sequence Supplier returned $SES_status\n";
246 $status = 1;
247 last;
249 if ($ses->WaitForFileTimed ($iorbase,$ses->ProcessStartWaitInterval()) == -1) {
250 print STDERR "ERROR: cannot find file <$ses_iorfile>\n";
251 $STS->Kill (); $STS->TimedWait (1);
252 $status = 1;
253 last;
255 if ($ses->GetFile ($iorbase) == -1) {
256 print STDERR "ERROR: cannot retrieve file <$ses_iorfile>\n";
257 $STS->Kill (); $STS->TimedWait (1);
258 $status = 1;
259 last;
261 if ($sec->PutFile ($iorbase) == -1) {
262 print STDERR "ERROR: cannot set file <$sec_iorfile>\n";
263 $STS->Kill (); $STS->TimedWait (1);
264 $status = 1;
265 last;
267 sleep 2;
269 $SEC->Arguments($CLI_args . " -k file://$sec_iorfile -d $discard_policy");
270 $SEC_status = $SEC->SpawnWaitKill ($sec->ProcessStartWaitInterval()+5);
271 if ($SEC_status != 0) {
272 print STDERR "ERROR: Sequence Consumer returned $SEC_status\n";
273 $SES->Kill (); $SES->TimedWait (1);
274 $status = 1;
275 last;
278 $SES_status = $SES->WaitKill ($ses->ProcessStopWaitInterval());
279 if ($SES_status != 0) {
280 print STDERR "ERROR: Sequence Supplier returned $SES_status\n";
281 $status = 1;
282 last;
285 $ses->DeleteFile ($iorbase);
286 $sec->DeleteFile ($iorbase);
289 $ses->DeleteFile ($iorbase);
290 $sec->DeleteFile ($iorbase);
292 if ($status == 0) {
293 for($i = 0; $i <= $#policies; $i++) {
294 $discard_policy = $policies[$i];
295 print "**** Sequence Supplier -> Structured Consumer with the " .
296 "$discard_policy policy ****\n";
298 $SES->Arguments($SES->Arguments() . $server_opts[$i]);
299 $SES_status = $SES->Spawn ();
300 if ($SES_status != 0) {
301 print STDERR "ERROR: Sequence Supplier returned $SES_status\n";
302 $status = 1;
303 last;
305 if ($ses->WaitForFileTimed ($iorbase,$ses->ProcessStartWaitInterval()) == -1) {
306 print STDERR "ERROR: cannot find file <$ses_iorfile>\n";
307 $STS->Kill (); $STS->TimedWait (1);
308 $status = 1;
309 last;
311 if ($ses->GetFile ($iorbase) == -1) {
312 print STDERR "ERROR: cannot retrieve file <$ses_iorfile>\n";
313 $STS->Kill (); $STS->TimedWait (1);
314 $status = 1;
315 last;
317 if ($stc->PutFile ($iorbase) == -1) {
318 print STDERR "ERROR: cannot set file <$stc_iorfile>\n";
319 $STS->Kill (); $STS->TimedWait (1);
320 $status = 1;
321 last;
323 sleep 2;
325 $STC->Arguments($CLI_args . " -k file://$stc_iorfile -d $discard_policy");
326 $STC_status = $STC->SpawnWaitKill ($stc->ProcessStartWaitInterval()+5);
327 if ($STC_status != 0) {
328 print STDERR "ERROR: Structured Consumer returned $STC_status\n";
329 $status = 1;
330 last;
333 $SES_status = $SES->WaitKill ($ses->ProcessStopWaitInterval());
334 if ($SES_status != 0) {
335 print STDERR "ERROR: Sequence Supplier returned $SES_status\n";
336 $status = 1;
337 last;
339 $ses->DeleteFile ($iorbase);
340 $stc->DeleteFile ($iorbase);
344 $NFS_status = $NFS->Kill ($nfs->ProcessStopWaitInterval());
345 if ($NFS_status != 0) {
346 print STDERR "ERROR: Notify Service returned $NFS_status\n";
347 $status = 1;
350 $NS_status = $NS->TerminateWaitKill ($ns->ProcessStopWaitInterval());
351 if ($NS_status != 0) {
352 print STDERR "ERROR: Name Service returned $NS_status\n";
353 $status = 1;
356 $ns->DeleteFile ($nsiorfile);
357 $nfs->DeleteFile ($nfsiorfile);
358 $sts->DeleteFile ($iorbase);
359 $stc->DeleteFile ($iorbase);
360 $sec->DeleteFile ($iorbase);
361 $ses->DeleteFile ($iorbase);
363 exit $status;